【问题标题】:Is there is any flutter plugin to play live streaming video (.m3u8) in android?是否有任何颤振插件可以在 android 中播放实时流媒体视频(.m3u8)?
【发布时间】:2019-10-20 14:55:06
【问题描述】:

我使用过video_player: ^0.10.1+2,它在 IOS 上运行良好,但在 Android 上却无法运行

_videoPlayerController1 = VideoPlayerController.network('url with .m3u8 file');
  

_chewieController = ChewieController(
    videoPlayerController: _videoPlayerController1,
    //aspectRatio: 3 / 2,
    //aspectRatio: _videoPlayerController1.value.aspectRatio,
    autoPlay: true,
    looping: true,
    routePageBuilder: (BuildContext context, Animation<double> animation,
        Animation<double> secondAnimation, provider) {
      return AnimatedBuilder(
        animation: animation,
        builder: (BuildContext context, Widget child) {
          return VideoScaffold(
            child: Scaffold(
              resizeToAvoidBottomPadding: false,
              body: Container(
                margin: EdgeInsets.only(bottom: 50),
                alignment: Alignment.center,
                color: Colors.black,
                child: provider,
              ),
            ),
          );
        },
      );
    },
    materialProgressColors: ChewieProgressColors(
       playedColor: Colors.red,
       handleColor: Colors.blue,
       backgroundColor: Colors.grey,
       bufferedColor: Colors.lightGreen,
     ),
     placeholder: Container(
       color: Colors.grey,
     ),
     autoInitialize: true,
    );
E/ExoPlayerImplInternal(13111): com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404
E/ExoPlayerImplInternal(13111):     at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:300)
E/ExoPlayerImplInternal(13111):     at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
E/ExoPlayerImplInternal(13111):     at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102)
E/ExoPlayerImplInternal(13111):     at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65)
E/ExoPlayerImplInternal(13111):     at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:156)
E/ExoPlayerImplInternal(13111):     at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
E/ExoPlayerImplInternal(13111):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(13111):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(13111):     at java.lang.Thread.run(Thread.java:764)

【问题讨论】:

  • 感谢@VidorVistrom,这是针对原生android的,但我需要flutter解决方案
  • 对于flutter,您可以执行以下任一操作,第一,创建一个webview并使用浏览器播放文件,第二,创建一个平台频道供您自己使用:)
  • @NikunjRami,我亲自检查了video_player 的颤振插件,它适用于 HLS .m3u8 文件。

标签: android flutter live-streaming


【解决方案1】:

Flutter 的video_player 插件在Android 上使用ExoPlayer,如docs 中所述。它应该支持 .m3u8 格式每次检查 ExoPlayer's GitHub issue tracker

如果您能够运行 Android 项目,我建议您尝试在他们的demo app 上播放您的 .m3u8 流链接,看看它是否有效。如果 .m3u8 链接在 ExoPlayer 演示应用程序上有效,则video_player 插件中可能存在问题。否则,我建议在ExoPlayer's GitHub issue page 上提交一张票,以检查您使用的媒体是否存在问题。还请包含一个可访问的 .m3u8 流链接,可对其进行测试以诊断问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2021-08-16
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多