HUAWEI Video Kit Sample
English | 中文
Table of Contents
Introduction
The sample code is used to implement the function of playing videos through the Video Kit player SDK.The following describes the structure of the sample code:
- activity: UI, which contains the video list and playback screen.
- adapter: Adapter of the video list screen.
- contract: Stores API classes.
- control: A class used to control UI data.
- entity: An entity class of the playback data.
- utils: A tool class.
- view: A layout view displayed on the UI.
Installation
Decompress the sample code package "videokit-player-sample-x.x.x.xxx.zip".
Take the Android Studio 3.x version as an example. The steps to run the Video Kit player SDK sample code are as follows:
- You should modify the applicationId in the build.gradle.
- You should create an app in AppGallery Connect, and obtain the file of agconnect-services.json and add to the project.
- You should also generate a signing certificate fingerprint and add the certificate file to the project, and add configuration to build.gradle.
See the Preparations for Integrating HUAWEI HMS Core guide to configure app in AppGallery Connect.
- In Android Studio, select "File > Open". In the pop-up dialog box, enter the path where the sample code is stored locally, for example: "D:\videokit-player-sample-x.x.x.xxx\VideoKitDemo\src";
- Select the src project to be opened, and then click "OK". In the pop-up dialog box, select "New Window" to open the project in a new window.
- In Android Studio, replace the URL in the video_kit_demo.txt file with the URL of the video to be played.
- In Android Studio, click "Run", then select your device as the target and click "OK" to launch the sample application on your device.
Configuration
The video_kit_demo.txt file has been placed in the assets directory. Data structure in video_kit_demo.txt:
- id: Unique ID of the video.
- urlType: Type of the video. Two options are available: 0 (single video URL) and 1 (multiple video URLs). Use "-SPAD-" to combine multiple video URLs.
- url: URL of the video.
- name: Name of the video.
Supported Environments
It is recommended that the EMUI version be 3.0 or later and the JDK version be 1.8 or later.
To play a video using the sample code, ensure that HMS Core (APK) 5.0.0.300 or a later version has been installed on your phone.
Sample Code
The sample code provides the following scenarios:
- Play a video.
- Switch to the specified bitrate.
- Enable or disable the repeat mode.
- Set the playback mode (audio or audio+video).
- Mute or unmute.
- Adjust the playback speed.
Result
Question or issues
If you want to evaluate more about HMS Core,
r/HMSCore on Reddit is for you to keep up with latest news about HMS Core, and to exchange insights with other developers.
If you have questions about how to use HMS samples, try the following options:
-
Stack Overflow is the best place for any programming questions. Be sure to tag your question with
huawei-mobile-services
.
-
Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
If you run into a bug in our samples, please submit an issue to the Repository. Even better you can submit a Pull Request with a fix.
License
HUAWEI Video Kit Sample is licensed under the Apache License, version 2.0.
Repository Comments ( 0 )