[Open Source] A lightweight, feature-rich video player supporting IJK/Exo/MediaPlayer decoder switching
Open SourceVideo and Live Streaming
![[Open Source] A lightweight, feature-rich video player supporting IJK/Exo/MediaPlayer decoder switching](https://yy123.ink/api/img/1782609473798-bigpoc.jpg)
1. Project Overview
A lightweight media player that supports switching between IJKPlayer, ExoPlayer, MediaPlayer, and other decoders. Features include mute, mirroring, rendering modes, playback speed adjustment, and more. Supports custom decoders, controllers, UI interaction components, floating window playback, and other capabilities.
2. Open Source License
Licensed under Apache-2.0
3. Screenshots
SDK and Demo Feature Preview



4. Feature Overview
SDK Core Features:
- Supports playback from network URLs, live streams, local Assets, and Raw resource files
- Supports playback speed, scaling modes, mute, mirroring, and other playback settings
- Supports custom video decoders, controllers, UI interaction components, and video renderers
- Supports simultaneous playback with multiple players
- The SDK's default controller (with customizable partial UI interactions) supports gesture controls, paid preview, and other interactive features
- Supports launching Activity-level floating window playback from any location
- Supports launching global floating window playback from any location
- Supports launching full-screen playback directly from any location
- Supports continuous playback of video playlists
- Demo: Seamless transition playback between lists or components
- Demo: Transition from global floating window playback to an Activity
- Demo: Switching between three decoders: MediaPlayer, IjkPlayer, and ExoPlayer
- Demo: TikTok-style player with video caching and instant playback
- Demo: Danmaku interaction
- Demo: Android 8.0+ Picture-in-Picture example
5. Tech Stack
Player Framework Architecture Diagram
- As shown in the diagram, the architecture provides a clear overview of the user-facing modules and interactions, all of which support customization, including the video decoders.
SDK Integration
- Before integration, it is recommended to download and try the APK to identify the feature modules you want to implement. You can then refer to the Demo source code for integration.
1. Configure the project's root build.gradle and module-level build.gradle
//1. Add the following to your root build.gradle:
allprojects {
repositories {
maven { url '[https://jitpack.io](https://jitpack.io)' }
}
}
//2. Add the following to your module build.gradle:
dependencies {
//Player
implementation 'com.github.hty527.iPlayer:iplayer:2.0.4.1'
//IJK audio/video decoder, use as needed
//implementation 'com.github.hty527.iPlayer:ijk:2.0.4.1'
//Exo audio/video decoder, use as needed
//implementation 'com.github.hty527.iPlayer:exo:2.0.4.1'
//Audio/video pre-caching + playback while downloading, use as needed
//implementation 'com.github.hty527.iPlayer:cache:2.0.4.1'
}
2. Add the following code to the XML layout where you want to play videos, or create a new VideoPlayer() instance at the appropriate location.
<com.android.iplayer.widget.VideoPlayer
android:id="@+id/video_player"
android:layout_width="match_parent"
android:layout_height="200dp"/>
3. Initialize the player and start playback
mVideoPlayer = (VideoPlayer) findViewById(R.id.video_player);
mVideoPlayer.getLayoutParams().height= getResources().getDisplayMetrics().widthPixels * 9 /16;//Set a fixed player height, or set the height to: match_parent
//Use the built-in SDK controller and UI interaction components
VideoController controller = mVideoPlayer.initController();
//Set the video title (visible only in landscape mode)
controller.setTitle("Test URL Playback");
//Set the playback source
mVideoPlayer.setDataSource("[https://upload.dongfeng-nissan.com.cn/nissan/video/202204/4cfde6f0-bf80-11ec-95c3-214c38efbbc8.mp4\](https://upload.dongfeng-nissan.com.cn/nissan/video/202204/4cfde6f0-bf80-11ec-95c3-214c38efbbc8.mp4\)");
//Asynchronously prepare for playback
mVideoPlayer.prepareAsync();
4. Lifecycle handling
@Override
protected void onResume() {
super.onResume();
mVideoPlayer.onResume();
}
@Override
protected void onPause() {
super.onPause();
mVideoPlayer.onPause();
}
@Override
public void onBackPressed() {
if(mVideoPlayer.isBackPressed()){
super.onBackPressed();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
mVideoPlayer.onDestroy();
}
5. For common APIs, switching decoders, custom decoders, UI interaction components, floating-window playback, and other features, please refer to the wiki.
下载地址 免费
评论