### Clone VEVodDemo-Android Repository Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/README.md This command clones the VEVodDemo-android project from GitHub. This is the initial step to obtain the PlayerKit modules and other related files for integration. ```shell git clone https://github.com/volcengine/VEVodDemo-android cd VEVodDemo-android ``` -------------------------------- ### Configure Project Repositories in build.gradle Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/README.md This Groovy script configures the repositories for the project's build.gradle file. It ensures that the Google, MavenCentral, and Volcengine Maven repositories are included, which are necessary for resolving dependencies, including PlayerKit. ```groovy allprojects { repositories { google() mavenCentral() maven { url "https://artifact.bytedance.com/repository/Volcengine/" // 火山引擎 maven 服务 } } } ``` -------------------------------- ### Include PlayerKit Module in settings.gradle Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/README.md This Groovy snippet demonstrates how to include the PlayerKit module into the project by applying a Gradle settings file. This makes the PlayerKit library available for use within the Android application. ```groovy include ':app' apply from: file("gradle-config/vod_playerkit_library_settings.gradle") ``` -------------------------------- ### Include SceneKit Modules in settings.gradle Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-scenekit/README.md This Groovy snippet demonstrates how to include the SceneKit modules in the `settings.gradle` file. It applies the necessary Gradle configuration files for `vod_playerkit` and `vod_scenekit`. ```groovy include ':app' apply from: file("gradle-config/vod_playerkit_library_settings.gradle") apply from: file("gradle-config/vod_scenekit_library_settings.gradle") ``` -------------------------------- ### Set Business Type and Custom Tags in Java Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/PlayerKitFeatures.md This Java code snippet shows how to set business types and custom tags for a media source before starting playback. It involves creating a VolcConfig object, assigning values to its 'tag' and 'subtag' properties, and then applying this configuration to the media source using VolcConfig.set(). ```java VolcConfig volcConfig = new VolcConfig(); volcConfig.tag = "your tag"; volcConfig.subtag = "your subtag"; VolcConfig.set(meddiaSource, volcConfig); ``` -------------------------------- ### Add PlayerKit Dependencies in App's build.gradle Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/README.md This code snippet shows how to declare the PlayerKit dependencies in the app module's build.gradle file. It includes enabling Java 8 support and adding the vod-player, vod-player-utils, and vod-player-volcengine modules as API dependencies. ```groovy // 在 app 的 build.gradle 文件添加 Java 8 支持 android { // ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { api project(":vod-playerkit:vod-player") api project(":vod-playerkit:vod-player-utils") api project(":vod-playerkit:vod-player-volcengine") } ``` -------------------------------- ### Add SceneKit Dependency in App's build.gradle Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-scenekit/README.md This Gradle code snippet shows how to add the SceneKit dependency to the app module's `build.gradle` file. It also includes enabling Java 8 compatibility, which might be required by the SceneKit modules. ```groovy // 在 app 的 build.gradle 文件添加 Java 8 支持 android { // ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { api project(":vod-scenekit") } ``` -------------------------------- ### 初始化 SDK 示例 (Kotlin) Source: https://github.com/volcengine/vevoddemo-android/blob/main/app-player-api-example/README.md 展示火山引擎播放器 SDK 的初始化流程。需要配置 AppId 和 License URI。 ```kotlin class App : Application() { companion object { const val APP_ID: String = "your app id" // 替换为您申请的 AppId const val LICENSE_URI: String = "your license assets uri" // 替换为您购买的 License 地址 } } ``` -------------------------------- ### Handle Clarity Event Callbacks in Java Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/PlayerKitFeatures.md This Java code snippet demonstrates how to add a playback listener to receive and process various track information events, such as track info readiness, track changes, and track will change. It uses the Dispatcher.EventListener interface and specific PlayerEvent codes to handle different scenarios related to video track clarity. ```java playbackController.addPlaybackListener(new Dispatcher.EventListener() { @Override public void onEvent(Event event) { switch (event.code()) { case PlayerEvent.Info.TRACK_INFO_READY: { InfoTrackInfoReady e = event.cast(InfoTrackInfoReady.class); @Track.TrackType int trackType = e.trackType; // track 类型 List tracks = e.tracks; // track 列表 break; } case PlayerEvent.Info.TRACK_WILL_CHANGE: { InfoTrackWillChange e = event.cast(InfoTrackWillChange.class); @Track.TrackType int trackType = e.trackType; // track 类型 Track current = e.current; // 当前播放清晰度 Track target = e.target; // 目标切换清晰度 break; } case PlayerEvent.Info.TRACK_CHANGED: { InfoTrackChanged e = event.cast(InfoTrackChanged.class); int trackType = e.trackType; // track 类型 Track current = e.current; // 当前播放清晰度 Track pre = e.pre; // 切换前的清晰度 break; } } } }); ``` -------------------------------- ### Listen to Playback Events with EventListener Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/PlayerKitFeatures.md Demonstrates how to set up an EventListener to monitor playback states and actions for the PlaybackController and Player. It covers common event codes for player actions, states, and info. The listener can be added and removed using playbackController.addPlaybackListener() and playbackController.removePlaybackListener(). ```java final EventListener eventListener = new EventListener() { @Override public void onEvent(Event event) { final int code = event.code; // Event 类型码 // 下面列举常见 Event 码,更多请参考 PlayerEvent 类和 PlaybackEvent 类 switch(code) { case PlaybackEvent.Action.START_PLAYBACK: // 调用 PlaybackController.startPlayback() 后触发 break; case PlaybackEvent.ACTION.STOP_PLAYBACK: // 调用 PlaybackController.stopPlayback() 后触发 break; case PlayerEvent.Action.PREPARE: // 调用 AVPlayer.prepare 后触发 break; case PlayerEvent.State.PREPARED: // 播放器准备完成回调 break; case PlayerEvent.Info.VIDEO_RENDERING_START: // 播放器首帧渲染回调 break; } } }; // 设置监听 playbackController.addPlaybackListener(eventListener); // 移除监听 playbackController.removePlaybackListener(eventListener); ``` -------------------------------- ### Handle onBackPressed Event in VideoLayer Source: https://github.com/volcengine/vevoddemo-android/blob/main/vod-playerkit/PlayerKitFeatures.md Illustrates how to integrate VideoLayer's onBackPressed handling within an Activity. This allows VideoLayers, such as DialogLayer, to intercept and manage back press events, providing a fallback mechanism for nested UI elements. ```java public class MainActivity extends AppCompatActivity { private VideoView mVideoView; @Override public void onBackPressed() { // VideoLayer 层拦截 Activity 的返回事件,用于处理 VideoLayer 内部的返回逻辑 if (mVideoView.layerHost().onBackPressed()) { return; } super.onBackPressed(); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.