Exoplayer: HLS: Live TV Fails to Play [com.google.android.exoplayer2.ParserException: Cannot find sync byte. Most likely not a Transport Stream.]

Created on 9 Sep 2020  路  6Comments  路  Source: google/ExoPlayer

Playlist URL [https://t1.tvmak.com/tv/TVSHENJA.m3u8?aBtVmfe1F7]

You can see that HLS.js library is playing this playlist very well on
"https://tvmak.com/tvshenja"
while ExoPlayer, throws exception.

Is there any other way to load this kind of Playlist or ... ?

    fun createMediaSource(
        context: Context,
        uri: Uri,
        headers: Map<String, String>? = null
    ): MediaSource {
        val dataSource = buildDataSourceFactory(context, headers)
        val factory = buildMediaSourceFactory(dataSource, uri)
        return factory.createMediaSource(uri)
    }

    private fun buildDataSourceFactory(
        context: Context,
        headers: Map<String, String>?,
    ): () -> DefaultDataSource {
        return {
            val defaultHttpDataSource = DefaultHttpDataSource(USER_AGENT)
            headers?.let {
                for (h in it)
                    defaultHttpDataSource.setRequestProperty(h.key, h.value)
            }
            DefaultDataSource(context, defaultHttpDataSource)
        }
    }

    private fun buildMediaSourceFactory(
        factory: DataSource.Factory,
        uri: Uri
    ): MediaSourceFactory {
        return when (val type = Util.inferContentType(uri)) {
            C.TYPE_SS -> SsMediaSource.Factory(factory)
            C.TYPE_DASH -> DashMediaSource.Factory(factory)
            C.TYPE_HLS -> HlsMediaSource.Factory(factory)
            C.TYPE_OTHER -> ProgressiveMediaSource.Factory(factory)
            else -> throw IllegalStateException("Unsupported type: $type");
        }
    }
bug

All 6 comments

I get an error ERR_CONNECTION_REFUSED when trying to open the link. Could you please fix this or send the HLS manifest directly? If you're unable to share the test content publicly, please send it to dev.[email protected] using subject "Issue #7876". Please also update this issue to indicate you鈥檝e done this.

Something you can do to see if the error comes from your code is to try to play the file using our demo app. If it plays with the demo app, this probably means that there is an error in the way you configured the player.

I get an error ERR_CONNECTION_REFUSED when trying to open the link. Could you please fix this or send the HLS manifest directly? If you're unable to share the test content publicly, please send it to dev.[email protected] using subject "Issue #7876". Please also update this issue to indicate you鈥檝e done this.

Something you can do to see if the error comes from your code is to try to play the file using our demo app. If it plays with the demo app, this probably means that there is an error in the way you configured the player.

Here you have the file
https://gofile.io/d/0e6ZVC

This file gets updated on every download request, which contains different segments.

Sorry but I get the same error with the new file. Can you send an example stream directly by email as indicated in my previous comment?

This is how the m3u8 file looks like
`#EXTM3U

EXT-X-VERSION:3

EXT-X-TARGETDURATION:10

EXT-X-MEDIA-SEQUENCE:0

EXT-X-PLAYLIST-TYPE:VOD

EXTINF:10.000000,

inc/tvmak0.ts

EXTINF:5.080000,

inc/tvmak47.ts

EXT-X-ENDLIST

`

The request to "ts" file which HLS.js library is sending
https://t3.tvmak.com/tv/TVART47.ts

As far as I can see, the Segment url does not point to a valid source [404 Not Found]

Is there any way to modify requests on the fly inside using Exo Player?
As well, the HLS.js libarary sends multiple requests to SERVER to the same ".m3u8" playlists to retrieve new segmets to play, does EXO player support this?

Is there any way to modify requests on the fly inside using Exo Player?

Do you mean to redirect the requests to another URL? I don't think so, no. You need to make sure that the HLS manifest is correct before passing it to ExoPlayer.

As well, the HLS.js libarary sends multiple requests to SERVER to the same ".m3u8" playlists to retrieve new segmets to play, does EXO player support this?

Yes. This is what ExoPlayer does for live content for example.

I am afraid I cannot help much if I don't have access to the test content. Have you tried to play it using our demo app? Can you send the logs that you get when the exception is thrown?

Is there any way to modify requests on the fly inside using Exo Player?

Do you mean to redirect the requests to another URL? I don't think so, no. You need to make sure that the HLS manifest is correct before passing it to ExoPlayer.

As well, the HLS.js libarary sends multiple requests to SERVER to the same ".m3u8" playlists to retrieve new segmets to play, does EXO player support this?

Yes. This is what ExoPlayer does for live content for example.

I am afraid I cannot help much if I don't have access to the test content. Have you tried to play it using our demo app? Can you send the logs that you get when the exception is thrown?

Hi Kim-Vde.
Thanks for your reply.

Unfortunately the client has build the website and he wants me only to extract the html, find the .m3u8 source and play it on Android.

As I mentioned on my last comment, the ".m3u8" playlists points to some paths like "inc/tvmak47.ts, inc/tvmak48.ts, inc/tvmak{n...}.ts" but the correct url to that segment is "tv/tvmak{n..}.ts" instead of "inc/"

Is there any other way to override the default behaviour of HLSMediaSource So I can modify the manifest on runtime?

[Edit]
I found the way to retrieve the correct manifest, this issue is now solved.
Thanks to all for their time and assistance.

B.r

Was this page helpful?
0 / 5 - 0 ratings