Flutter 中的流媒体广播
Posted
技术标签:
【中文标题】Flutter 中的流媒体广播【英文标题】:Streaming radio in flutter 【发布时间】:2021-08-26 21:50:44 【问题描述】:我有问题。我在我的应用程序中查看广播频道并使用 assets_audio_player(https://pub.dev/packages/assets_audio_player) 并且我还使用了其他几个但同样的问题。 如下。
> isRestricted mode = 0 E/ExoPlayerImplInternal(30199): Playback error
> E/ExoPlayerImplInternal(30199):
> com.google.android.exoplayer2.ExoPlaybackException: Source error
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException:
> Unable to connect E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:356)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1015)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
> E/ExoPlayerImplInternal(30199): at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
> E/ExoPlayerImplInternal(30199): at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
> E/ExoPlayerImplInternal(30199): at
> java.lang.Thread.run(Thread.java:919) E/ExoPlayerImplInternal(30199):
> Caused by: javax.net.ssl.SSLHandshakeException:
> java.security.cert.CertPathValidatorException: Trust anchor for
> certification path not found. E/ExoPlayerImplInternal(30199): at
> com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:231)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:90)
> E/ExoPlayerImplInternal(30199): at
> com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:30)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:641)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:528)
> E/ExoPlayerImplInternal(30199): at
> com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:349)
> E/ExoPlayerImplInternal(30199): ... 7 more
> E/ExoPlayerImplInternal(30199): Caused by:
> java.security.cert.CertificateException:
> java.security.cert.CertPathValidatorException: Trust anchor for
> certification path not found. E/ExoPlayerImplInternal(30199): at
> com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:658)
android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
> E/ExoPlayerImplInternal(30199): at
> android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:89)
> E/ExoPlayerImplInternal(30199): at
> com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:224)
> E/ExoPlayerImplInternal(30199): at
> com.android.org.conscrypt.ConscryptFileDescriptorSocket.verifyCertificateChain(ConscryptFileDescriptorSocket.java:407)
> E/ExoPlayerImplInternal(30199): at
> com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Meth
manifest img
network-security-config img 这是网址https://icecast.mada.ps:8495/ajyalnewssl
【问题讨论】:
【参考方案1】:问题不在于您的代码,而在于流 URL。
我已经在https://players.akamai.com/
等在线播放器上测试了您提供的收音机链接,但声音无法打开。所以,我认为这个收音机不受支持,因为它是.mp3
格式而不是.m3u8
用于STREAMs
【讨论】:
我在安卓应用上测试过,运行正常,但不知道Flutter是什么问题 如果你没有其他选择,你应该使用原生实现;(以上是关于Flutter 中的流媒体广播的主要内容,如果未能解决你的问题,请参考以下文章
低延迟流媒体协议SRTWebRTCLL-HLSUDPTCPRTMP详解