Exoplayer cannot catch error - Input does not start with the #EXTM3U header
Asked Answered
A

2

7

Like the title above, I can't catch the error Input does not start with the #EXTM3U header.

I tried to catch the error in this way:

exoPlayer.addListener(new ExoPlayer.EventListener() {
            @Override
            public void onPlayerError(ExoPlaybackException error) {
                Toast.makeText(Act_Details.this, "SOURCE ERROR1", Toast.LENGTH_SHORT).show(); //Didn't work or didn't get here 
                Log.e("EXO-ERROR", error.getCause().getMessage()); //Didn't work or didn't get here
                switch (error.type) {
                    case ExoPlaybackException.TYPE_SOURCE:
                        Toast.makeText(Act_Details.this, "SOURCE ERROR1", Toast.LENGTH_SHORT).show(); //Didn't work or didn't get here
                        Log.e("EXO-ERROR-SOURCE", error.getCause().getMessage()); //Didn't work or didn't get here
                        ...
                        ...

And trying like this to :

try {
    PlayerMode = "HLS Mode";
    HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
    exoPlayer = new SimpleExoPlayer.Builder(context).setTrackSelector(trackSelector).build();
    exoPlayer.prepare(hlsMediaSource);
} catch (Exception e) {
    Log.d("Set_Media_Player", e.getMessage()); //Didn't work or didn't get here
    return null;
}

Error :

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:199)
        at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistParser.parse(HlsPlaylistParser.java:62)
        at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:172)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
        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:919)

The url that I am trying to play is of type .m3u8 and the results are as above, then I try to use Progressive mode and it works.

how can I catch the error, so I can try with the next mode?

Armorial answered 1/4, 2020 at 19:54 Comment(0)
W
0

You need to use .addAnalyticsListener(...) instead of .addListener.

Wellmeaning answered 30/3, 2021 at 14:25 Comment(0)
B
0

In my case, I got this error - when I tried to pass a url to exoplayer with a time span in the future. Be careful.

Bevus answered 22/2, 2023 at 8:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.