Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding m3u8 to ConcatenatingMediaSource stopped playback #4661

Closed
sneltyn opened this issue Aug 14, 2018 · 5 comments
Closed

Adding m3u8 to ConcatenatingMediaSource stopped playback #4661

sneltyn opened this issue Aug 14, 2018 · 5 comments
Assignees
Labels

Comments

@sneltyn
Copy link

sneltyn commented Aug 14, 2018

I use ConcatenatingMediaSource to play the video. After the first media mp4 is added, the second carrier m3u8 is added, and the Internet is disabled. I get the exception :

HttpDataSourceException: It is impossible to connect to ...

And the player stops the current playback of mp4.

How to ignore m3u8 in case it fails to load it?

@tonihei
Copy link
Collaborator

tonihei commented Aug 20, 2018

Can you please provide example media files to reproduce the issue? Also, please try to capture a bugreport (or copy the logcat) after the issue occurred. Thanks!

@sneltyn
Copy link
Author

sneltyn commented Aug 20, 2018

@tonihei, thanks for the response! Yes of course, here are the test media(mp4 is loaded in the device storage):

http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4
https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8

In fact, it does not matter what files, you can take any mp4 and m3u8.

Logcat output

08-21 00:33:00.373 19934-20001/com.sneltyn.demo E/ExoPlayerImplInternal: Source error.
08-21 00:33:00.404 19934-20069/com.sneltyn.demo D/SurfaceUtils: disconnecting from surface 0x7c2a7a2010, reason disconnectFromSurface
08-21 00:33:00.436 19934-19934/com.sneltyn.demo W/System.err: com.google.android.exoplayer2.ExoPlaybackException
08-21 00:33:00.437 19934-19934/com.sneltyn.demo W/System.err:     at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:349)
        at android.os.Handler.dispatchMessage(Handler.java:101)
        at android.os.Looper.loop(Looper.java:164)
        at android.os.HandlerThread.run(HandlerThread.java:65)
08-21 00:33:00.438 19934-19934/com.sneltyn.demo W/System.err: Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:147)
08-21 00:33:00.439 19934-19934/com.sneltyn.demo W/System.err:     at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102)
        at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65)
        at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:137)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:320)
08-21 00:33:00.440 19934-19934/com.sneltyn.demo W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
08-21 00:33:00.441 19934-19934/com.sneltyn.demo W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
08-21 00:33:00.442 19934-19934/com.sneltyn.demo W/System.err: Caused by: java.net.UnknownHostException: Unable to resolve host "video-dev.github.io": No address associated with hostname
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:141)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:90)
        at java.net.InetAddress.getAllByName(InetAddress.java:787)
08-21 00:33:00.443 19934-19934/com.sneltyn.demo W/System.err:     at com.android.okhttp.Dns$1.lookup(Dns.java:39)
        at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175)
        at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141)
        at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83)
08-21 00:33:00.444 19934-19934/com.sneltyn.demo W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
08-21 00:33:00.445 19934-19934/com.sneltyn.demo W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(Unknown Source:0)
08-21 00:33:00.446 19934-19934/com.sneltyn.demo W/System.err:     at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:429)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:350)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:192)
        ... 8 more
08-21 00:33:00.447 19934-19934/com.sneltyn.demo W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
        at libcore.io.Linux.android_getaddrinfo(Native Method)
        at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:58)
08-21 00:33:00.448 19934-19934/com.sneltyn.demo W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:122)
        ... 26 more

Code

    ...
    private ConcatenatingMediaSource mConcatVideos;

    public void preloadHLS(String path, int duration) {
        try {
             MediaSource source = buildMediaSource(Uri.parse(path));
             if (mConcatVideos.getSize() == 0)
                mConcatVideos = new ConcatenatingMediaSource();
             mConcatVideos.addMediaSource(new ClippingMediaSource(source, 0,
                    TimeUnit.SECONDS.toMicros(duration)));
        } catch (Exception ignore) {
            println(ERROR, MediaView.class, "Problem preload stream: %s", path);
        }
    }

    public void playMp4(String path) {
        try {
            if (mConcatVideos.getSize() == 0)
                mConcatVideos = new ConcatenatingMediaSource();
            MediaSource source = buildMediaSource(Uri.parse(path));
            mConcatVideos.addMediaSource(source);
            mPlayer.setPlayWhenReady(true);
            mPlayer.prepare(mConcatVideos);
        } catch (Exception ignored) {
            println(ERROR, MediaView.class, "Problem play video: %s", path);
        }
    }

    private MediaSource buildMediaSource(
            Uri uri) {
        int type = Util.inferContentType(uri);
        switch (type) {
            case C.TYPE_DASH:
                return new DashMediaSource.Factory(
                        new DefaultDashChunkSource.Factory(mMediaDataSourceFactory),
                        buildDataSourceFactory())
                        .createMediaSource(uri);
            case C.TYPE_SS:
                return new SsMediaSource.Factory(
                        new DefaultSsChunkSource.Factory(mMediaDataSourceFactory),
                        buildDataSourceFactory())
                        .createMediaSource(uri);
            case C.TYPE_HLS:
                return new HlsMediaSource.Factory(mMediaDataSourceFactory)
                        .createMediaSource(uri);
            case C.TYPE_OTHER:
                return new ExtractorMediaSource.Factory(mMediaDataSourceFactory)
                        .createMediaSource(uri);
            default: {
                throw new IllegalStateException("Unsupported type: " + type);
            }
        }
    }
    ...

I call the playMp4() method and after 2 seconds preloadHLS() method. At the same time, the INTERNET is disabled.

ExoPlayer: 2.8.3

If anything, I can provide a demo app this problem.

@tonihei
Copy link
Collaborator

tonihei commented Aug 21, 2018

Unfortunately, I can't reproduce your problem.
I added a local MP4 file and while this file was playing, I disabled the internet connection and then added a HLS file to the ConcatenatingMediaSource. As a result, the MP4 played to its end and only then I got the Exception for the failed load. Did I miss any important steps?

@sneltyn
Copy link
Author

sneltyn commented Sep 1, 2018

@tonihei, I continue to receive this problem, so I created demo app https://github.com/sneltyn/ExoPreload. Sorry for my long answer.

@tonihei
Copy link
Collaborator

tonihei commented Sep 6, 2018

Thanks for the example project! I can now reproduce the problem. I'll take a look and we'll provide a fix in the next release.

@tonihei tonihei added bug and removed need more info labels Sep 6, 2018
ojw28 pushed a commit that referenced this issue Sep 12, 2018
… issues

1. Currently, we may throw source info refresh errors while the previous media
   period is still playing.
2. We don't throw if the next period in a playlist fails to prepare and the
   previous renderers are all disabled.
3. We throw source info refresh errors for playlists before playback reaches
   the culprit source.

This change:
1. Defers the exceptions until all existing media periods have been played.
2. Checks for period preparation exception if the next period is not
   getting prepared and the renderer time reached the next period.
3. Does no longer throw from ConcatenatingMediaSource.maybeThrowSourceInfo
   RefreshError. The deferred media periods take care of that for each source
   individually.

Issue:#4661

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=211819436
@ojw28 ojw28 closed this as completed Sep 12, 2018
@google google locked and limited conversation to collaborators Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants