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:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am very sorry.
You were right pointing out that the call
player.prepare(mediaSource, true, true)
needs to be replaced by:Then I messed again my pasted code because
player.prepare(false)
does not exist and it must be simplyplayer.prepare()
.Now the new code works fine.
Thanks.
Glad it works! Thanks for letting me know!