【问题标题】:Not able to play live video through ExoPlayer无法通过 ExoPlayer 播放实时视频
【发布时间】:2018-05-15 11:30:27
【问题描述】:

我正在使用 ExoPlayer 在 Android 中播放视频。我们正在使用 ExoPlayer 播放 mp4 和现场视频。但有时我们会遇到下面描述的异常。

> 12-01 14:15:09.388 12080-12517/com.mse.monumentalsnetwork
> E/ExoPlayerImplInternal: Source error.
>                                                                                    com.google.android.exoplayer2.source.UnrecognizedInputFormatException:
> Input does not start with the #EXTM3U header.
>                                                                                        at
> com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistParser.parse(HlsPlaylistParser.java:119)
>                                                                                        at
> com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistParser.parse(HlsPlaylistParser.java:43)
>                                                                                        at
> com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:115)
>                                                                                        at
> com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315)
>                                                                                        at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
>                                                                                        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
>                                                                                        at java.lang.Thread.run(Thread.java:818)

所以请帮帮我。

【问题讨论】:

  • 看起来在解析 .m3u 播放列表文件时出错(假设您使用的是 m3u 格式)。这只发生在直播中吗?
  • 发布您正在使用的播放列表
  • @pskink 播放列表是指我正在播放的网址?
  • 我的意思是extended m3u 播放列表
  • @NibinSalim 是的,问题出在 HLS 网址上。 Exoplayer 无法解析该网址。所以检查你的网址。

标签: android exoplayer


【解决方案1】:

检查您的网址。可能是您的 URL 包含一个空格,您可以像这样替换它:

String StringName= "Your URL".replaceAll(" ","%20");

【讨论】:

    【解决方案2】:

    该错误表明您在播放 MP4 文件时正在使用 HlsMediaSource。它无法解析 HLS 清单。

    您需要使用 ExtractorMediaSource 来播放 MP4:

    DefaultHttpDataSourceFactory dataSource = new DefaultHttpDataSourceFactory(
        Util.getUserAgent(this, "your-user-agent"));
    ExtractorMediaSource mediaSource = new ExtractorMediaSource.Factory(dataSource)
        .createMediaSource(uri, null, null);
    player.setPlayWhenReady(true);
    player.prepare(mediaSource);
    

    ExoPlayer 的演示应用程序有一个createMediaSource 方法,该方法演示了可用媒体源的创建。

    【讨论】:

    • 我 100% 确定。我们正在使用 m3u8 文件进行播放。
    • @Ramkailash,您找到问题的解决方案了吗?
    猜你喜欢
    • 2017-01-01
    • 2016-05-17
    • 1970-01-01
    • 2020-11-15
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    • 2016-05-18
    相关资源
    最近更新 更多