Media3 UI 模組

播放媒體的應用程式需要使用者介面元件,才能顯示媒體及控制播放。Media3 程式庫包含三個 UI 模組,其中包含多個 UI 元件。

如要使用以檢視畫面為基礎的 UI 模組,請新增下列依附元件:

Kotlin

implementation("androidx.media3:media3-ui:1.11.1")

Groovy

implementation "androidx.media3:media3-ui:1.11.1"

如果是 Jetpack Compose,請在兩個 Compose UI 模組之間選擇 (您不需要同時新增這兩個模組,因為 media3-ui-compose-material3 依附於 media3-ui-compose)。請參閱「開始使用以 Compose 為基礎的 UI」,決定哪一個適合您的應用程式。

如要依附核心 Jetpack Compose UI 模組,請新增下列依附元件:

Kotlin

implementation("androidx.media3:media3-ui-compose:1.11.1")

Groovy

implementation "androidx.media3:media3-ui-compose:1.11.1"

如要依附採用 Material 3 的 Jetpack Compose UI 模組,請新增下列依附元件:

Kotlin

implementation("androidx.media3:media3-ui-compose-material3:1.11.1")

Groovy

implementation "androidx.media3:media3-ui-compose-material3:1.11.1"

強烈建議您以 Compose 優先的方式開發應用程式,或從使用 View 遷移,並避免在 Compose 的 AndroidView 中包裝 PlayerView。