Description

  • Audio player (mp3player) API

Interface version

Version number Writer Date Description
1.0 Xie Yicheng November 23, 2020 initial release

IP address

http://192.168.1.1

Audio storage path

/usr/layout_test.mp3

API list

Name Description
set_path set playback path
set_volume set playback volume
switch_music switch music
get_directory get MP3 files in the directory
stop stop playback

1. set_path

Request parameter description

Parameter name Type Description
path string file path information

Call sample

  1. ubus command method:
ubus call mp3player set_path '{"path":"/usr/layout_test.mp3"}'
  1. wapi command method:
wapi 8ms '{"ver": "1.0", "module": "mp3player",  "api": "set_path", "param": {"path": "/usr/layout_test.mp3"}}'

Return sample

{
        "path": "\/usr\/layout_test.mp3"
}

Return parameter description

Parameter Name Type Description
path string file path information

Error code

Error Code Description

2. set_volume

Request parameter description

Parameter Name Type Description
volume uint32 volume range 0-90

Call sample

  1. ubus command method:
ubus call mp3player set_volume '{"volume":10}'
  1. wapi command method:
wapi 8ms '{"ver": "1.0", "module": "mp3player",  "api": "set_volume", "param": {"volume": "10"}}'

Return sample

{
        "volume": 10
}

Return parameter description

Parameter Name Type Description
volume uint32 volume value

Error code

Error Code Description

3. cutover_music

Request parameter description

Parameter Name Type Description
cutover string select the previous song “up” or the next song “down”

Call sample

  1. ubus command method:
ubus call mp3player switch_music '{"switch":"up"}'
ubus call mp3player switch_music '{"switch":"down"}'
  1. wapi command method:
wapi 8ms '{"ver": "1.0", "module": "mp3player",  "api": "switch_music", "param": {"switch": "up"}}'
wapi 8ms '{"ver": "1.0", "module": "mp3player",  "api": "switch_music", "param": {"switch": "down"}}'

Return sample

{
        "switch": "down",
        "index": 1,
        "music": "\/usr\/layout_test2.mp3"
}

Return parameter description

Parameter Name Type Description
cutover string choose the previous or next song
index uint32 the directory where the current song is located
music string the path of the currently playing song

Error code

Error Code Description

4. get_directory

Request parameter description

Parameter Name Type Description
directory string the directory to be queried

Call sample

  1. ubus command method:
ubus call mp3player get_directory '{"directory":"/usr"}'
  1. wapi command method:
wapi 8ms '{"ver": "1.0", "module": "mp3player",  "api": "get_directory", "param": {"directory": "/usr"}}'

Return sample

{
        "directory": "\/usr",
        "num": 2,
        "list"{ "videoplayback.mp3",
                 "201_7.mp3"
              }
}

Return parameter description

Parameter Name Type Description
directory string the directory currently being queried
num uint32 the total number of files queried
list string the file names queried

Error code

Error Code Description

5. stop

Request parameter description

Parameter Name Type Description
stop uint32 stop

Call sample

  1. ubus command method:
ubus call mp3player stop '{"stop":"stop"}'
  1. wapi command method:
wapi 8ms '{"ver": "1.0", "module": "mp3player",  "api": "stop"}'

Return sample

{
   "stop": "ok"
}

Return parameter description

Parameter Name Type Description
stop uint32 stop

Error code

Error Code Description
文档更新时间: 2021-06-02 15:12   作者:plj