HLS Stream无法在运行Android 9.0的设备和模拟器中播放。 HLS Stream适用于在API级别28以下运行的其他设备和模拟器。该应用程序正在使用Exoplayer v2库。
堆栈跟踪中的错误如下:
E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://streamIP/hls/stream.m3u8
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:137)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65)
at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:114)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
目前的app/build.gradle
如下:
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 28
versionCode 14
versionName "14.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}...
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:28.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
testCompile 'junit:junit:4.12'
implementation 'com.google.android.exoplayer:exoplayer:r2.5.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.android.support:multidex:1.0.3'
}
确保为Android 9允许不安全的网络连接。默认情况下禁用此功能。