diff --git a/en/medialib/audio.Audio.md b/en/medialib/audio.Audio.md index 19eb62edfd38fa747f805e8c836213535a3e5725..a4731dfacf77de7693a1d6b8a9faf9e52e98475b 100644 --- a/en/medialib/audio.Audio.md +++ b/en/medialib/audio.Audio.md @@ -237,6 +237,8 @@ Audio.playStream(format, buf) This method plays audio stream. It supports audio stream in MP3, AMR, and WAV format. +> Note: When playing an AMR format audio stream, if the audio comes from a file, it is recommended to skip the first 6 bytes (i.e., the file header) after starting to read the file; otherwise, playback may fail. + **Parameter:** - `format` - Integer type. The audio stream format. `2` - `WAVPCM`,`3` - `MP3`,`4` - `AMRNB`. diff --git a/zh/medialib/audio.Audio.md b/zh/medialib/audio.Audio.md index 780dff9610d8a2932260fe1c42c8cae9b3dc2cec..e58cff7681ae088eebcbe3d3addd4750d7c3b9b3 100644 --- a/zh/medialib/audio.Audio.md +++ b/zh/medialib/audio.Audio.md @@ -193,6 +193,8 @@ Audio.playStream(format, buf) 该方法用于音频流播放,支持mp3、amr和wav格式的音频流播放。 +> 说明:播放 AMR 格式音频流时,若音频来源于文件,建议在开始读取文件后跳过开头 6 个字节(即文件头),否则可能导致播放失败。 + **参数描述:** - `format` - 音频流格式,int类型,`2` - `WAVPCM`,`3` - `MP3`,`4` - `AMRNB`。 @@ -280,7 +282,9 @@ format = 4 def play_from_fs(): file_size = uos.stat("/usr/test.amr")[6] # 获取文件总字节数 print(file_size) - with open("/usr/test.amr", "rb")as f: + with open("/usr/test.amr", "rb")as f: + if format == 4: + f.read(6) # 跳过6字节的AMR文件头 while 1: b = f.read(size) # read if not b: