我正在使用 audioplayers 播放音频。尽管如此,我还是收到了这个错误:
V/MediaPlayer(13566): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13566): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(13566): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13566): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(13566): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13566): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaHTTPService(13566): MediaHTTPService(android.media.MediaHTTPService@5069e1b): Cookies: null
V/MediaHTTPService(13566): makeHTTPConnection: CookieHandler (java.net.CookieManager@f9da40) exists.
V/MediaHTTPService(13566): makeHTTPConnection(android.media.MediaHTTPService@5069e1b): cookieHandler: java.net.CookieManager@f9da40 Cookies: null
屏幕上出现此信息后不久:
E/flutter (13566): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: TimeoutException after 0:00:30.000000: Future not completed
E/flutter (13566):
E/MediaPlayerNative(13566): error (1, -2147483648)
E/MediaPlayer(13566): Error (1,-2147483648)
V/MediaPlayer(13566): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13566): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(13566): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(13566): cleanDrmObj: mDrmObj=null mDrmSessionId=null
I/flutter (13566): AudioPlayers Exception: AudioPlayerException(
I/flutter (13566): UrlSource(url: https://file-examples.com/storage/fe1dbaea7664d369bb6e226/2017/11/file_example_MP3_700KB.mp3),
I/flutter (13566): PlatformException(MEDIA_ERROR_UNKNOWN {what:1}, MEDIA_ERROR_SYSTEM, null, null)
代码只是对音频 URL 的调用:
class MyWidget extends StatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
@override
void initState() {
super.initState();
AudioPlayer().play(UrlSource(
"https://file-examples.com/storage/fe1dbaea7664d369bb6e226/2017/11/file_example_MP3_700KB.mp3"));
}
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
我应该做什么来解决这个问题? bug从哪里来?
我使用的是 Android 模拟器:Pixel 2 (R) API 30。最新的 Dart、Flutter 和 audioplayers 版本。
注意: https://file-examples.com/storage/fe1dbaea7664d369bb6e226/2017/11/file_example_MP3_700KB.mp3是我在互联网上找到的随机音频文件的链接。寻找更多,发生了一个相同的错误,所以它不可能是源头。
如果您想播放远程音频,可以尝试这个。
UrlSource(Uri.decodeFull(url))