无法在Android Pie上播放带有颤动声音插件的音乐

问题描述 投票:-1回答:1

我正在使用Flutter Sound plugin播放Android上的网址音乐。这在Android 8上没有任何问题,但在更新到Android 9之后,来自URL的音乐不再播放了。我为the plugin打开了一个问题,但这似乎是Android 9本身的一些重大改变。

Android 9中是否有任何变化会导致这种情况?

我在android 9 changes上找不到任何明显的东西。

这是日志输出:

I/MediaPlayer(26707): Need to enable context aware info
V/MediaPlayer-JNI(26707): native_setup
I/flutter (26707): error: Exception: Player already stopped.
V/MediaPlayerNative(26707): constructor
V/MediaPlayerNative(26707): setListener
V/MediaHTTPService(26707): MediaHTTPService(android.media.MediaHTTPService@b2558b2): Cookies: null
V/MediaPlayerNative(26707): setVideoSurfaceTexture
V/MediaPlayerNative(26707): prepare
V/MediaHTTPService(26707): makeHTTPConnection: CookieManager created: java.net.CookieManager@b993003
V/MediaHTTPService(26707): makeHTTPConnection(android.media.MediaHTTPService@b2558b2): cookieHandler: java.net.CookieManager@b993003 Cookies: null
D/MediaHTTPConnection(26707): setReadTimeOut = 15000ms
D/NetworkSecurityConfig(26707): Using Network Security Config from resource network_security_config debugBuild: true
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
D/MediaHTTPConnection(26707): setReadTimeout with 15000ms
I/System.out(26707): (HTTPLog)-Static: isSBSettingEnabled false
V/MediaPlayerNative(26707): message received msg=300, ext1=0, ext2=0
V/MediaPlayerNative(26707): Received SEC_MM_PLAYER_CONTEXT_AWARE
V/MediaPlayerNative(26707): callback application
V/MediaPlayerNative(26707): back from callback
V/MediaPlayerNative(26707): message received msg=100, ext1=1, ext2=-2147483648
E/MediaPlayerNative(26707): error (1, -2147483648)
V/MediaPlayerNative(26707): signal application thread
V/MediaPlayerNative(26707): prepare complete - status=1
E/FlutterSoundPlugin(26707): startPlayer() exception
E/flutter (26707): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Exception: PlatformException(ERR_UNKNOWN, ERR_UNKNOWN, Prepare failed.: status=0x1)
E/flutter (26707): #0 FlutterSound.startPlayer (package:flutter_sound/flutter_sound.dart:163:7)
E/flutter (26707):
android dart flutter android-mediaplayer flutter-dependencies
1个回答
1
投票

从Android 9.0(API级别28)开始,默认情况下禁用明文支持。

因此,MediaPlayer无法打开提供的URL。

选项是:

  1. 在AndroidManifest.xml中设置android:usesCleartextTraffic =“true”
  2. 使用HTTPS

解决方案在这里解释Android 8: Cleartext HTTP traffic not permitted

© www.soinside.com 2019 - 2024. All rights reserved.