ExoPlayer 迁移到 Media3 日志

参考网站

中文:https://developer.android.google.cn/media/media3/exoplayer/mappings?authuser=3&hl=zh-cn
英文:https://developer.android.google.cn/media/media3/exoplayer/migration-guide?hl=en&authuser=0

主体 替换

ExoPlayerMedia3
com.google.android.exoplayer2androidx.media3.exoplayer
com.google.android.exoplayer2.upstream.DataSourceandroidx.media3.datasource.DataSource
com.google.android.exoplayer2.source.hls.HlsMediaSourceandroidx.media3.exoplayer.hls.HlsMediaSource
com.google.android.exoplayer2.Timelineandroidx.media3.common.Timeline
com.google.android.exoplayer2.Playerandroidx.media3.common.Player
com.google.android.exoplayer2.PlaybackParametersandroidx.media3.common.PlaybackParameters
com.google.android.exoplayer2.upstream.DefaultDataSourceFactoryandroidx.media3.datasource.DefaultDataSourceFactory
com.google.android.exoplayer2.util.Utilandroidx.media3.common.util.Util
com.google.android.exoplayer2.Candroidx.media3.common.C
com.google.android.exoplayer2.SimpleExoPlayerandroidx.media3.exoplayer.ExoPlayer
com.google.android.exoplayer2.video.VideoListenersimpleExoPlayer.addVideoListener替换为Player.Listener;SimpleExoPlayer替换为ExoPlayer

gradle修改

1)主体库
implementation ‘com.google.android.exoplayer:exoplayer:2.12.1’
替换为(以1.3.1为例)
implementation ‘androidx.media3:media3-exoplayer:1.3.1’
implementation ‘androidx.media3:media3-exoplayer-dash:1.3.1’
implementation ‘androidx.media3:media3-ui:1.3.1’
2)如果有hls类库,需要添加下面的
implementation ‘androidx.media3:media3-exoplayer-hls:1.3.1’

类修改

SimpleExoPlayer已淘汰,替换为ExoPlayer
TrackSelection.Factory替换为ExoTrackSelection.Factory
new DefaultLoadControl.Builder().createDefaultLoadControl();替换为new DefaultLoadControl.Builder().build();
new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri)替换为new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(uri)

Player.EventListener, VideoListener 替换为Player.Listener

重载函数替换

onPlaybackStateChanged(boolean,int) 替换为 onPlayWhenReadyChanged(boolean, int) instead
onPlayerError(ExoPlaybackException error)替换为onPlayerError(PlaybackException error)
onSeekProcessed()替换为onSeekBackIncrementChanged(long seekBackIncrementMs)和onSeekForwardIncrementChanged(long seekForwardIncrementMs)
onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio)替换为onVideoSizeChanged(VideoSize videoSize)
onTimelineChanged(final Timeline timeline, Object manifest, final int reason)替换为onTimelineChanged(Timeline timeline, int reason)
onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections)替换为onTracksChanged(Tracks tracks)

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值