我目前正在从我的Android应用程序中的ExoPlayer(com.google.android.exoplayer2版本2.19.1)迁移到Media3(1.1.1).中提供的迁移说明 official Android documentation.
我已经进行了必要的代码和依赖项更改,但在扩展我的XML布局中的androidx.media3.ui.PlayerView时遇到错误.具体地说,我收到以下错误:
android.view.InflateException: Binary XML file line #16 in
com.xxx.xx:layout/mpeg_player: Binary XML file line #16 in
com.xxxx.xx:layout/mpeg_player: Error inflating class
androidx.media3.ui.PlayerView
并进一步
Caused by: android.view.InflateException: Binary XML
file line #78 in com.xxx.xx:layout/exo_player_control_view:
Binary XML file line #78 in com.xxx.xx:layout/exo_player_control_view:
Error inflating class com.google.android.exoplayer2.ui.DefaultTimeBar
Caused by: android.view.InflateException: Binary XML file line #78 in com.xxx.xxx:layout/exo_player_control_view: Error inflating class com.google.android.exoplayer2.ui.DefaultTimeBar
Caused by: java.lang.ClassNotFoundException: com.google.android.exoplayer2.ui.DefaultTimeBar
以下是我的XML
<androidx.media3.ui.PlayerView
android:id="@+id/video_view"
app:show_buffering="always"
app:show_subtitle_button="true"
android:focusable="false"
app:use_controller="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
并添加了所有依赖项
implementation 'androidx.media3:media3-exoplayer:1.1.1'
implementation 'androidx.media3:media3-exoplayer-dash:1.1.1'
implementation 'androidx.media3:media3-ui:1.1.1'
implementation "androidx.media3:media3-session:1.1.1"
我还把这个加到了我的build.gradle上
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
如果有任何关于如何解决此问题并成功迁移到Media3的指导或建议,我将不胜感激.谢谢!