question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After upgrading from 2.11.8 to 2.12.1 and replacing deprecated components I can't play any video.

See original GitHub issue

[REQUIRED] Searched documentation and issues

Release Notes for version 2.12.1 and 2.12.0.

[REQUIRED] Question

I’ve recently upgraded com.google.android.exoplayer:exoplayer-core from version 2.11.8 to version 2.12.1.
Some components are deprecated by version 2.12.1 in the following code snippet.

        cacheEvictor = LeastRecentlyUsedCacheEvictor(CACHE_SIZE_MAX)
        databaseProvider = ExoDatabaseProvider(context)
        cache = SimpleCache(File(context.cacheDir, CACHE_DIR),
                cacheEvictor, databaseProvider)
        upstreamFactory = DefaultDataSourceFactory(context, USER_AGENT)
        // CacheDataSourceFactory class is deprecated
        cacheFactory = CacheDataSourceFactory(cache, upstreamFactory,
                CacheDataSource.FLAG_BLOCK_ON_CACHE or
                        CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
        mediaSourceFactory = ProgressiveMediaSource.Factory(cacheFactory)
        [...]
        val url: Uri
        val player: SimpleExoPlayer
        [...]
        // createMediaSource method is deprecated
        val mediaSource = mediaSourceFactory.createMediaSource(uri)
        // prepare method is deprecated
        player.prepare(mediaSource, true, true)

Thus I replaced the deprecated components by the newest ones.

        cacheEvictor = LeastRecentlyUsedCacheEvictor(CACHE_SIZE_MAX)
        databaseProvider = ExoDatabaseProvider(context)
        cache = SimpleCache(File(context.cacheDir, CACHE_DIR),
                cacheEvictor, databaseProvider)
        upstreamFactory = DefaultDataSourceFactory(context, USER_AGENT)
        cacheFactory = CacheDataSource.Factory().apply {
              setCache(this@VideoPlayer.cache)
              setUpstreamDataSourceFactory(upstreamFactory)
              setFlags(CacheDataSource.FLAG_BLOCK_ON_CACHE or                  
                    CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
        }
        mediaSourceFactory = ProgressiveMediaSource.Factory(cacheFactory)
        [...]
        val url: Uri
        val player: SimpleExoPlayer
        [...]
        val mediaItem =  MediaItem.fromUri(uri)
        val mediaSource = mediaSourceFactory.createMediaSource(mediaItem)
        player.setMediaSource(mediaSource, true)
        player.prepare(mediaSource, true)

After the updates, the player was black and I could not play any video (nothing usefull in Logcat). I’ve returned to the deprecated components (still with version 2.12.1) and now I can play every video.

I think I messed up something when in replacing the deprecated components.
Can you help me, please?

A full bug report captured from the device

(EMPTY)

Link to test content

(EMPTY)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dscoppelletticommented, Nov 4, 2020

I am very sorry.
You were right pointing out that the call player.prepare(mediaSource, true, true) needs to be replaced by:

player.setMediaSource(source, true);
player.prepare();

Then I messed again my pasted code because player.prepare(false) does not exist and it must be simply player.prepare().

Now the new code works fine.

Thanks.

0reactions
marcbaechingercommented, Nov 4, 2020

Glad it works! Thanks for letting me know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

After upgrading ExoPlayer from 2.11.8 to 2.12.1 and replacing ...
1) and now I can play every video. I think I messed up something when in replacing the deprecated components. Can anyone help...
Read more >
After upgrading ExoPlayer from 2.11.8 to 2.12.1 and replacing ...
Coding example for the question After upgrading ExoPlayer from 2.11.8 to 2.12.1 and replacing deprecated components I can't play any video-kotlin.
Read more >
ExoPlayer/RELEASENOTES.md at release-v2 - GitHub
These methods are all overrides and are already deprecated on Player and the respective ExoPlayer component classes (since 2.14.0). Video:.
Read more >
Windows 10 Anniversary Update: Loss of music and video
When installing the Windows 10 Anniversary Update some people will get this message: Loss of music and video content with update.
Read more >
Package List — Spack 0.20.0.dev0 documentation
libFLAME is a C-only implementation and does not depend on any external FORTRAN ... A package universe and a request to install, remove,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found