├── .DS_Store
├── .gitignore
├── LICENSE
├── README.md
├── app
├── .DS_Store
├── .gitignore
├── build.gradle
├── libs
│ └── logtools.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kk
│ │ └── taurus
│ │ └── avplayer
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── video
│ │ │ └── big_buck_bunny.mp4
│ ├── java
│ │ └── com
│ │ │ └── kk
│ │ │ └── taurus
│ │ │ └── avplayer
│ │ │ ├── App.java
│ │ │ ├── HomeActivity.java
│ │ │ ├── adapter
│ │ │ ├── ListAdapter.java
│ │ │ ├── OnItemClickListener.java
│ │ │ ├── PlayPagerAdapter.java
│ │ │ ├── RecyclerBaseVideoContentAdapter.java
│ │ │ ├── SettingAdapter.java
│ │ │ └── VideoListPagerAdapter.java
│ │ │ ├── base
│ │ │ ├── BSPlayer.java
│ │ │ └── ISPayer.java
│ │ │ ├── bean
│ │ │ ├── RecyclerBaseVideoBean.java
│ │ │ ├── SettingItem.java
│ │ │ └── VideoBean.java
│ │ │ ├── cover
│ │ │ ├── CloseCover.java
│ │ │ ├── CompleteCover.java
│ │ │ ├── ControllerCover.java
│ │ │ ├── DanmuCover.java
│ │ │ ├── ErrorCover.java
│ │ │ ├── GestureCover.java
│ │ │ └── LoadingCover.java
│ │ │ ├── event_producer
│ │ │ └── DanmuDataProducer.java
│ │ │ ├── play
│ │ │ ├── DataInter.java
│ │ │ ├── DemoDataProvider.java
│ │ │ ├── ListPlayer.java
│ │ │ ├── OnHandleListener.java
│ │ │ ├── ReceiverGroupManager.java
│ │ │ └── ShareAnimationPlayer.java
│ │ │ ├── ui
│ │ │ ├── BaseVideoViewActivity.java
│ │ │ ├── DetailPlayActivity.java
│ │ │ ├── InputUrlPlayActivity.java
│ │ │ ├── MultiPlayActivity.java
│ │ │ ├── MusicPlayActivity.java
│ │ │ ├── RecyclerBaseVideoActivity.java
│ │ │ ├── ShareAnimationActivityA.java
│ │ │ ├── ShareAnimationActivityB.java
│ │ │ ├── SplashActivity.java
│ │ │ ├── ViewPagerPlayActivity.java
│ │ │ ├── fragment
│ │ │ │ └── VideoListFragment.java
│ │ │ ├── listplay
│ │ │ │ ├── ListPlayActivity.java
│ │ │ │ └── MultiListActivity.java
│ │ │ └── window
│ │ │ │ ├── FloatWindowActivity.java
│ │ │ │ └── WindowVideoViewActivity.java
│ │ │ ├── utils
│ │ │ ├── DataUtils.java
│ │ │ ├── ImageDisplayEngine.java
│ │ │ ├── MediaGlideModule.java
│ │ │ ├── OrientationHelper.java
│ │ │ ├── OrientationSensor.java
│ │ │ ├── PUtil.java
│ │ │ ├── RandomUtils.java
│ │ │ └── WindowPermissionCheck.java
│ │ │ └── view
│ │ │ ├── SmileView.java
│ │ │ └── VisualizerView.java
│ ├── jniLibs
│ │ └── armeabi-v7a
│ │ │ ├── libijkffmpeg.so
│ │ │ ├── libijkplayer.so
│ │ │ └── libijksdl.so
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ ├── selector_play_state.xml
│ │ ├── selector_seek_bar_thumb.xml
│ │ ├── shape_controller_bottom_gradient.xml
│ │ ├── shape_controller_top_gradient.xml
│ │ ├── shape_next.xml
│ │ ├── shape_replay.xml
│ │ ├── style_video_player_video_bottom_seekbar.xml
│ │ └── style_video_player_video_seekbar.xml
│ │ ├── layout-v21
│ │ └── activity_share_animation_b.xml
│ │ ├── layout
│ │ ├── activity_base_video_view.xml
│ │ ├── activity_detail_page.xml
│ │ ├── activity_home.xml
│ │ ├── activity_input_url_play.xml
│ │ ├── activity_list.xml
│ │ ├── activity_multi_list.xml
│ │ ├── activity_multi_play.xml
│ │ ├── activity_recycler_base_video.xml
│ │ ├── activity_recycler_base_video_type_item.xml
│ │ ├── activity_recycler_base_video_type_video.xml
│ │ ├── activity_share_animation_a.xml
│ │ ├── activity_share_animation_b.xml
│ │ ├── activity_splash.xml
│ │ ├── activity_test_play.xml
│ │ ├── activity_view_pager_play.xml
│ │ ├── activity_window_switch_play.xml
│ │ ├── activity_window_video_view.xml
│ │ ├── fragment_list.xml
│ │ ├── item_pager_play.xml
│ │ ├── item_setting.xml
│ │ ├── item_video.xml
│ │ ├── layout_close_cover.xml
│ │ ├── layout_complete_cover.xml
│ │ ├── layout_controller_cover.xml
│ │ ├── layout_danmu_cover.xml
│ │ ├── layout_dark_mode_title_bar.xml
│ │ ├── layout_error_cover.xml
│ │ ├── layout_gesture_cover.xml
│ │ ├── layout_loading_cover.xml
│ │ └── layout_window.xml
│ │ ├── menu
│ │ └── main_menu.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_brightness_white.png
│ │ ├── ic_launcher.png
│ │ ├── ic_video_player_btn_pause.png
│ │ ├── ic_video_player_btn_play.png
│ │ ├── ic_volume_off_white.png
│ │ ├── ic_volume_up_white.png
│ │ ├── icon_arrow_right.png
│ │ ├── icon_back_white.png
│ │ ├── icon_close.png
│ │ ├── icon_exit_full_screen.png
│ │ ├── icon_full_screen.png
│ │ ├── icon_player_back.png
│ │ ├── player_icon_start_play.png
│ │ ├── seek_bar_progress.png
│ │ └── seek_bar_progress_default.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── raw
│ │ └── big_buck_bunny.mp4
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── kk
│ └── taurus
│ └── avplayer
│ └── ExampleUnitTest.java
├── build.gradle
├── exoplayer
├── .gitignore
├── bintray.gradle
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── kk
│ └── taurus
│ └── exoplayer
│ └── ExoMediaPlayer.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── ijkplayer
├── .DS_Store
├── .gitignore
├── bintray.gradle
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── kk
│ └── taurus
│ └── ijkplayer
│ ├── IjkPlayer.java
│ └── RawDataSourceProvider.java
├── playerbase
├── .DS_Store
├── .gitignore
├── bintray.gradle
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── kk
│ └── taurus
│ └── playerbase
│ ├── AVPlayer.java
│ ├── assist
│ ├── AssistPlay.java
│ ├── BaseEventAssistHandler.java
│ ├── InterEvent.java
│ ├── InterKey.java
│ ├── OnAssistPlayEventHandler.java
│ ├── OnEventAssistHandler.java
│ ├── OnVideoViewEventHandler.java
│ └── RelationAssist.java
│ ├── config
│ ├── AppContextAttach.java
│ ├── PConst.java
│ ├── PlayerConfig.java
│ ├── PlayerLibrary.java
│ └── PlayerLoader.java
│ ├── entity
│ ├── DataSource.java
│ ├── DecoderPlan.java
│ └── TimedTextSource.java
│ ├── event
│ ├── BundlePool.java
│ ├── EventDispatcher.java
│ ├── EventKey.java
│ ├── IEventDispatcher.java
│ ├── OnErrorEventListener.java
│ └── OnPlayerEventListener.java
│ ├── extension
│ ├── BaseEventProducer.java
│ ├── DelegateReceiverEventSender.java
│ ├── EventCallback.java
│ ├── EventProducer.java
│ ├── IProducerGroup.java
│ ├── NetworkEventProducer.java
│ ├── ProducerEventSender.java
│ ├── ProducerGroup.java
│ └── ReceiverEventSender.java
│ ├── log
│ ├── DebugLog.java
│ └── PLog.java
│ ├── player
│ ├── BaseInternalPlayer.java
│ ├── IPlayer.java
│ ├── IPlayerProxy.java
│ ├── OnBufferingListener.java
│ ├── OnTimerUpdateListener.java
│ ├── SysMediaPlayer.java
│ └── TimerCounterProxy.java
│ ├── provider
│ ├── BaseDataProvider.java
│ └── IDataProvider.java
│ ├── receiver
│ ├── AbsCoverContainer.java
│ ├── BaseCover.java
│ ├── BaseLevelCoverContainer.java
│ ├── BaseReceiver.java
│ ├── CoverComparator.java
│ ├── DefaultLevelCoverContainer.java
│ ├── GroupValue.java
│ ├── ICover.java
│ ├── ICoverHandle.java
│ ├── ICoverStrategy.java
│ ├── IReceiver.java
│ ├── IReceiverGroup.java
│ ├── OnReceiverEventListener.java
│ ├── PlayerStateGetter.java
│ ├── ReceiverGroup.java
│ ├── StateGetter.java
│ └── ValueInter.java
│ ├── record
│ ├── DefaultRecordKeyProvider.java
│ ├── OnRecordCallBack.java
│ ├── PlayRecord.java
│ ├── PlayRecordManager.java
│ ├── PlayValueGetter.java
│ ├── RecordCache.java
│ ├── RecordInvoker.java
│ ├── RecordKeyProvider.java
│ └── RecordProxyPlayer.java
│ ├── render
│ ├── AspectRatio.java
│ ├── IRender.java
│ ├── RenderMeasure.java
│ ├── RenderSurfaceView.java
│ └── RenderTextureView.java
│ ├── style
│ ├── IStyleSetter.java
│ ├── StyleSetter.java
│ ├── ViewOvalRectOutlineProvider.java
│ └── ViewRoundRectOutlineProvider.java
│ ├── touch
│ ├── BaseGestureCallbackHandler.java
│ ├── ContainerTouchHelper.java
│ ├── OnTouchGestureListener.java
│ └── TouchEventIndicator.java
│ ├── utils
│ ├── NetworkUtils.java
│ ├── PUtils.java
│ ├── RectUtils.java
│ └── TimeUtil.java
│ ├── widget
│ ├── BaseVideoView.java
│ ├── IVideoView.java
│ └── SuperContainer.java
│ └── window
│ ├── FloatWindow.java
│ ├── FloatWindowParams.java
│ ├── IWindow.java
│ ├── WindowHelper.java
│ └── WindowVideoView.java
├── screenshot
├── Screenshot_001.jpeg
├── Screenshot_002.jpeg
├── Screenshot_003.jpeg
├── Screenshot_004.jpeg
├── Screenshot_005.jpeg
├── Screenshot_006.jpeg
├── frame_structure01.jpg
├── frame_structure02.png
├── frame_structure03.png
├── frame_structure04.png
├── mtime.png
├── piaoshen.png
├── playerbase_top_slogen.png
├── qrcode.png
├── qrcode_qq_group.jpg
├── receiver_cover_life_cycle.jpg
├── widget_struct.jpg
└── yingmidayuan.png
└── settings.gradle
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/.DS_Store
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.kk.taurus.avplayer"
7 | minSdkVersion 16
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 | ndk {
13 | //目前手机主流cpu架构是armeabi-v7a,所以通常情况下只考虑armeabi-v7a(除非特殊情况,比如TBS只有armeabi so库)
14 | // https://zhuanlan.zhihu.com/p/26833002
15 | // 1,如果同时保留 armeabi 和 armeabi-v7a 两个文件夹,则必须保证这两个文件夹中 .so 数量一致
16 | // 2,如果只存在armeabi-v7a,则对只提供 armeabi 版本的第三方 .so,原样复制一份到 armeabi-v7a 文件夹
17 | abiFilters 'armeabi-v7a'
18 | }
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled true
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | compileOptions{
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 | }
30 |
31 | lintOptions{
32 | abortOnError false
33 | }
34 |
35 | }
36 |
37 | dependencies {
38 | implementation fileTree(include: ['*.jar'], dir: 'libs')
39 | implementation 'androidx.appcompat:appcompat:1.1.0'
40 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
41 | testImplementation 'junit:junit:4.12'
42 | androidTestImplementation 'androidx.test:runner:1.2.0'
43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
44 | implementation 'com.jiajunhui.xapp.medialoader:medialoader:1.2.1'
45 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
46 | implementation 'com.lovedise:permissiongen:0.0.6'
47 | implementation 'com.github.bumptech.glide:glide:4.9.0'
48 | annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
49 | implementation 'com.jakewharton:butterknife:10.1.0'
50 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
51 | debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
52 | releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
53 | implementation project(':exoplayer')
54 | implementation project(':ijkplayer')
55 | implementation 'com.google.android.material:material:1.0.0'
56 |
57 | implementation 'com.github.ctiao:DanmakuFlameMaster:0.9.25'
58 | implementation 'com.github.ctiao:ndkbitmap-armv7a:0.9.21'
59 |
60 | implementation 'com.google.android.exoplayer:extension-rtmp:2.12.2'
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/libs/logtools.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/libs/logtools.jar
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/kk/taurus/avplayer/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.kk.taurus.avplayer", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/assets/video/big_buck_bunny.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/assets/video/big_buck_bunny.mp4
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/adapter/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.adapter;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 |
5 | public interface OnItemClickListener {
6 |
7 | void onItemClick(H holder, T item, int position);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/adapter/PlayPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.adapter;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.NonNull;
5 | import androidx.viewpager.widget.PagerAdapter;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.FrameLayout;
9 | import android.widget.ImageView;
10 |
11 | import com.kk.taurus.avplayer.R;
12 | import com.kk.taurus.avplayer.bean.VideoBean;
13 | import com.kk.taurus.avplayer.utils.GlideApp;
14 |
15 | import java.util.List;
16 |
17 | public class PlayPagerAdapter extends PagerAdapter {
18 |
19 | private Context mContext;
20 | private List mItems;
21 |
22 | public PlayPagerAdapter(Context context, List list){
23 | this.mContext = context;
24 | this.mItems = list;
25 | }
26 |
27 | @Override
28 | public int getCount() {
29 | if(mItems!=null)
30 | return mItems.size();
31 | return 0;
32 | }
33 |
34 | @NonNull
35 | @Override
36 | public Object instantiateItem(@NonNull ViewGroup container, int position) {
37 | VideoBean bean = mItems.get(position);
38 | View itemView = View.inflate(mContext, R.layout.item_pager_play, null);
39 | FrameLayout playerContainer = itemView.findViewById(R.id.playerContainer);
40 | playerContainer.setTag(bean.getPath());
41 | ImageView coverView = itemView.findViewById(R.id.iv_cover);
42 | GlideApp.with(mContext)
43 | .load(bean.getPath())
44 | .centerInside()
45 | .into(coverView);
46 | container.addView(itemView);
47 | return itemView;
48 | }
49 |
50 | @Override
51 | public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
52 | return view == object;
53 | }
54 |
55 | @Override
56 | public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
57 | container.removeView((View) object);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/adapter/SettingAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import androidx.annotation.NonNull;
6 | import androidx.recyclerview.widget.RecyclerView;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.kk.taurus.avplayer.R;
12 |
13 | import java.util.List;
14 |
15 | import com.kk.taurus.avplayer.bean.SettingItem;
16 |
17 | public class SettingAdapter extends RecyclerView.Adapter {
18 |
19 | private Context mContext;
20 | private List mItems;
21 |
22 | private OnItemClickListener onItemClickListener;
23 |
24 | public SettingAdapter(Context context, List list){
25 | this.mContext = context;
26 | this.mItems = list;
27 | }
28 |
29 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
30 | this.onItemClickListener = onItemClickListener;
31 | }
32 |
33 | @NonNull
34 | @Override
35 | public SettingItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
36 | return new SettingItemHolder(View.inflate(mContext, R.layout.item_setting, null));
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(@NonNull final SettingItemHolder holder, final int position) {
41 | final SettingItem item = mItems.get(position);
42 | holder.itemView.setBackgroundColor((item.getCode()/100)%2==0?Color.WHITE:Color.parseColor("#EEEEEE"));
43 | holder.settingText.setText(item.getItemText());
44 |
45 | holder.itemView.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | onItemClickListener.onItemClick(holder, item, position);
49 | }
50 | });
51 | }
52 |
53 | @Override
54 | public int getItemCount() {
55 | if(mItems!=null)
56 | return mItems.size();
57 | return 0;
58 | }
59 |
60 | public static class SettingItemHolder extends RecyclerView.ViewHolder{
61 |
62 | TextView settingText;
63 |
64 | public SettingItemHolder(View itemView) {
65 | super(itemView);
66 | settingText = itemView.findViewById(R.id.settingText);
67 | }
68 |
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/adapter/VideoListPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.adapter;
2 |
3 | import androidx.annotation.Nullable;
4 | import androidx.fragment.app.Fragment;
5 | import androidx.fragment.app.FragmentManager;
6 | import androidx.fragment.app.FragmentStatePagerAdapter;
7 |
8 | import com.kk.taurus.avplayer.ui.fragment.VideoListFragment;
9 |
10 | import java.util.List;
11 |
12 | public class VideoListPagerAdapter extends FragmentStatePagerAdapter {
13 |
14 | private List mFragments;
15 |
16 | public VideoListPagerAdapter(FragmentManager fm, List fragments) {
17 | super(fm);
18 | mFragments = fragments;
19 | }
20 |
21 | @Override
22 | public Fragment getItem(int position) {
23 | return mFragments.get(position);
24 | }
25 |
26 | @Nullable
27 | @Override
28 | public CharSequence getPageTitle(int position) {
29 | return "列表" + (position + 1);
30 | }
31 |
32 | @Override
33 | public int getCount() {
34 | if(mFragments==null)
35 | return 0;
36 | return mFragments.size();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/base/ISPayer.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.base;
2 |
3 |
4 | import android.view.ViewGroup;
5 |
6 | import com.kk.taurus.playerbase.entity.DataSource;
7 | import com.kk.taurus.playerbase.event.OnErrorEventListener;
8 | import com.kk.taurus.playerbase.event.OnPlayerEventListener;
9 | import com.kk.taurus.playerbase.provider.IDataProvider;
10 | import com.kk.taurus.playerbase.receiver.GroupValue;
11 | import com.kk.taurus.playerbase.receiver.IReceiver;
12 | import com.kk.taurus.playerbase.receiver.IReceiverGroup;
13 | import com.kk.taurus.playerbase.receiver.OnReceiverEventListener;
14 |
15 | /**
16 | * Created by JiaJunHui on 2018/6/21.
17 | */
18 | public interface ISPayer {
19 |
20 | int RECEIVER_GROUP_CONFIG_SILENCE_STATE = 1;
21 | int RECEIVER_GROUP_CONFIG_LIST_STATE = 2;
22 | int RECEIVER_GROUP_CONFIG_DETAIL_PORTRAIT_STATE = 3;
23 | int RECEIVER_GROUP_CONFIG_FULL_SCREEN_STATE = 4;
24 |
25 | void addOnPlayerEventListener(OnPlayerEventListener onPlayerEventListener);
26 |
27 | boolean removePlayerEventListener(OnPlayerEventListener onPlayerEventListener);
28 |
29 | void addOnErrorEventListener(OnErrorEventListener onErrorEventListener);
30 |
31 | boolean removeErrorEventListener(OnErrorEventListener onErrorEventListener);
32 |
33 | void addOnReceiverEventListener(OnReceiverEventListener onReceiverEventListener);
34 |
35 | boolean removeReceiverEventListener(OnReceiverEventListener onReceiverEventListener);
36 |
37 | void setReceiverGroup(IReceiverGroup receiverGroup);
38 |
39 | IReceiverGroup getReceiverGroup();
40 |
41 | void removeReceiver(String receiverKey);
42 |
43 | void addReceiver(String key, IReceiver receiver);
44 |
45 | void attachContainer(ViewGroup userContainer);
46 |
47 | void play(DataSource dataSource);
48 |
49 | void play(DataSource dataSource, boolean updateRender);
50 |
51 | void setDataProvider(IDataProvider dataProvider);
52 |
53 | GroupValue getGroupValue();
54 |
55 | void updateGroupValue(String key, Object value);
56 |
57 | void registerOnGroupValueUpdateListener(IReceiverGroup.OnGroupValueUpdateListener onGroupValueUpdateListener);
58 |
59 | void unregisterOnGroupValueUpdateListener(IReceiverGroup.OnGroupValueUpdateListener onGroupValueUpdateListener);
60 |
61 | boolean isInPlaybackState();
62 |
63 | boolean isPlaying();
64 |
65 | int getCurrentPosition();
66 |
67 | int getState();
68 |
69 | void pause();
70 |
71 | void resume();
72 |
73 | void stop();
74 |
75 | void reset();
76 |
77 | void rePlay(int position);
78 |
79 | void destroy() ;
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/bean/RecyclerBaseVideoBean.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.bean;
2 |
3 | import com.kk.taurus.avplayer.utils.DataUtils;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @author KaraShokZ (张耀中)
10 | * DESCRIPTION
11 | * @name RecyclerBaseVideoBean
12 | * @date 2021/01/15 14:51
13 | */
14 | public class RecyclerBaseVideoBean {
15 |
16 | public static final List getItemList(){
17 | List itemList = new ArrayList<>();
18 | itemList.add(new RecyclerBaseVideoBean(1));
19 | for (int i = 0; i < 50; i++){
20 | itemList.add(new RecyclerBaseVideoBean());
21 | }
22 | return itemList;
23 | }
24 | public int itemType;
25 | public String videoUrl = DataUtils.VIDEO_URL_09,itemStr = "音乐和艺术如何改变世界";
26 |
27 | public RecyclerBaseVideoBean(int itemType) {
28 | this.itemType = itemType;
29 | }
30 |
31 | public RecyclerBaseVideoBean() {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/bean/VideoBean.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.bean;
2 |
3 | import java.io.Serializable;
4 |
5 | public class VideoBean implements Serializable {
6 |
7 | private String displayName;
8 | private String cover;
9 | private String path;
10 |
11 | public VideoBean() {
12 | }
13 |
14 | public VideoBean(String displayName, String cover, String path) {
15 | this.displayName = displayName;
16 | this.cover = cover;
17 | this.path = path;
18 | }
19 |
20 | public VideoBean(String displayName, String path) {
21 | this.displayName = displayName;
22 | this.path = path;
23 | }
24 |
25 | public String getDisplayName() {
26 | return displayName;
27 | }
28 |
29 | public void setDisplayName(String displayName) {
30 | this.displayName = displayName;
31 | }
32 |
33 | public String getCover() {
34 | return cover;
35 | }
36 |
37 | public void setCover(String cover) {
38 | this.cover = cover;
39 | }
40 |
41 | public String getPath() {
42 | return path;
43 | }
44 |
45 | public void setPath(String path) {
46 | this.path = path;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/cover/CloseCover.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.cover;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 |
8 | import com.kk.taurus.avplayer.R;
9 | import com.kk.taurus.avplayer.play.DataInter;
10 | import com.kk.taurus.playerbase.receiver.BaseCover;
11 |
12 | import butterknife.BindView;
13 | import butterknife.ButterKnife;
14 | import butterknife.OnClick;
15 | import butterknife.Unbinder;
16 |
17 | public class CloseCover extends BaseCover {
18 |
19 | @BindView(R.id.iv_close)
20 | ImageView mCloseIcon;
21 |
22 | private Unbinder unbinder;
23 |
24 | public CloseCover(Context context) {
25 | super(context);
26 | }
27 |
28 | @Override
29 | public void onReceiverBind() {
30 | super.onReceiverBind();
31 | unbinder = ButterKnife.bind(this, getView());
32 | }
33 |
34 | @OnClick({R.id.iv_close})
35 | public void onViewClick(View view){
36 | notifyReceiverEvent(DataInter.Event.EVENT_CODE_REQUEST_CLOSE, null);
37 | }
38 |
39 | @Override
40 | public void onReceiverUnBind() {
41 | super.onReceiverUnBind();
42 | unbinder.unbind();
43 | }
44 |
45 | @Override
46 | public View onCreateCoverView(Context context) {
47 | return View.inflate(context, R.layout.layout_close_cover, null);
48 | }
49 |
50 | @Override
51 | public void onPlayerEvent(int eventCode, Bundle bundle) {
52 |
53 | }
54 |
55 | @Override
56 | public void onErrorEvent(int eventCode, Bundle bundle) {
57 |
58 | }
59 |
60 | @Override
61 | public void onReceiverEvent(int eventCode, Bundle bundle) {
62 |
63 | }
64 |
65 | @Override
66 | public int getCoverLevel() {
67 | return levelMedium(10);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/cover/LoadingCover.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.cover;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import com.kk.taurus.avplayer.R;
8 | import com.kk.taurus.playerbase.event.OnPlayerEventListener;
9 | import com.kk.taurus.playerbase.player.IPlayer;
10 | import com.kk.taurus.playerbase.receiver.BaseCover;
11 | import com.kk.taurus.playerbase.receiver.PlayerStateGetter;
12 |
13 | /**
14 | * Created by Taurus on 2018/4/15.
15 | */
16 |
17 | public class LoadingCover extends BaseCover {
18 |
19 | public LoadingCover(Context context) {
20 | super(context);
21 | }
22 |
23 | @Override
24 | protected void onCoverAttachedToWindow() {
25 | super.onCoverAttachedToWindow();
26 | PlayerStateGetter playerStateGetter = getPlayerStateGetter();
27 | if(playerStateGetter!=null && isInPlaybackState(playerStateGetter)){
28 | setLoadingState(playerStateGetter.isBuffering());
29 | }
30 | }
31 |
32 | private boolean isInPlaybackState(PlayerStateGetter playerStateGetter){
33 | int state = playerStateGetter.getState();
34 | return state!= IPlayer.STATE_END
35 | && state!= IPlayer.STATE_ERROR
36 | && state!= IPlayer.STATE_IDLE
37 | && state!= IPlayer.STATE_INITIALIZED
38 | && state!= IPlayer.STATE_STOPPED;
39 | }
40 |
41 | @Override
42 | public void onPlayerEvent(int eventCode, Bundle bundle) {
43 | switch (eventCode){
44 | case OnPlayerEventListener.PLAYER_EVENT_ON_BUFFERING_START:
45 | case OnPlayerEventListener.PLAYER_EVENT_ON_DATA_SOURCE_SET:
46 | case OnPlayerEventListener.PLAYER_EVENT_ON_PROVIDER_DATA_START:
47 | case OnPlayerEventListener.PLAYER_EVENT_ON_SEEK_TO:
48 | setLoadingState(true);
49 | break;
50 |
51 | case OnPlayerEventListener.PLAYER_EVENT_ON_VIDEO_RENDER_START:
52 | case OnPlayerEventListener.PLAYER_EVENT_ON_BUFFERING_END:
53 | case OnPlayerEventListener.PLAYER_EVENT_ON_STOP:
54 | case OnPlayerEventListener.PLAYER_EVENT_ON_PROVIDER_DATA_ERROR:
55 | case OnPlayerEventListener.PLAYER_EVENT_ON_SEEK_COMPLETE:
56 | setLoadingState(false);
57 | break;
58 | }
59 | }
60 |
61 | @Override
62 | public void onErrorEvent(int eventCode, Bundle bundle) {
63 | setLoadingState(false);
64 | }
65 |
66 | @Override
67 | public void onReceiverEvent(int eventCode, Bundle bundle) {
68 |
69 | }
70 |
71 | private void setLoadingState(boolean show){
72 | setCoverVisibility(show?View.VISIBLE:View.GONE);
73 | }
74 |
75 | @Override
76 | public View onCreateCoverView(Context context) {
77 | return View.inflate(context, R.layout.layout_loading_cover, null);
78 | }
79 |
80 | @Override
81 | public int getCoverLevel() {
82 | return levelMedium(1);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/play/DataInter.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.play;
2 |
3 | import com.kk.taurus.playerbase.assist.InterEvent;
4 | import com.kk.taurus.playerbase.assist.InterKey;
5 |
6 | public interface DataInter {
7 |
8 | interface Event extends InterEvent{
9 |
10 | int EVENT_CODE_REQUEST_BACK = -100;
11 | int EVENT_CODE_REQUEST_CLOSE = -101;
12 |
13 | int EVENT_CODE_REQUEST_TOGGLE_SCREEN = -104;
14 |
15 | int EVENT_CODE_ERROR_SHOW = -111;
16 |
17 | }
18 |
19 | interface Key extends InterKey{
20 |
21 | String KEY_IS_LANDSCAPE = "isLandscape";
22 |
23 | String KEY_DATA_SOURCE = "data_source";
24 |
25 | String KEY_ERROR_SHOW = "error_show";
26 |
27 | String KEY_COMPLETE_SHOW = "complete_show";
28 | String KEY_CONTROLLER_TOP_ENABLE = "controller_top_enable";
29 | String KEY_CONTROLLER_SCREEN_SWITCH_ENABLE = "screen_switch_enable";
30 |
31 | String KEY_TIMER_UPDATE_ENABLE = "timer_update_enable";
32 |
33 | String KEY_NETWORK_RESOURCE = "network_resource";
34 |
35 | }
36 |
37 | interface ReceiverKey{
38 | String KEY_LOADING_COVER = "loading_cover";
39 | String KEY_CONTROLLER_COVER = "controller_cover";
40 | String KEY_GESTURE_COVER = "gesture_cover";
41 | String KEY_COMPLETE_COVER = "complete_cover";
42 | String KEY_ERROR_COVER = "error_cover";
43 | String KEY_CLOSE_COVER = "close_cover";
44 | String KEY_DANMU_COVER = "danmu_cover";
45 | }
46 |
47 | interface PrivateEvent{
48 | int EVENT_CODE_UPDATE_SEEK = -201;
49 | }
50 |
51 | interface ProducerEvent{
52 |
53 | int ADD_DANMU_DATA = -301;
54 |
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/play/DemoDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.play;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 | import android.text.TextUtils;
6 |
7 | import com.kk.taurus.avplayer.utils.DataUtils;
8 | import com.kk.taurus.playerbase.entity.DataSource;
9 | import com.kk.taurus.playerbase.provider.BaseDataProvider;
10 |
11 | public class DemoDataProvider extends BaseDataProvider {
12 |
13 | private Handler mHandler = new Handler(Looper.getMainLooper());
14 | private Runnable mDelayRunnable;
15 |
16 | @Override
17 | public void handleSourceData(final DataSource sourceData) {
18 | if(TextUtils.isEmpty(sourceData.getData())){
19 | cancel();
20 | //模拟请求数据的过程
21 | mHandler.postDelayed(mDelayRunnable = new Runnable() {
22 | @Override
23 | public void run() {
24 | DataSource data = new DataSource(DataUtils.VIDEO_URL_08);
25 | data.setTitle("音乐和艺术如何改变世界");
26 | //success result data
27 | onProviderMediaDataSuccess(data);
28 | //if occur error, you can call this method
29 | //onProviderMediaDataError(bundle);
30 | }
31 | }, 1000);
32 | }else{
33 | onProviderMediaDataSuccess(sourceData);
34 | }
35 | }
36 |
37 | @Override
38 | public void cancel() {
39 | if(mDelayRunnable!=null)
40 | mHandler.removeCallbacks(mDelayRunnable);
41 | }
42 |
43 | @Override
44 | public void destroy() {
45 | cancel();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/play/OnHandleListener.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.play;
2 |
3 | public interface OnHandleListener {
4 |
5 | void onBack();
6 | void onToggleScreen();
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/ui/RecyclerBaseVideoActivity.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.ui;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.recyclerview.widget.LinearLayoutManager;
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import android.os.Bundle;
8 |
9 | import com.kk.taurus.avplayer.R;
10 | import com.kk.taurus.avplayer.adapter.RecyclerBaseVideoContentAdapter;
11 | import com.kk.taurus.avplayer.bean.RecyclerBaseVideoBean;
12 |
13 | public class RecyclerBaseVideoActivity extends AppCompatActivity {
14 |
15 | RecyclerBaseVideoContentAdapter mAdapter;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_recycler_base_video);
21 | RecyclerView contentRv = findViewById(R.id.content_rv);
22 | contentRv.setLayoutManager(new LinearLayoutManager(this));
23 | contentRv.setAdapter(mAdapter = new RecyclerBaseVideoContentAdapter(RecyclerBaseVideoBean.getItemList()));
24 | }
25 |
26 | @Override
27 | protected void onDestroy() {
28 | super.onDestroy();
29 | mAdapter.onDestroy();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/ui/ShareAnimationActivityB.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.ui;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.Nullable;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import android.view.WindowManager;
7 | import android.widget.RelativeLayout;
8 |
9 | import com.kk.taurus.avplayer.R;
10 | import com.kk.taurus.avplayer.play.ShareAnimationPlayer;
11 | import com.kk.taurus.playerbase.entity.DataSource;
12 |
13 | import butterknife.BindView;
14 | import butterknife.ButterKnife;
15 |
16 | public class ShareAnimationActivityB extends AppCompatActivity {
17 |
18 | public static final String KEY_DATA = "data_source";
19 |
20 | @BindView(R.id.top_container)
21 | RelativeLayout mTopContainer;
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_share_animation_b);
27 | ButterKnife.bind(this);
28 |
29 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
30 |
31 | DataSource dataSource = (DataSource) getIntent().getSerializableExtra(KEY_DATA);
32 |
33 | DataSource useData = null;
34 | DataSource playData = ShareAnimationPlayer.get().getDataSource();
35 | boolean dataChange = playData!=null && !playData.getData().equals(dataSource.getData());
36 | if(!ShareAnimationPlayer.get().isInPlaybackState() || dataChange){
37 | useData = dataSource;
38 | }
39 |
40 | ShareAnimationPlayer.get().play(mTopContainer, useData);
41 |
42 | }
43 |
44 | @Override
45 | protected void onDestroy() {
46 | super.onDestroy();
47 | ShareAnimationPlayer.get().destroy();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/ui/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.ui;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.os.Looper;
8 | import androidx.annotation.Nullable;
9 | import androidx.appcompat.app.AppCompatActivity;
10 | import android.widget.Toast;
11 |
12 | import com.kk.taurus.avplayer.R;
13 |
14 | import com.kk.taurus.avplayer.HomeActivity;
15 | import kr.co.namee.permissiongen.PermissionFail;
16 | import kr.co.namee.permissiongen.PermissionGen;
17 | import kr.co.namee.permissiongen.PermissionSuccess;
18 |
19 | /**
20 | * Created by Taurus on 2018/4/19.
21 | */
22 |
23 | public class SplashActivity extends AppCompatActivity {
24 |
25 | @Override
26 | protected void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_splash);
29 |
30 | new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
31 | @Override
32 | public void run() {
33 | PermissionGen.with(SplashActivity.this)
34 | .addRequestCode(100)
35 | .permissions(
36 | Manifest.permission.READ_EXTERNAL_STORAGE,
37 | Manifest.permission.WRITE_EXTERNAL_STORAGE,
38 | Manifest.permission.RECORD_AUDIO,
39 | Manifest.permission.MODIFY_AUDIO_SETTINGS
40 | )
41 | .request();
42 | }
43 | }, 1000);
44 | }
45 |
46 | @Override
47 | public void onRequestPermissionsResult(int requestCode, String[] permissions,
48 | int[] grantResults) {
49 | PermissionGen.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
50 | }
51 |
52 | @PermissionSuccess(requestCode = 100)
53 | public void permissionSuccess() {
54 | intentToMainPage();
55 | }
56 |
57 | @PermissionFail(requestCode = 100)
58 | public void permissionFailure(){
59 | Toast.makeText(this, "权限拒绝,无法正常使用", Toast.LENGTH_LONG).show();
60 |
61 | }
62 |
63 | private void intentToMainPage() {
64 | Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
65 | startActivity(intent);
66 | finish();
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/utils/ImageDisplayEngine.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.drawable.BitmapDrawable;
6 | import android.graphics.drawable.Drawable;
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import android.widget.ImageView;
10 |
11 | import com.bumptech.glide.request.target.SimpleTarget;
12 | import com.bumptech.glide.request.transition.Transition;
13 |
14 | /**
15 | * Created by Taurus on 2017/5/20.
16 | */
17 |
18 | public class ImageDisplayEngine {
19 |
20 | public static void display(Context context, ImageView view, String path, int defaultHolder){
21 | GlideApp.with(context)
22 | .load(path)
23 | .centerCrop()
24 | .placeholder(defaultHolder)
25 | .into(view);
26 | }
27 |
28 | public static void displayNoCenterCrop(Context context, ImageView view, String path, int defaultHolder){
29 | GlideApp.with(context)
30 | .load(path)
31 | .placeholder(defaultHolder)
32 | .into(view);
33 | }
34 |
35 | public static void displayAsBitmap(Context context, ImageView view, String path, int defaultHolder){
36 | GlideApp.with(context)
37 | .load(path)
38 | .centerCrop()
39 | .placeholder(defaultHolder)
40 | .into(view);
41 | }
42 |
43 | public static void displayAsBitmap(Context context, String path, final OnBitmapResourceCallBack callBack){
44 | GlideApp.with(context)
45 | .load(path)
46 | .dontAnimate()
47 | .into(new SimpleTarget() {
48 | @Override
49 | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition super Drawable> transition) {
50 | if(callBack!=null){
51 | BitmapDrawable bitmapDrawable = (BitmapDrawable) resource;
52 | Bitmap bitmap = null;
53 | if(bitmapDrawable!=null){
54 | bitmap = bitmapDrawable.getBitmap();
55 | }
56 | callBack.onResourceReady(bitmap);
57 | }
58 | }
59 | });
60 | }
61 |
62 | public interface OnBitmapResourceCallBack{
63 | void onResourceReady(Bitmap bitmap);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/utils/MediaGlideModule.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.utils;
2 |
3 | import com.bumptech.glide.annotation.GlideModule;
4 | import com.bumptech.glide.module.AppGlideModule;
5 |
6 | @GlideModule
7 | public class MediaGlideModule extends AppGlideModule {
8 |
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kk/taurus/avplayer/utils/RandomUtils.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer.utils;
2 |
3 | import java.util.Random;
4 |
5 | /**
6 | * author: jiajunhui
7 | * date: 2019/5/29 9:45
8 | * email: junhui.jia@wm-motor.com
9 | * Description: 随机数或随机字符工具
10 | */
11 | public class RandomUtils {
12 |
13 | /**
14 | * 获取指定位数的随机数字
15 | * @param len
16 | * @return
17 | */
18 | public static String getRandomNumberStr(int len){
19 | if(len < 1)
20 | return "";
21 | StringBuilder sb = new StringBuilder();
22 | for(int i=0;i= Build.VERSION_CODES.M
14 | && !Settings.canDrawOverlays(activity)) {
15 | Toast.makeText(activity, "当前无权限,请授权", Toast.LENGTH_SHORT).show();
16 | activity.startActivityForResult(
17 | new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
18 | Uri.parse("package:" + activity.getPackageName())), 0);
19 | return false;
20 | }
21 | return true;
22 | }
23 |
24 | public static void onActivityResult(Activity activity,
25 | int requestCode,
26 | int resultCode,
27 | Intent data,
28 | OnWindowPermissionListener onWindowPermissionListener) {
29 | if (requestCode == 0) {
30 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
31 | && !Settings.canDrawOverlays(activity)) {
32 | Toast.makeText(activity.getApplicationContext(), "授权失败", Toast.LENGTH_SHORT).show();
33 | if(onWindowPermissionListener!=null)
34 | onWindowPermissionListener.onFailure();
35 | }else {
36 | Toast.makeText(activity.getApplicationContext(), "授权成功", Toast.LENGTH_SHORT).show();
37 | if(onWindowPermissionListener!=null)
38 | onWindowPermissionListener.onSuccess();
39 | }
40 | }
41 | }
42 |
43 | public interface OnWindowPermissionListener{
44 | void onSuccess();
45 | void onFailure();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/jniLibs/armeabi-v7a/libijkffmpeg.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/jniLibs/armeabi-v7a/libijkplayer.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/jniLibs/armeabi-v7a/libijksdl.so
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_play_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 | -
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_seek_bar_thumb.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_controller_bottom_gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_controller_top_gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_next.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_replay.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/style_video_player_video_bottom_seekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | -
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | -
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/style_video_player_video_seekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | -
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | -
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-v21/activity_share_animation_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_base_video_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_detail_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_input_url_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
18 |
27 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_multi_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
16 |
17 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_multi_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
17 |
24 |
25 |
26 |
31 |
37 |
44 |
45 |
46 |
51 |
57 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_base_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_base_video_type_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_base_video_type_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_share_animation_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
17 |
22 |
28 |
29 |
34 |
35 |
36 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_share_animation_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_view_pager_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_window_switch_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
24 |
25 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_window_video_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_pager_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
19 |
23 |
28 |
34 |
35 |
40 |
41 |
42 |
47 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_close_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_complete_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_danmu_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_dark_mode_title_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_error_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
24 |
25 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_loading_cover.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
19 |
20 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
18 |
23 |
28 |
29 |
34 |
35 |
36 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_brightness_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/ic_brightness_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_video_player_btn_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/ic_video_player_btn_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_video_player_btn_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/ic_video_player_btn_play.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_volume_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/ic_volume_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_volume_up_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/ic_volume_up_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon_arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/icon_arrow_right.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon_back_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/icon_back_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/icon_close.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon_exit_full_screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/icon_exit_full_screen.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon_full_screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/icon_full_screen.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon_player_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/icon_player_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/player_icon_start_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/player_icon_start_play.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/seek_bar_progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/seek_bar_progress.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/seek_bar_progress_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xhdpi/seek_bar_progress_default.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/raw/big_buck_bunny.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/app/src/main/res/raw/big_buck_bunny.mp4
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #CCCCCC
8 | #000000
9 |
10 | #66000000
11 | #00000000
12 |
13 | #77ffffff
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AVPlayer
3 | PlayerBase
4 |
5 | 选择解码器
6 |
7 | 用IjkPlayer解码
8 | 用MediaPlayer解码
9 | 用ExoPlayer解码
10 |
11 | 打开窗口播放
12 | 关闭窗口播放
13 |
14 | 窗口播放
15 | 页面播放
16 |
17 | 输入地址播放
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
18 |
19 |
23 |
24 |
29 |
30 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/test/java/com/kk/taurus/avplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.avplayer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.6.2'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 |
25 | tasks.withType(Javadoc) {
26 | options.addStringOption('Xdoclint:none', '-quiet')
27 | options.addStringOption('encoding', 'UTF-8')
28 | }
29 | }
30 |
31 | task clean(type: Delete) {
32 | delete rootProject.buildDir
33 | }
34 |
35 | project.ext {
36 |
37 | lib = [
38 | //module versions
39 | ijksdkVersion = '0.8.8',
40 | exoplayersdkVersion = '2.13.2',
41 | appcompatVersion = '1.2.0',
42 |
43 | playerbaseIjkVersion = '342_088_012',
44 | playerbaseExoVersion = '342_2132_019',
45 | playerbaseVersion = '3.4.2'
46 | ]
47 |
48 | }
--------------------------------------------------------------------------------
/exoplayer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/exoplayer/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
5 | version = rootProject.ext.playerbaseExoVersion
6 |
7 | def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页
8 | def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url
9 | group = "cn.jiajunhui" // Maven Group ID for the artifact,一般填你唯一的包名
10 | install {
11 | repositories.mavenInstaller {
12 | // This generates POM.xml with proper parameters
13 | pom {
14 | project {
15 | packaging 'aar'
16 | // Add your description here
17 | description 'Packaging exoplayer by PlayerBase'
18 | name 'exoplayer' //项目描述
19 | url siteUrl
20 | // Set your license
21 | licenses {
22 | license {
23 | name 'The Apache Software License, Version 2.0'
24 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
25 | }
26 | }
27 | developers {
28 | developer { // 开发者信息
29 | id 'exoplayer'
30 | name 'junhui jia'
31 | email 'jiajunhuiplay@gmail.com'
32 | }
33 | }
34 | scm {
35 | connection gitUrl
36 | developerConnection gitUrl
37 | url siteUrl
38 | }
39 | }
40 | }
41 | }
42 | }
43 | task sourcesJar(type: Jar) {
44 | from android.sourceSets.main.java.srcDirs
45 | classifier = 'sources'
46 | }
47 | task javadoc(type: Javadoc) {
48 | options.encoding = 'UTF-8'
49 | source = 'src/main/java'
50 | }
51 |
52 | task javadocJar(type: Jar, dependsOn: javadoc) {
53 | classifier = 'javadoc'
54 | from javadoc.destinationDir
55 | }
56 | artifacts {
57 | archives javadocJar
58 | archives sourcesJar
59 | }
60 | Properties properties = new Properties()
61 | // 加载本地配置
62 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
63 | bintray {
64 | user = properties.getProperty("bintray.user")
65 | key = properties.getProperty("bintray.apikey")
66 | configurations = ['archives']
67 | pkg {
68 | repo = "Tools" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
69 | name = "exoplayer" //发布到Bintray上的项目名字
70 | websiteUrl = siteUrl
71 | vcsUrl = gitUrl
72 | licenses = ["Apache-2.0"]
73 | publish = true
74 | }
75 | }
--------------------------------------------------------------------------------
/exoplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //apply from: 'bintray.gradle'
3 |
4 | android {
5 | compileSdkVersion 29
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | compileOptions{
20 | sourceCompatibility JavaVersion.VERSION_1_8
21 | targetCompatibility JavaVersion.VERSION_1_8
22 | }
23 | }
24 |
25 | lintOptions{
26 | abortOnError false
27 | }
28 |
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(include: ['*.jar'], dir: 'libs')
33 |
34 | api "com.google.android.exoplayer:exoplayer-core:$exoplayersdkVersion"
35 | api "com.google.android.exoplayer:exoplayer-dash:$exoplayersdkVersion"
36 | api "com.google.android.exoplayer:exoplayer-hls:$exoplayersdkVersion"
37 | api "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayersdkVersion"
38 | api "com.kk.taurus.playerbase:playerbase:$playerbaseVersion"
39 | // api project(':playerbase')
40 | }
--------------------------------------------------------------------------------
/exoplayer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/exoplayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Mar 19 10:07:48 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/ijkplayer/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/ijkplayer/.DS_Store
--------------------------------------------------------------------------------
/ijkplayer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
5 | version = rootProject.ext.playerbaseIjkVersion
6 |
7 | def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页
8 | def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url
9 | group = "cn.jiajunhui" // Maven Group ID for the artifact,一般填你唯一的包名
10 | install {
11 | repositories.mavenInstaller {
12 | // This generates POM.xml with proper parameters
13 | pom {
14 | project {
15 | packaging 'aar'
16 | // Add your description here
17 | description 'Packaging ijkplayer by PlayerBase'
18 | name 'ijkplayer' //项目描述
19 | url siteUrl
20 | // Set your license
21 | licenses {
22 | license {
23 | name 'The Apache Software License, Version 2.0'
24 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
25 | }
26 | }
27 | developers {
28 | developer { // 开发者信息
29 | id 'ijkplayer'
30 | name 'junhui jia'
31 | email 'jiajunhuiplay@gmail.com'
32 | }
33 | }
34 | scm {
35 | connection gitUrl
36 | developerConnection gitUrl
37 | url siteUrl
38 | }
39 | }
40 | }
41 | }
42 | }
43 | task sourcesJar(type: Jar) {
44 | from android.sourceSets.main.java.srcDirs
45 | classifier = 'sources'
46 | }
47 | task javadoc(type: Javadoc) {
48 | options.encoding = 'UTF-8'
49 | source = 'src/main/java'
50 | }
51 |
52 | task javadocJar(type: Jar, dependsOn: javadoc) {
53 | classifier = 'javadoc'
54 | from javadoc.destinationDir
55 | }
56 | artifacts {
57 | archives javadocJar
58 | archives sourcesJar
59 | }
60 | Properties properties = new Properties()
61 | // 加载本地配置
62 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
63 | bintray {
64 | user = properties.getProperty("bintray.user")
65 | key = properties.getProperty("bintray.apikey")
66 | configurations = ['archives']
67 | pkg {
68 | repo = "Tools" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
69 | name = "ijkplayer" //发布到Bintray上的项目名字
70 | websiteUrl = siteUrl
71 | vcsUrl = gitUrl
72 | licenses = ["Apache-2.0"]
73 | publish = true
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/ijkplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //apply from: 'bintray.gradle'
3 |
4 | android {
5 | compileSdkVersion 29
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | compileOptions{
20 |
21 | }
22 | }
23 |
24 | lintOptions{
25 | abortOnError false
26 | }
27 |
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(include: ['*.jar'], dir: 'libs')
32 |
33 | api "tv.danmaku.ijk.media:ijkplayer-java:$ijksdkVersion"
34 | api "com.kk.taurus.playerbase:playerbase:$playerbaseVersion"
35 | // api project(':playerbase')
36 | }
37 |
--------------------------------------------------------------------------------
/ijkplayer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ijkplayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/ijkplayer/src/main/java/com/kk/taurus/ijkplayer/RawDataSourceProvider.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.ijkplayer;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetFileDescriptor;
5 | import android.net.Uri;
6 |
7 | import java.io.ByteArrayOutputStream;
8 | import java.io.FileNotFoundException;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 |
12 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
13 |
14 | public class RawDataSourceProvider implements IMediaDataSource {
15 |
16 | private AssetFileDescriptor mDescriptor;
17 |
18 | private byte[] mMediaBytes;
19 |
20 | private RawDataSourceProvider(AssetFileDescriptor descriptor) {
21 | this.mDescriptor = descriptor;
22 | }
23 |
24 | @Override
25 | public int readAt(long position, byte[] buffer, int offset, int size) {
26 | if(position + 1 >= mMediaBytes.length){
27 | return -1;
28 | }
29 |
30 | int length;
31 | if(position + size < mMediaBytes.length){
32 | length = size;
33 | }else{
34 | length = (int) (mMediaBytes.length - position);
35 | if(length > buffer.length)
36 | length = buffer.length ;
37 |
38 | length--;
39 | }
40 | System.arraycopy(mMediaBytes, (int) position, buffer, offset, length);
41 |
42 | return length;
43 | }
44 |
45 | @Override
46 | public long getSize() throws IOException {
47 | long length = mDescriptor.getLength();
48 | if(mMediaBytes == null){
49 | InputStream inputStream = mDescriptor.createInputStream();
50 | mMediaBytes = readBytes(inputStream);
51 | }
52 |
53 |
54 | return length;
55 | }
56 |
57 | @Override
58 | public void close() throws IOException {
59 | if(mDescriptor != null)
60 | mDescriptor.close();
61 |
62 | mDescriptor = null;
63 | mMediaBytes = null;
64 | }
65 |
66 | private byte[] readBytes(InputStream inputStream) throws IOException {
67 | ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
68 |
69 | int bufferSize = 1024;
70 | byte[] buffer = new byte[bufferSize];
71 |
72 | int len = 0;
73 | while ((len = inputStream.read(buffer)) != -1) {
74 | byteBuffer.write(buffer, 0, len);
75 | }
76 |
77 | return byteBuffer.toByteArray();
78 | }
79 |
80 | public static RawDataSourceProvider create(Context context, Uri uri){
81 | try {
82 | AssetFileDescriptor fileDescriptor = context.getContentResolver().openAssetFileDescriptor(uri, "r");
83 | return new RawDataSourceProvider(fileDescriptor);
84 |
85 | } catch (FileNotFoundException e) {
86 | e.printStackTrace();
87 | }
88 | return null;
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/playerbase/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/playerbase/.DS_Store
--------------------------------------------------------------------------------
/playerbase/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/playerbase/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
5 | version = rootProject.ext.playerbaseVersion
6 |
7 | def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页
8 | def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url
9 | group = "com.kk.taurus.playerbase" // Maven Group ID for the artifact,一般填你唯一的包名
10 | install {
11 | repositories.mavenInstaller {
12 | // This generates POM.xml with proper parameters
13 | pom {
14 | project {
15 | packaging 'aar'
16 | // Add your description here
17 | description 'a base player widget library'
18 | name 'PlayerBase' //项目描述
19 | url siteUrl
20 | // Set your license
21 | licenses {
22 | license {
23 | name 'The Apache Software License, Version 2.0'
24 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
25 | }
26 | }
27 | developers {
28 | developer { // 开发者信息
29 | id 'playerbase'
30 | name 'junhui jia'
31 | email 'jiajunhuiplay@gmail.com'
32 | }
33 | }
34 | scm {
35 | connection gitUrl
36 | developerConnection gitUrl
37 | url siteUrl
38 | }
39 | }
40 | }
41 | }
42 | }
43 | task sourcesJar(type: Jar) {
44 | from android.sourceSets.main.java.srcDirs
45 | classifier = 'sources'
46 | }
47 | task javadoc(type: Javadoc) {
48 | options.encoding = 'UTF-8'
49 | source = 'src/main/java'
50 | }
51 |
52 | task javadocJar(type: Jar, dependsOn: javadoc) {
53 | classifier = 'javadoc'
54 | from javadoc.destinationDir
55 | }
56 | artifacts {
57 | archives javadocJar
58 | archives sourcesJar
59 | }
60 | Properties properties = new Properties()
61 | // 加载本地配置
62 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
63 | bintray {
64 | user = properties.getProperty("bintray.user")
65 | key = properties.getProperty("bintray.apikey")
66 | configurations = ['archives']
67 | pkg {
68 | repo = "Tools" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
69 | name = "PlayerBase" //发布到Bintray上的项目名字
70 | websiteUrl = siteUrl
71 | vcsUrl = gitUrl
72 | licenses = ["Apache-2.0"]
73 | publish = true
74 | }
75 | }
--------------------------------------------------------------------------------
/playerbase/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //apply from: 'bintray.gradle'
3 |
4 | android {
5 | compileSdkVersion 29
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | compileOptions{
20 | sourceCompatibility JavaVersion.VERSION_1_8
21 | targetCompatibility JavaVersion.VERSION_1_8
22 | }
23 | }
24 |
25 | lintOptions{
26 | abortOnError false
27 | }
28 |
29 | }
30 |
31 | buildscript {
32 | repositories {
33 | mavenCentral()
34 | google()
35 | }
36 | }
37 |
38 | dependencies {
39 | implementation fileTree(dir: 'libs', include: ['*.jar'])
40 |
41 | implementation "androidx.appcompat:appcompat:$appcompatVersion"
42 |
43 | }
--------------------------------------------------------------------------------
/playerbase/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/playerbase/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/assist/AssistPlay.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.assist;
18 |
19 | import android.view.ViewGroup;
20 |
21 | import com.kk.taurus.playerbase.entity.DataSource;
22 | import com.kk.taurus.playerbase.event.OnErrorEventListener;
23 | import com.kk.taurus.playerbase.event.OnPlayerEventListener;
24 | import com.kk.taurus.playerbase.provider.IDataProvider;
25 | import com.kk.taurus.playerbase.receiver.IReceiverGroup;
26 | import com.kk.taurus.playerbase.receiver.OnReceiverEventListener;
27 | import com.kk.taurus.playerbase.render.AspectRatio;
28 |
29 | /**
30 | *
31 | * Created by Taurus on 2018/5/21.
32 | *
33 | * The Association for auxiliary view containers and players
34 | *
35 | */
36 | public interface AssistPlay {
37 |
38 | void setOnPlayerEventListener(OnPlayerEventListener onPlayerEventListener);
39 | void setOnErrorEventListener(OnErrorEventListener onErrorEventListener);
40 | void setOnReceiverEventListener(OnReceiverEventListener onReceiverEventListener);
41 |
42 | void setOnProviderListener(IDataProvider.OnProviderListener onProviderListener);
43 | void setDataProvider(IDataProvider dataProvider);
44 | boolean switchDecoder(int decoderPlanId);
45 |
46 | void setRenderType(int renderType);
47 | void setAspectRatio(AspectRatio aspectRatio);
48 |
49 | void setVolume(float left, float right);
50 | void setSpeed(float speed);
51 | void setLooping(boolean looping);
52 |
53 | void setReceiverGroup(IReceiverGroup receiverGroup);
54 |
55 | void attachContainer(ViewGroup userContainer);
56 |
57 | void setDataSource(DataSource dataSource);
58 |
59 | void play();
60 | void play(boolean updateRender);
61 |
62 | boolean isInPlaybackState();
63 | boolean isPlaying();
64 | int getCurrentPosition();
65 | int getDuration();
66 | int getAudioSessionId();
67 | int getBufferPercentage();
68 | int getState();
69 |
70 | void rePlay(int msc);
71 |
72 | void pause();
73 | void resume();
74 | void seekTo(int msc);
75 | void stop();
76 | void reset();
77 | void destroy();
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/assist/BaseEventAssistHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.assist;
18 |
19 | import android.os.Bundle;
20 |
21 | /**
22 | * Created by Taurus on 2018/5/21.
23 | * @param
24 | */
25 | public abstract class BaseEventAssistHandler implements OnEventAssistHandler {
26 |
27 | @Override
28 | public void onAssistHandle(T assist, int eventCode, Bundle bundle) {
29 | switch (eventCode){
30 | case InterEvent.CODE_REQUEST_PAUSE:
31 | requestPause(assist, bundle);
32 | break;
33 | case InterEvent.CODE_REQUEST_RESUME:
34 | requestResume(assist, bundle);
35 | break;
36 | case InterEvent.CODE_REQUEST_SEEK:
37 | requestSeek(assist, bundle);
38 | break;
39 | case InterEvent.CODE_REQUEST_STOP:
40 | requestStop(assist, bundle);
41 | break;
42 | case InterEvent.CODE_REQUEST_RESET:
43 | requestReset(assist, bundle);
44 | break;
45 | case InterEvent.CODE_REQUEST_RETRY:
46 | requestRetry(assist, bundle);
47 | break;
48 | case InterEvent.CODE_REQUEST_REPLAY:
49 | requestReplay(assist, bundle);
50 | break;
51 | case InterEvent.CODE_REQUEST_PLAY_DATA_SOURCE:
52 | requestPlayDataSource(assist, bundle);
53 | break;
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/assist/InterEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.assist;
18 |
19 | /**
20 | * Created by Taurus on 2018/5/21.
21 | */
22 | public interface InterEvent {
23 |
24 | int CODE_REQUEST_PAUSE = -66001;
25 | int CODE_REQUEST_RESUME = -66003;
26 | int CODE_REQUEST_SEEK = -66005;
27 | int CODE_REQUEST_STOP = -66007;
28 | int CODE_REQUEST_RESET = -66009;
29 | int CODE_REQUEST_RETRY = -660011;
30 | int CODE_REQUEST_REPLAY = -66013;
31 | int CODE_REQUEST_PLAY_DATA_SOURCE = -66014;
32 | int CODE_REQUEST_NOTIFY_TIMER = -66015;
33 | int CODE_REQUEST_STOP_TIMER = -66016;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/assist/InterKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.assist;
18 |
19 | /**
20 | * Created by Taurus on 2018/5/21.
21 | */
22 | public interface InterKey {
23 |
24 | String KEY_NETWORK_STATE = "network_state";
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/assist/OnAssistPlayEventHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.assist;
18 |
19 | import android.os.Bundle;
20 |
21 | import com.kk.taurus.playerbase.entity.DataSource;
22 | import com.kk.taurus.playerbase.event.EventKey;
23 | import com.kk.taurus.playerbase.log.PLog;
24 |
25 | /**
26 | * Created by Taurus on 2018/5/21.
27 | */
28 | public class OnAssistPlayEventHandler extends BaseEventAssistHandler {
29 |
30 | @Override
31 | public void requestPause(AssistPlay assistPlay, Bundle bundle) {
32 | if(assistPlay.isInPlaybackState()){
33 | assistPlay.pause();
34 | }else{
35 | assistPlay.stop();
36 | assistPlay.reset();
37 | }
38 | }
39 |
40 | @Override
41 | public void requestResume(AssistPlay assistPlay, Bundle bundle) {
42 | if(assistPlay.isInPlaybackState()){
43 | assistPlay.resume();
44 | }else{
45 | requestRetry(assistPlay, bundle);
46 | }
47 | }
48 |
49 | @Override
50 | public void requestSeek(AssistPlay assistPlay, Bundle bundle) {
51 | int pos = 0;
52 | if(bundle!=null){
53 | pos = bundle.getInt(EventKey.INT_DATA);
54 | }
55 | assistPlay.seekTo(pos);
56 | }
57 |
58 | @Override
59 | public void requestStop(AssistPlay assistPlay, Bundle bundle) {
60 | assistPlay.stop();
61 | }
62 |
63 | @Override
64 | public void requestReset(AssistPlay assist, Bundle bundle) {
65 | assist.reset();
66 | }
67 |
68 | @Override
69 | public void requestRetry(AssistPlay assistPlay, Bundle bundle) {
70 | int pos = 0;
71 | if(bundle!=null){
72 | pos = bundle.getInt(EventKey.INT_DATA);
73 | }
74 | assistPlay.rePlay(pos);
75 | }
76 |
77 | @Override
78 | public void requestReplay(AssistPlay assistPlay, Bundle bundle) {
79 | assistPlay.rePlay(0);
80 | }
81 |
82 | @Override
83 | public void requestPlayDataSource(AssistPlay assist, Bundle bundle) {
84 | if(bundle!=null){
85 | DataSource data = (DataSource) bundle.getSerializable(EventKey.SERIALIZABLE_DATA);
86 | if(data==null){
87 | PLog.e("OnAssistPlayEventHandler","requestPlayDataSource need legal data source");
88 | return;
89 | }
90 | assist.stop();
91 | assist.setDataSource(data);
92 | assist.play();
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/assist/OnEventAssistHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.assist;
18 |
19 | import android.os.Bundle;
20 |
21 | /**
22 | *
23 | * Created by Taurus on 2018/5/21.
24 | *
25 | * This interface is used to handle the basic playback
26 | * operation event issued by the caller. Such as pause,
27 | * fast forward and other operations.
28 | *
29 | * @param Play master controller, maybe AVPlayer or AssistPlay or other packaging classes.
30 | *
31 | */
32 | public interface OnEventAssistHandler {
33 |
34 | void onAssistHandle(T assist, int eventCode, Bundle bundle);
35 |
36 | void requestPause(T assist, Bundle bundle);
37 | void requestResume(T assist, Bundle bundle);
38 | void requestSeek(T assist, Bundle bundle);
39 | void requestStop(T assist, Bundle bundle);
40 | void requestReset(T assist, Bundle bundle);
41 | void requestRetry(T assist, Bundle bundle);
42 | void requestReplay(T assist, Bundle bundle);
43 | void requestPlayDataSource(T assist, Bundle bundle);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/config/AppContextAttach.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.config;
18 |
19 | import android.content.Context;
20 | import android.util.Log;
21 |
22 | /**
23 | * if you want get app context, you need call attach method to init it.
24 | */
25 | public class AppContextAttach {
26 |
27 | private static Context mAppContext;
28 |
29 | static void attach(Context context){
30 | mAppContext = context.getApplicationContext();
31 | }
32 |
33 | public static Context getApplicationContext(){
34 | if(mAppContext==null){
35 | Log.e("AppContextAttach", "app context not init !!!");
36 | throw new RuntimeException("if you need context for using decoder, you must call PlayerLibrary.init(context).");
37 | }
38 | return mAppContext;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/config/PConst.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.config;
18 |
19 | public interface PConst {
20 |
21 | int NETWORK_STATE_CONNECTING = -2;
22 | int NETWORK_STATE_NONE = -1;
23 | int NETWORK_STATE_WIFI = 1;
24 | int NETWORK_STATE_2G = 2;
25 | int NETWORK_STATE_3G = 3;
26 | int NETWORK_STATE_4G = 4;
27 | int NETWORK_STATE_MOBILE_UNKNOWN = 5;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/config/PlayerLibrary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.config;
18 |
19 | import android.content.Context;
20 |
21 | public class PlayerLibrary {
22 |
23 | public static void init(Context context){
24 | AppContextAttach.attach(context);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/config/PlayerLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.config;
18 |
19 | import com.kk.taurus.playerbase.player.BaseInternalPlayer;
20 |
21 | import java.lang.reflect.Constructor;
22 |
23 | /**
24 | * Created by Taurus on 2018/3/17.
25 | *
26 | * The decoder instance loader is loaded
27 | * according to the decoding scheme you set.
28 | *
29 | */
30 |
31 | public class PlayerLoader {
32 |
33 | public static BaseInternalPlayer loadInternalPlayer(int decoderPlanId){
34 | BaseInternalPlayer internalPlayer = null;
35 | try {
36 | Object decoderInstance = getDecoderInstance(decoderPlanId);
37 | if(decoderInstance instanceof BaseInternalPlayer){
38 | internalPlayer = (BaseInternalPlayer) decoderInstance;
39 | }
40 | }catch (Exception e){
41 | e.printStackTrace();
42 | }
43 | return internalPlayer;
44 | }
45 |
46 | public static Object getDecoderInstance(int planId){
47 | Object instance = null;
48 | try{
49 | Class clz = getSDKClass(PlayerConfig.getPlan(planId).getClassPath());
50 | if(clz!=null){
51 | Constructor constructor = getConstructor(clz);
52 | if(constructor!=null){
53 | instance = constructor.newInstance();
54 | }
55 | }
56 | }catch (Exception e){
57 | e.printStackTrace();
58 | }
59 | return instance;
60 | }
61 |
62 | private static Constructor getConstructor(Class clz){
63 | Constructor result = null;
64 | try{
65 | result = clz.getConstructor();
66 | }catch (Exception e){
67 | e.printStackTrace();
68 | }
69 | return result;
70 | }
71 |
72 | private static Class getSDKClass(String classPath){
73 | Class result = null;
74 | try {
75 | result = Class.forName(classPath);
76 | } catch (ClassNotFoundException e) {
77 | e.printStackTrace();
78 | }
79 | return result;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/entity/DecoderPlan.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.entity;
18 |
19 | /**
20 | * Created by Taurus on 2018/3/17.
21 | *
22 | * The entity class of the decoder type.
23 | *
24 | */
25 |
26 | public class DecoderPlan {
27 |
28 | /**
29 | * Required field
30 | * It must be guaranteed that the number is unique.
31 | */
32 | private int idNumber;
33 |
34 | /**
35 | * Required field
36 | * it's decoder class reference path.
37 | */
38 | private String classPath;
39 |
40 | private String tag;
41 | private String desc;
42 |
43 | public DecoderPlan(int idNumber, String classPath) {
44 | this(idNumber, classPath, classPath);
45 | }
46 |
47 | public DecoderPlan(int idNumber, String classPath, String desc) {
48 | this.idNumber = idNumber;
49 | this.classPath = classPath;
50 | this.desc = desc;
51 | }
52 |
53 | public int getIdNumber() {
54 | return idNumber;
55 | }
56 |
57 | public void setIdNumber(int idNumber) {
58 | this.idNumber = idNumber;
59 | }
60 |
61 | public String getTag() {
62 | return tag;
63 | }
64 |
65 | public void setTag(String tag) {
66 | this.tag = tag;
67 | }
68 |
69 | public String getClassPath() {
70 | return classPath;
71 | }
72 |
73 | public void setClassPath(String classPath) {
74 | this.classPath = classPath;
75 | }
76 |
77 | public String getDesc() {
78 | return desc;
79 | }
80 |
81 | public void setDesc(String desc) {
82 | this.desc = desc;
83 | }
84 |
85 | @Override
86 | public String toString() {
87 | return "id = " + idNumber +
88 | ", classPath = " + classPath +
89 | ", desc = " + desc;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/entity/TimedTextSource.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by Taurus on 2018/12/11.
7 | */
8 | public class TimedTextSource implements Serializable {
9 |
10 | private String path;
11 | private String mimeType;
12 | private int flag;
13 |
14 | public TimedTextSource(String path) {
15 | this.path = path;
16 | }
17 |
18 | public TimedTextSource(String path, String mimeType) {
19 | this.path = path;
20 | this.mimeType = mimeType;
21 | }
22 |
23 | public TimedTextSource(String path, String mimeType, int flag) {
24 | this.path = path;
25 | this.mimeType = mimeType;
26 | this.flag = flag;
27 | }
28 |
29 | public String getPath() {
30 | return path;
31 | }
32 |
33 | public void setPath(String path) {
34 | this.path = path;
35 | }
36 |
37 | public String getMimeType() {
38 | return mimeType;
39 | }
40 |
41 | public void setMimeType(String mimeType) {
42 | this.mimeType = mimeType;
43 | }
44 |
45 | public int getFlag() {
46 | return flag;
47 | }
48 |
49 | public void setFlag(int flag) {
50 | this.flag = flag;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/event/BundlePool.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.event;
18 |
19 | import android.os.Bundle;
20 |
21 | import com.kk.taurus.playerbase.log.PLog;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | /**
27 | * Created by Taurus on 2018/3/17.
28 | *
29 | * In order to improve memory performance,
30 | * the bundle entities passed in the framework
31 | * come from the bundle buffer pool.
32 | *
33 | */
34 |
35 | public class BundlePool {
36 |
37 | private static final int POOL_SIZE = 3;
38 |
39 | private static List mPool;
40 |
41 | static {
42 | mPool = new ArrayList<>();
43 | for(int i=0;i");
54 | return new Bundle();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/event/EventKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.event;
18 |
19 | /**
20 | * Created by Taurus on 2018/3/17.
21 | */
22 |
23 | public interface EventKey {
24 |
25 | String BYTE_DATA = "byte_data";
26 | String INT_DATA = "int_data";
27 | String BOOL_DATA = "bool_data";
28 | String FLOAT_DATA = "float_data";
29 | String LONG_DATA = "long_data";
30 | String DOUBLE_DATA = "double_data";
31 | String STRING_DATA = "string_data";
32 |
33 | String SERIALIZABLE_DATA = "serializable_data";
34 | String SERIALIZABLE_EXTRA_DATA = "serializable_extra_data";
35 |
36 | String INT_ARG1 = "int_arg1";
37 | String INT_ARG2 = "int_arg2";
38 | String INT_ARG3 = "int_arg3";
39 | String INT_ARG4 = "int_arg4";
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/event/IEventDispatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.event;
18 |
19 | import android.os.Bundle;
20 | import android.view.MotionEvent;
21 |
22 | import com.kk.taurus.playerbase.receiver.IReceiverGroup;
23 |
24 | /**
25 | * Created by Taurus on 2018/4/15.
26 | */
27 |
28 | public interface IEventDispatcher {
29 | void dispatchPlayEvent(int eventCode, Bundle bundle);
30 | void dispatchErrorEvent(int eventCode, Bundle bundle);
31 | void dispatchReceiverEvent(int eventCode, Bundle bundle);
32 | void dispatchReceiverEvent(int eventCode, Bundle bundle, IReceiverGroup.OnReceiverFilter onReceiverFilter);
33 | void dispatchProducerEvent(int eventCode, Bundle bundle, IReceiverGroup.OnReceiverFilter onReceiverFilter);
34 | void dispatchProducerData(String key, Object data, IReceiverGroup.OnReceiverFilter onReceiverFilter);
35 |
36 |
37 | void dispatchTouchEventOnSingleTapConfirmed(MotionEvent event);
38 | void dispatchTouchEventOnLongPress(MotionEvent event);
39 | void dispatchTouchEventOnDoubleTabUp(MotionEvent event);
40 | void dispatchTouchEventOnDown(MotionEvent event);
41 | void dispatchTouchEventOnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
42 | void dispatchTouchEventOnEndGesture();
43 | }
44 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/event/OnErrorEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.event;
18 |
19 | import android.os.Bundle;
20 |
21 | /**
22 | * Created by Taurus on 2018/3/17.
23 | */
24 |
25 | public interface OnErrorEventListener {
26 |
27 | int ERROR_EVENT_DATA_PROVIDER_ERROR = -88000;
28 |
29 | //A error that causes a play to terminate
30 | int ERROR_EVENT_RENDER = -88010;
31 |
32 | int ERROR_EVENT_COMMON = -88011;
33 |
34 | int ERROR_EVENT_UNKNOWN = -88012;
35 |
36 | int ERROR_EVENT_SERVER_DIED = -88013;
37 |
38 | int ERROR_EVENT_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = -88014;
39 |
40 | int ERROR_EVENT_IO = -88015;
41 |
42 | int ERROR_EVENT_MALFORMED = -88016;
43 |
44 | int ERROR_EVENT_UNSUPPORTED = -88017;
45 |
46 | int ERROR_EVENT_TIMED_OUT = -88018;
47 |
48 | int ERROR_EVENT_OUT_OF_MEMORY = -88019;
49 |
50 | int ERROR_EVENT_REMOTE = -88020;
51 |
52 | void onErrorEvent(int eventCode, Bundle bundle);
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/extension/BaseEventProducer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.extension;
18 |
19 | import androidx.annotation.Nullable;
20 |
21 | import com.kk.taurus.playerbase.receiver.PlayerStateGetter;
22 | import com.kk.taurus.playerbase.receiver.StateGetter;
23 |
24 | /**
25 | *
26 | * Created by Taurus on 2018/5/27.
27 | *
28 | */
29 | public abstract class BaseEventProducer implements EventProducer {
30 |
31 | private ReceiverEventSender mReceiverEventSender;
32 | private StateGetter mStateGetter;
33 |
34 | void attachSender(ReceiverEventSender receiverEventSender){
35 | this.mReceiverEventSender = receiverEventSender;
36 | }
37 |
38 | void attachStateGetter(StateGetter stateGetter){
39 | this.mStateGetter = stateGetter;
40 | }
41 |
42 | @Override
43 | public final PlayerStateGetter getPlayerStateGetter() {
44 | if(mStateGetter!=null)
45 | return mStateGetter.getPlayerStateGetter();
46 | return null;
47 | }
48 |
49 | @Override
50 | public final ReceiverEventSender getSender() {
51 | return mReceiverEventSender;
52 | }
53 |
54 | @Nullable
55 | protected EventCallback getEventCallback() {
56 | return null;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/extension/DelegateReceiverEventSender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.extension;
18 |
19 | import android.os.Bundle;
20 |
21 | import com.kk.taurus.playerbase.receiver.IReceiverGroup;
22 |
23 | /**
24 | *
25 | * Created by Taurus on 2018/5/27.
26 | *
27 | */
28 | public interface DelegateReceiverEventSender {
29 |
30 | void sendEvent(int eventCode, Bundle bundle, IReceiverGroup.OnReceiverFilter receiverFilter);
31 |
32 | void sendObject(String key, Object value, IReceiverGroup.OnReceiverFilter receiverFilter);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/extension/EventCallback.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.extension;
2 |
3 | import android.os.Bundle;
4 |
5 | /**
6 | * @ClassName EventCallback
7 | * @Description
8 | * @Author Taurus
9 | * @Date 2020/9/6 6:16 PM
10 | */
11 | public interface EventCallback {
12 |
13 | void onPlayerEvent(int eventCode, Bundle data);
14 |
15 | void onErrorEvent(int eventCode, Bundle data);
16 |
17 | void onReceiverEvent(int eventCode, Bundle data);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/extension/EventProducer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.extension;
18 |
19 | import androidx.annotation.Nullable;
20 |
21 | import com.kk.taurus.playerbase.receiver.PlayerStateGetter;
22 |
23 | /**
24 | *
25 | * Created by Taurus on 2018/5/27.
26 | *
27 | * The producer of the event. It is usually added by the users themselves,
28 | * such as the system's power change events or network change events.
29 | * The framework adds the network change event producer by default.
30 | *
31 | */
32 | public interface EventProducer {
33 |
34 | void onAdded();
35 |
36 | void onRemoved();
37 |
38 | PlayerStateGetter getPlayerStateGetter();
39 |
40 | @Nullable ReceiverEventSender getSender();
41 |
42 | void destroy();
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/extension/IProducerGroup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.extension;
18 |
19 | import androidx.annotation.NonNull;
20 |
21 | import com.kk.taurus.playerbase.receiver.StateGetter;
22 |
23 | /**
24 | *
25 | * Created by Taurus on 2018/5/27.
26 | *
27 | * To manage multiple event producers
28 | *
29 | */
30 | public interface IProducerGroup {
31 |
32 | void addEventProducer(BaseEventProducer eventProducer);
33 |
34 | boolean removeEventProducer(BaseEventProducer eventProducer);
35 |
36 | void bindStateGetter(StateGetter stateGetter);
37 |
38 | @NonNull EventCallback getEventCallback();
39 |
40 | void destroy();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/extension/ReceiverEventSender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.extension;
18 |
19 | import android.os.Bundle;
20 |
21 | import com.kk.taurus.playerbase.receiver.IReceiverGroup;
22 |
23 | public interface ReceiverEventSender {
24 |
25 | void sendEvent(int eventCode, Bundle bundle);
26 | void sendEvent(int eventCode, Bundle bundle, IReceiverGroup.OnReceiverFilter receiverFilter);
27 |
28 | void sendBoolean(String key, boolean value);
29 | void sendBoolean(String key, boolean value, IReceiverGroup.OnReceiverFilter receiverFilter);
30 |
31 | void sendInt(String key, int value);
32 | void sendInt(String key, int value, IReceiverGroup.OnReceiverFilter receiverFilter);
33 |
34 | void sendString(String key, String value);
35 | void sendString(String key, String value, IReceiverGroup.OnReceiverFilter receiverFilter);
36 |
37 | void sendFloat(String key, float value);
38 | void sendFloat(String key, float value, IReceiverGroup.OnReceiverFilter receiverFilter);
39 |
40 | void sendLong(String key, long value);
41 | void sendLong(String key, long value, IReceiverGroup.OnReceiverFilter receiverFilter);
42 |
43 | void sendDouble(String key, double value);
44 | void sendDouble(String key, double value, IReceiverGroup.OnReceiverFilter receiverFilter);
45 |
46 | void sendObject(String key, Object value);
47 | void sendObject(String key, Object value, IReceiverGroup.OnReceiverFilter receiverFilter);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/log/PLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.log;
18 |
19 | import android.util.Log;
20 |
21 | /**
22 | * Created by Taurus on 2018/3/17.
23 | */
24 |
25 | public class PLog {
26 |
27 | public static boolean LOG_OPEN = false;
28 |
29 | public static void d(String tag, String message){
30 | if(!LOG_OPEN)
31 | return;
32 | Log.d(tag,message);
33 | }
34 |
35 | public static void w(String tag, String message){
36 | if(!LOG_OPEN)
37 | return;
38 | Log.w(tag,message);
39 | }
40 |
41 | public static void e(String tag, String message){
42 | if(!LOG_OPEN)
43 | return;
44 | Log.e(tag,message);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/player/IPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.player;
18 |
19 | import android.os.Bundle;
20 | import android.view.Surface;
21 | import android.view.SurfaceHolder;
22 |
23 | import com.kk.taurus.playerbase.entity.DataSource;
24 | import com.kk.taurus.playerbase.event.OnErrorEventListener;
25 | import com.kk.taurus.playerbase.event.OnPlayerEventListener;
26 |
27 | /**
28 | * Created by Taurus on 2018/3/17.
29 | */
30 |
31 | public interface IPlayer {
32 |
33 | int STATE_END = -2;
34 | int STATE_ERROR = -1;
35 | int STATE_IDLE = 0;
36 | int STATE_INITIALIZED = 1;
37 | int STATE_PREPARED = 2;
38 | int STATE_STARTED = 3;
39 | int STATE_PAUSED = 4;
40 | int STATE_STOPPED = 5;
41 | int STATE_PLAYBACK_COMPLETE = 6;
42 |
43 | /**
44 | * with this method, you can send some params for player init or switch some setting.
45 | * such as some configuration option (use mediacodec or timeout or reconnect and so on) for decoder init.
46 | * @param code the code value custom yourself.
47 | * @param bundle deliver some data if you need.
48 | */
49 | void option(int code, Bundle bundle);
50 |
51 | void setDataSource(DataSource dataSource);
52 | void setDisplay(SurfaceHolder surfaceHolder);
53 | void setSurface(Surface surface);
54 | void setVolume(float left, float right);
55 | void setSpeed(float speed);
56 | void setLooping(boolean looping);
57 |
58 | void setOnPlayerEventListener(OnPlayerEventListener onPlayerEventListener);
59 | void setOnErrorEventListener(OnErrorEventListener onErrorEventListener);
60 |
61 | void setOnBufferingListener(OnBufferingListener onBufferingListener);
62 |
63 | int getBufferPercentage();
64 |
65 | boolean isPlaying();
66 | int getCurrentPosition();
67 | int getDuration();
68 | int getAudioSessionId();
69 | int getVideoWidth();
70 | int getVideoHeight();
71 | int getState();
72 |
73 | void start();
74 | void start(int msc);
75 | void pause();
76 | void resume();
77 | void seekTo(int msc);
78 | void stop();
79 | void reset();
80 | void destroy();
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/player/IPlayerProxy.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.player;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.kk.taurus.playerbase.entity.DataSource;
6 |
7 | /**
8 | * Created by Taurus on 2018/12/12.
9 | */
10 | public interface IPlayerProxy {
11 |
12 | void onDataSourceReady(DataSource dataSource);
13 |
14 | void onIntentStop();
15 |
16 | void onIntentReset();
17 |
18 | void onIntentDestroy();
19 |
20 | void onPlayerEvent(int eventCode, Bundle bundle);
21 |
22 | void onErrorEvent(int eventCode, Bundle bundle);
23 |
24 | int getRecord(DataSource dataSource);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/player/OnBufferingListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.player;
18 |
19 | import android.os.Bundle;
20 |
21 | /**
22 | *
23 | * on decoder buffering update call back.
24 | *
25 | * Created by Taurus on 2018/6/14.
26 | */
27 | public interface OnBufferingListener {
28 |
29 | void onBufferingUpdate(int bufferPercentage, Bundle extra);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/player/OnTimerUpdateListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.player;
18 |
19 | import com.kk.taurus.playerbase.AVPlayer;
20 |
21 | /**
22 | * Created by Taurus on 2018/4/15.
23 | *
24 | * in AVPlayer default open timer proxy, you can use update callback to refresh UI.
25 | * if you close timer proxy{@link AVPlayer#setUseTimerProxy(boolean)},
26 | * you will not receive this timer update callback.
27 | * if timer open , the call back called per second.
28 | * in some scene, you can close it to improve battery performance.
29 | *
30 | */
31 | public interface OnTimerUpdateListener {
32 | void onTimerUpdate(int curr, int duration, int bufferPercentage);
33 | }
34 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/provider/IDataProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.provider;
18 |
19 | import android.os.Bundle;
20 |
21 | import com.kk.taurus.playerbase.entity.DataSource;
22 |
23 | /**
24 | * Created by Taurus on 2018/3/17.
25 | *
26 | * Data providers are designed for special needs.
27 | * For example, if you need to take a id to get the playback address,then play it.
28 | * In this case, the process can be independent of a data provider.
29 | *
30 | */
31 |
32 | public interface IDataProvider {
33 |
34 | int PROVIDER_CODE_SUCCESS_MEDIA_DATA = -77001;
35 |
36 | int PROVIDER_CODE_DATA_PROVIDER_ERROR = -77003;
37 |
38 | void setOnProviderListener(OnProviderListener onProviderListener);
39 |
40 | /**
41 | * the provider handle data source, Users usually need to be implemented
42 | * @param sourceData
43 | */
44 | void handleSourceData(DataSource sourceData);
45 |
46 | /**
47 | * cancel the DataProvider handle data source.
48 | */
49 | void cancel();
50 |
51 | /**
52 | * destroy the provider.
53 | */
54 | void destroy();
55 |
56 |
57 | interface OnProviderListener{
58 | /**
59 | * on provider start load data
60 | */
61 | void onProviderDataStart();
62 |
63 | /**
64 | * on provider load data success
65 | * @param code
66 | * @param bundle you can set some data to bundle
67 | */
68 | void onProviderDataSuccess(int code, Bundle bundle);
69 |
70 | /**
71 | * on provider load data error
72 | * @param code
73 | * @param bundle
74 | */
75 | void onProviderError(int code, Bundle bundle);
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/BaseLevelCoverContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import android.content.Context;
20 | import android.graphics.Color;
21 | import android.view.ViewGroup;
22 | import android.widget.FrameLayout;
23 |
24 | import com.kk.taurus.playerbase.log.PLog;
25 |
26 |
27 | /**
28 | * Created by Taurus on 2017/4/29.
29 | */
30 |
31 | public abstract class BaseLevelCoverContainer extends AbsCoverContainer {
32 |
33 | private final String TAG = "base_cover_container";
34 |
35 | public BaseLevelCoverContainer(Context context) {
36 | super(context);
37 | initLevelContainers(context);
38 | }
39 |
40 | @Override
41 | protected void onCoverAdd(BaseCover cover) {
42 |
43 | }
44 |
45 | @Override
46 | protected void onAvailableCoverAdd(BaseCover cover) {
47 | PLog.d(TAG,"on available cover add : now count = " + getCoverCount());
48 | }
49 |
50 | @Override
51 | protected void onCoverRemove(BaseCover cover) {
52 | PLog.d(TAG,"on cover remove : now count = " + getCoverCount());
53 |
54 | }
55 |
56 | @Override
57 | protected void onAvailableCoverRemove(BaseCover cover) {
58 |
59 | }
60 |
61 | @Override
62 | protected void onCoversRemoveAll() {
63 | PLog.d(TAG,"on covers remove all ...");
64 |
65 | }
66 |
67 | @Override
68 | protected ViewGroup initContainerRootView() {
69 | FrameLayout root = new FrameLayout(mContext);
70 | root.setBackgroundColor(Color.TRANSPARENT);
71 | return root;
72 | }
73 |
74 | protected abstract void initLevelContainers(Context context);
75 |
76 | protected void addLevelContainerView(ViewGroup container, ViewGroup.LayoutParams layoutParams){
77 | if(getContainerView()!=null){
78 | if(layoutParams==null)
79 | layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
80 | getContainerView().addView(container,layoutParams);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/CoverComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import java.util.Comparator;
20 |
21 | public class CoverComparator implements Comparator {
22 | @Override
23 | public int compare(IReceiver o1, IReceiver o2) {
24 | int x = 0;
25 | int y = 0;
26 | if(o1 instanceof BaseCover){
27 | x = ((BaseCover) o1).getCoverLevel();
28 | }
29 | if(o2 instanceof BaseCover){
30 | y = ((BaseCover) o2).getCoverLevel();
31 | }
32 | return (x < y) ? -1 : ((x == y) ? 0 : 1);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/ICover.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import android.view.View;
20 |
21 | /**
22 | * Created by Taurus on 2017/3/24.
23 | */
24 |
25 | public interface ICover {
26 |
27 | //the max cover priority value per level container.
28 | int LEVEL_MAX = 1 << 5;
29 |
30 | //level low container start value.
31 | int COVER_LEVEL_LOW = 0;
32 |
33 | //level medium container start value.
34 | int COVER_LEVEL_MEDIUM = 1 << 5;
35 |
36 | //level high container start value.
37 | int COVER_LEVEL_HIGH = 1 << 6;
38 |
39 | void setCoverVisibility(int visibility);
40 | View getView();
41 | int getCoverLevel();
42 | }
43 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/ICoverHandle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import android.os.Bundle;
20 |
21 | public interface ICoverHandle {
22 |
23 | void requestPause(Bundle bundle);
24 | void requestResume(Bundle bundle);
25 | void requestSeek(Bundle bundle);
26 | void requestStop(Bundle bundle);
27 | void requestReset(Bundle bundle);
28 | void requestRetry(Bundle bundle);
29 | void requestReplay(Bundle bundle);
30 | void requestPlayDataSource(Bundle bundle);
31 |
32 | void requestNotifyTimer();
33 | void requestStopTimer();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/ICoverStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import android.view.ViewGroup;
20 |
21 | /**
22 | * Created by Taurus on 2018/3/17.
23 | */
24 |
25 | public interface ICoverStrategy {
26 |
27 | void addCover(BaseCover cover);
28 | void removeCover(BaseCover cover);
29 | void removeAllCovers();
30 | boolean isContainsCover(BaseCover cover);
31 | int getCoverCount();
32 | ViewGroup getContainerView();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/IReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import android.os.Bundle;
20 | import androidx.annotation.NonNull;
21 | import androidx.annotation.Nullable;
22 |
23 | /**
24 | * Created by Taurus on 2018/3/17.
25 | */
26 |
27 | public interface IReceiver {
28 |
29 | /**
30 | * bind host group.
31 | * @param receiverGroup
32 | */
33 | void bindGroup(@NonNull IReceiverGroup receiverGroup);
34 |
35 | /**
36 | * on receiver added to ReceiverGroup.
37 | */
38 | void onReceiverBind();
39 |
40 | /**
41 | * all player event dispatch by this method.
42 | * @param eventCode
43 | * @param bundle
44 | */
45 | void onPlayerEvent(int eventCode, Bundle bundle);
46 |
47 | /**
48 | * error event.
49 | * @param eventCode
50 | * @param bundle
51 | */
52 | void onErrorEvent(int eventCode, Bundle bundle);
53 |
54 | /**
55 | * bind a state getter.
56 | * @param stateGetter
57 | */
58 | void bindStateGetter(StateGetter stateGetter);
59 |
60 | /**
61 | * bind the bridge of receivers communication
62 | * @param onReceiverEventListener
63 | */
64 | void bindReceiverEventListener(OnReceiverEventListener onReceiverEventListener);
65 |
66 | /**
67 | * receivers event.
68 | * @param eventCode
69 | * @param bundle
70 | */
71 | void onReceiverEvent(int eventCode, Bundle bundle);
72 |
73 | /**
74 | * you can call this method dispatch private event.
75 | *
76 | * @param eventCode
77 | * @param bundle
78 | *
79 | * @return Bundle Return value after the receiver's response, nullable.
80 | */
81 | @Nullable
82 | Bundle onPrivateEvent(int eventCode, Bundle bundle);
83 |
84 | /**
85 | * producer event call back this method
86 | * @param eventCode
87 | * @param bundle
88 | */
89 | void onProducerEvent(int eventCode, Bundle bundle);
90 |
91 | /**
92 | * producer data call back this method
93 | * @param key
94 | * @param data
95 | */
96 | void onProducerData(String key, Object data);
97 |
98 | /**
99 | * on receiver destroy.
100 | * when receiver removed, this method will be callback.
101 | */
102 | void onReceiverUnBind();
103 |
104 | /**
105 | * get the receiver key, when add receiver the key set it.
106 | * @return
107 | */
108 | String getKey();
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/OnReceiverEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import android.os.Bundle;
20 |
21 | /**
22 | * Created by Taurus on 2018/4/15.
23 | */
24 |
25 | public interface OnReceiverEventListener {
26 | void onReceiverEvent(int eventCode, Bundle bundle);
27 | }
28 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/PlayerStateGetter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | import com.kk.taurus.playerbase.player.IPlayer;
20 |
21 | /**
22 | *
23 | * player state getter for Receivers.
24 | *
25 | * Created by Taurus on 2018/6/8.
26 | *
27 | */
28 | public interface PlayerStateGetter {
29 |
30 | /**
31 | * get player state code.
32 | *
33 | * See also
34 | * {@link IPlayer#STATE_END}
35 | * {@link IPlayer#STATE_ERROR}
36 | * {@link IPlayer#STATE_IDLE}
37 | * {@link IPlayer#STATE_INITIALIZED}
38 | * {@link IPlayer#STATE_PREPARED}
39 | * {@link IPlayer#STATE_STARTED}
40 | * {@link IPlayer#STATE_PAUSED}
41 | * {@link IPlayer#STATE_STOPPED}
42 | * {@link IPlayer#STATE_PLAYBACK_COMPLETE}
43 | *
44 | * @return state
45 | */
46 | int getState();
47 |
48 | /**
49 | * get player current play progress.
50 | * @return
51 | */
52 | int getCurrentPosition();
53 |
54 | /**
55 | * get video duration
56 | * @return
57 | */
58 | int getDuration();
59 |
60 | /**
61 | * get player buffering percentage.
62 | * @return
63 | */
64 | int getBufferPercentage();
65 |
66 | /**
67 | * the player is in buffering.
68 | * @return
69 | */
70 | boolean isBuffering();
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/StateGetter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | /**
20 | * the state getter for receivers, because receivers dynamic attach,
21 | * maybe you need get some state on attach.
22 | *
23 | * Created by Taurus on 2018/6/8.
24 | *
25 | */
26 | public interface StateGetter {
27 |
28 | PlayerStateGetter getPlayerStateGetter();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/receiver/ValueInter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.receiver;
18 |
19 | interface ValueInter {
20 |
21 | void putBoolean(String key, boolean value);
22 | void putBoolean(String key, boolean value, boolean notifyUpdate);
23 |
24 | void putInt(String key, int value);
25 | void putInt(String key, int value, boolean notifyUpdate);
26 |
27 | void putString(String key, String value);
28 | void putString(String key, String value, boolean notifyUpdate);
29 |
30 | void putFloat(String key, float value);
31 | void putFloat(String key, float value, boolean notifyUpdate);
32 |
33 | void putLong(String key, long value);
34 | void putLong(String key, long value, boolean notifyUpdate);
35 |
36 | void putDouble(String key, double value);
37 | void putDouble(String key, double value, boolean notifyUpdate);
38 |
39 | void putObject(String key, Object value);
40 | void putObject(String key, Object value, boolean notifyUpdate);
41 |
42 |
43 |
44 | T get(String key);
45 |
46 | boolean getBoolean(String key);
47 | boolean getBoolean(String key, boolean defaultValue);
48 |
49 | int getInt(String key);
50 | int getInt(String key, int defaultValue);
51 |
52 | String getString(String key);
53 |
54 | float getFloat(String key);
55 | float getFloat(String key, float defaultValue);
56 |
57 | long getLong(String key);
58 | long getLong(String key, long defaultValue);
59 |
60 | double getDouble(String key);
61 | double getDouble(String key, double defaultValue);
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/DefaultRecordKeyProvider.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import android.net.Uri;
4 | import android.text.TextUtils;
5 |
6 | import com.kk.taurus.playerbase.entity.DataSource;
7 |
8 | /**
9 | * Created by Taurus on 2018/12/12.
10 | */
11 | public class DefaultRecordKeyProvider implements RecordKeyProvider {
12 |
13 | @Override
14 | public String generatorKey(DataSource dataSource) {
15 | String data = dataSource.getData();
16 | Uri uri = dataSource.getUri();
17 | String assetsPath = dataSource.getAssetsPath();
18 | int rawId = dataSource.getRawId();
19 | if(!TextUtils.isEmpty(data)){
20 | return data;
21 | }else if(uri!=null){
22 | return uri.toString();
23 | }else if(!TextUtils.isEmpty(assetsPath)){
24 | return assetsPath;
25 | }else if(rawId > 0){
26 | return String.valueOf(rawId);
27 | }
28 | return dataSource.toString();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/OnRecordCallBack.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import com.kk.taurus.playerbase.entity.DataSource;
4 |
5 | /**
6 | * Created by Taurus on 2018/12/12.
7 | *
8 | * if you want to custom save record, you can set it.
9 | *
10 | */
11 | public interface OnRecordCallBack {
12 |
13 | int onSaveRecord(DataSource dataSource, int record);
14 |
15 | int onGetRecord(DataSource dataSource);
16 |
17 | int onResetRecord(DataSource dataSource);
18 |
19 | int onRemoveRecord(DataSource dataSource);
20 |
21 | void onClearRecord();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/PlayRecord.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import com.kk.taurus.playerbase.entity.DataSource;
4 | import com.kk.taurus.playerbase.log.PLog;
5 |
6 | /**
7 | * Created by Taurus on 2018/12/12.
8 | */
9 | class PlayRecord {
10 |
11 | private final String TAG = "PlayRecord";
12 | private static PlayRecord i;
13 |
14 | private RecordInvoker mRecordInvoker;
15 |
16 | private PlayRecord(){
17 | mRecordInvoker = new RecordInvoker(PlayRecordManager.getConfig());
18 | }
19 |
20 | public static PlayRecord get(){
21 | if(null==i){
22 | synchronized (PlayRecord.class){
23 | if(null==i){
24 | i = new PlayRecord();
25 | }
26 | }
27 | }
28 | return i;
29 | }
30 |
31 | public int record(DataSource data, int record){
32 | if(data==null)
33 | return -1;
34 | int saveRecord = mRecordInvoker.saveRecord(data, record);
35 | PLog.d(TAG,"<> : record = " + record);
36 | return saveRecord;
37 | }
38 |
39 | public int reset(DataSource data){
40 | if(data==null)
41 | return -1;
42 | return mRecordInvoker.resetRecord(data);
43 | }
44 |
45 | public int removeRecord(DataSource data){
46 | if(data==null)
47 | return -1;
48 | return mRecordInvoker.removeRecord(data);
49 | }
50 |
51 | public int getRecord(DataSource data){
52 | if(data==null)
53 | return 0;
54 | int record = mRecordInvoker.getRecord(data);
55 | PLog.d(TAG,"<> : record = " + record);
56 | return record;
57 | }
58 |
59 | public void clearRecord(){
60 | mRecordInvoker.clearRecord();
61 | }
62 |
63 | public void destroy(){
64 | clearRecord();
65 | i = null;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/PlayValueGetter.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | /**
4 | * Created by Taurus on 2018/12/12.
5 | */
6 | public interface PlayValueGetter {
7 |
8 | int getCurrentPosition();
9 |
10 | int getBufferPercentage();
11 |
12 | int getDuration();
13 |
14 | int getState();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/RecordCache.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import android.util.LruCache;
4 |
5 | /**
6 | * Created by Taurus on 2018/12/12.
7 | *
8 | * play position memory record, use LruCache.
9 | *
10 | */
11 | public class RecordCache {
12 |
13 | private LruCache mLruCache;
14 |
15 | public RecordCache(int maxCacheCount){
16 | mLruCache = new LruCache(maxCacheCount * 4){
17 | @Override
18 | protected int sizeOf(String key, Integer value) {
19 | return 4;
20 | }
21 | };
22 | }
23 |
24 | public int putRecord(String key, int record){
25 | Integer put = mLruCache.put(key, record);
26 | return put!=null?put:-1;
27 | }
28 |
29 | public int removeRecord(String key){
30 | Integer remove = mLruCache.remove(key);
31 | return remove!=null?remove:-1;
32 | }
33 |
34 | public int getRecord(String key){
35 | Integer integer = mLruCache.get(key);
36 | return integer!=null?integer:0;
37 | }
38 |
39 | public void clearRecord(){
40 | mLruCache.evictAll();
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/RecordInvoker.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import com.kk.taurus.playerbase.entity.DataSource;
4 |
5 | /**
6 | * Created by Taurus on 2018/12/12.
7 | */
8 | public class RecordInvoker {
9 |
10 | private OnRecordCallBack mCallBack;
11 |
12 | private RecordCache mRecordCache;
13 |
14 | public RecordInvoker(PlayRecordManager.RecordConfig config){
15 | this.mCallBack = config.getOnRecordCallBack();
16 | mRecordCache = new RecordCache(config.getMaxRecordCount());
17 | }
18 |
19 | public int saveRecord(DataSource dataSource, int record) {
20 | if(mCallBack!=null){
21 | return mCallBack.onSaveRecord(dataSource, record);
22 | }
23 | return mRecordCache.putRecord(getKey(dataSource), record);
24 | }
25 |
26 | public int getRecord(DataSource dataSource) {
27 | if(mCallBack!=null){
28 | return mCallBack.onGetRecord(dataSource);
29 | }
30 | return mRecordCache.getRecord(getKey(dataSource));
31 | }
32 |
33 | public int resetRecord(DataSource dataSource) {
34 | if(mCallBack!=null){
35 | return mCallBack.onResetRecord(dataSource);
36 | }
37 | return mRecordCache.putRecord(getKey(dataSource), 0);
38 | }
39 |
40 | public int removeRecord(DataSource dataSource) {
41 | if(mCallBack!=null){
42 | return mCallBack.onRemoveRecord(dataSource);
43 | }
44 | return mRecordCache.removeRecord(getKey(dataSource));
45 | }
46 |
47 | public void clearRecord() {
48 | if(mCallBack!=null){
49 | mCallBack.onClearRecord();
50 | return;
51 | }
52 | mRecordCache.clearRecord();
53 | }
54 |
55 | String getKey(DataSource dataSource){
56 | return PlayRecordManager.getKey(dataSource);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/RecordKeyProvider.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import com.kk.taurus.playerbase.entity.DataSource;
4 |
5 | /**
6 | * Created by Taurus on 2018/12/12.
7 | */
8 | public interface RecordKeyProvider {
9 |
10 | String generatorKey(DataSource dataSource);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/record/RecordProxyPlayer.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.record;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.kk.taurus.playerbase.entity.DataSource;
6 | import com.kk.taurus.playerbase.event.OnPlayerEventListener;
7 | import com.kk.taurus.playerbase.player.IPlayer;
8 | import com.kk.taurus.playerbase.player.IPlayerProxy;
9 |
10 | /**
11 | * Created by Taurus on 2018/12/12.
12 | */
13 | public class RecordProxyPlayer implements IPlayerProxy {
14 |
15 | private PlayValueGetter mPlayValueGetter;
16 |
17 | private DataSource mDataSource;
18 |
19 | public RecordProxyPlayer(PlayValueGetter valueGetter){
20 | this.mPlayValueGetter = valueGetter;
21 | }
22 |
23 | @Override
24 | public void onDataSourceReady(DataSource dataSource) {
25 | //right now change DataSource, record it.
26 | record();
27 | mDataSource = dataSource;
28 | }
29 |
30 | @Override
31 | public void onIntentStop() {
32 | record();
33 | }
34 |
35 | @Override
36 | public void onIntentReset() {
37 | record();
38 | }
39 |
40 | @Override
41 | public void onIntentDestroy() {
42 | record();
43 | }
44 |
45 | @Override
46 | public void onPlayerEvent(int eventCode, Bundle bundle) {
47 | switch (eventCode){
48 | case OnPlayerEventListener.PLAYER_EVENT_ON_PAUSE:
49 | //on pause, record play position.
50 | record();
51 | break;
52 | case OnPlayerEventListener.PLAYER_EVENT_ON_PLAY_COMPLETE:
53 | //on play complete, reset play record.
54 | PlayRecord.get().reset(mDataSource);
55 | break;
56 | }
57 | }
58 |
59 | private void record(){
60 | if(isInPlaybackState() && getState()!=IPlayer.STATE_PLAYBACK_COMPLETE){
61 | PlayRecord.get().record(mDataSource, getCurrentPosition());
62 | }
63 | }
64 |
65 | private int getCurrentPosition(){
66 | if(mPlayValueGetter!=null)
67 | return mPlayValueGetter.getCurrentPosition();
68 | return 0;
69 | }
70 |
71 | private int getState(){
72 | return mPlayValueGetter!=null?mPlayValueGetter.getState():IPlayer.STATE_IDLE;
73 | }
74 |
75 | private boolean isInPlaybackState() {
76 | int state = getState();
77 | return state!= IPlayer.STATE_END
78 | && state!= IPlayer.STATE_ERROR
79 | && state!= IPlayer.STATE_IDLE
80 | && state!= IPlayer.STATE_INITIALIZED
81 | && state!= IPlayer.STATE_STOPPED;
82 | }
83 |
84 | @Override
85 | public void onErrorEvent(int eventCode, Bundle bundle) {
86 |
87 | }
88 |
89 | @Override
90 | public int getRecord(DataSource dataSource){
91 | return PlayRecord.get().getRecord(dataSource);
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/render/AspectRatio.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.render;
18 |
19 | import java.io.Serializable;
20 |
21 | /**
22 | * Created by Taurus on 2016/10/18.
23 | */
24 |
25 | public enum AspectRatio implements Serializable {
26 | AspectRatio_16_9,
27 | AspectRatio_4_3,
28 | AspectRatio_MATCH_PARENT,
29 | AspectRatio_FILL_PARENT,
30 | AspectRatio_FIT_PARENT,
31 | AspectRatio_ORIGIN,
32 | AspectRatio_FILL_WIDTH,
33 | AspectRatio_FILL_HEIGHT
34 | }
35 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/style/IStyleSetter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.style;
18 |
19 | import android.graphics.Rect;
20 |
21 | /**
22 | * Created by Taurus on 2017/12/9.
23 | */
24 |
25 | public interface IStyleSetter {
26 |
27 | void setRoundRectShape(float radius);
28 |
29 | void setRoundRectShape(Rect rect, float radius);
30 |
31 | void setOvalRectShape();
32 |
33 | void setOvalRectShape(Rect rect);
34 |
35 | void clearShapeStyle();
36 |
37 | void setElevationShadow(float elevation);
38 |
39 | /**
40 | * must setting a color when set shadow, not transparent.
41 | * @param backgroundColor
42 | * @param elevation
43 | */
44 | void setElevationShadow(int backgroundColor, float elevation);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/style/StyleSetter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.style;
18 |
19 | import android.graphics.Color;
20 | import android.graphics.Rect;
21 | import android.os.Build;
22 | import androidx.annotation.RequiresApi;
23 | import androidx.core.view.ViewCompat;
24 | import android.view.View;
25 |
26 | /**
27 | * Created by Taurus on 2017/12/9.
28 | *
29 | * style setter ,include round rect,oval rect and shadow.
30 | * The Shape Style settings support only more than LOLLIPOP.
31 | *
32 | */
33 |
34 | public final class StyleSetter implements IStyleSetter {
35 |
36 | private View mView;
37 |
38 | public StyleSetter(View view){
39 | this.mView = view;
40 | }
41 |
42 | @Override
43 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
44 | public void setRoundRectShape(float radius){
45 | setRoundRectShape(null, radius);
46 | }
47 |
48 | @Override
49 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
50 | public void setRoundRectShape(Rect rect, float radius){
51 | this.mView.setClipToOutline(true);
52 | this.mView.setOutlineProvider(new ViewRoundRectOutlineProvider(radius, rect));
53 | }
54 |
55 | @Override
56 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
57 | public void setOvalRectShape(){
58 | setOvalRectShape(null);
59 | }
60 |
61 | @Override
62 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
63 | public void setOvalRectShape(Rect rect){
64 | this.mView.setClipToOutline(true);
65 | this.mView.setOutlineProvider(new ViewOvalRectOutlineProvider(rect));
66 | }
67 |
68 | @Override
69 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
70 | public void clearShapeStyle() {
71 | this.mView.setClipToOutline(false);
72 | }
73 |
74 | @Override
75 | public void setElevationShadow(float elevation) {
76 | setElevationShadow(Color.BLACK, elevation);
77 | }
78 |
79 | @Override
80 | public void setElevationShadow(int backgroundColor, float elevation) {
81 | mView.setBackgroundColor(backgroundColor);
82 | ViewCompat.setElevation(mView,elevation);
83 | mView.invalidate();
84 | }
85 | }
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/style/ViewOvalRectOutlineProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.style;
18 |
19 | import android.annotation.TargetApi;
20 | import android.graphics.Outline;
21 | import android.graphics.Rect;
22 | import android.os.Build;
23 | import android.view.View;
24 | import android.view.ViewOutlineProvider;
25 |
26 | import com.kk.taurus.playerbase.utils.RectUtils;
27 |
28 | /**
29 | * Created by Taurus on 2017/12/9.
30 | */
31 |
32 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
33 | public class ViewOvalRectOutlineProvider extends ViewOutlineProvider {
34 |
35 | private Rect mRect;
36 |
37 | public ViewOvalRectOutlineProvider(Rect rect){
38 | this.mRect = rect;
39 | }
40 |
41 | @Override
42 | public void getOutline(final View view, final Outline outline) {
43 | Rect selfRect;
44 | if(mRect!=null){
45 | selfRect = mRect;
46 | }else{
47 | selfRect = new Rect();
48 | view.getDrawingRect(selfRect);
49 | selfRect = RectUtils.getOvalRect(selfRect);
50 | }
51 | outline.setOval(selfRect);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/style/ViewRoundRectOutlineProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.style;
18 |
19 | import android.annotation.TargetApi;
20 | import android.graphics.Outline;
21 | import android.graphics.Rect;
22 | import android.os.Build;
23 | import android.view.View;
24 | import android.view.ViewOutlineProvider;
25 |
26 | /**
27 | * Created by Taurus on 2017/12/9.
28 | */
29 |
30 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
31 | public class ViewRoundRectOutlineProvider extends ViewOutlineProvider {
32 |
33 | private float mRadius;
34 | private Rect mRect;
35 |
36 | public ViewRoundRectOutlineProvider(float radius){
37 | this.mRadius = radius;
38 | }
39 |
40 | public ViewRoundRectOutlineProvider(float radius, Rect rect) {
41 | this.mRadius = radius;
42 | this.mRect = rect;
43 | }
44 |
45 | @Override
46 | public void getOutline(View view, Outline outline) {
47 | Rect rect;
48 | if(mRect!=null){
49 | rect = mRect;
50 | }else {
51 | rect = new Rect();
52 | view.getDrawingRect(rect);
53 | }
54 | outline.setRoundRect(rect, mRadius);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/touch/BaseGestureCallbackHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.touch;
18 |
19 | import android.view.GestureDetector;
20 | import android.view.MotionEvent;
21 |
22 | import com.kk.taurus.playerbase.log.PLog;
23 |
24 | /**
25 | * Created by Taurus on 2017/11/20.
26 | */
27 |
28 | public class BaseGestureCallbackHandler extends GestureDetector.SimpleOnGestureListener {
29 |
30 | private final String TAG = "GestureCallbackHandler";
31 | protected OnTouchGestureListener mOnTouchGestureListener;
32 |
33 | private boolean mGestureEnable = true;
34 | private boolean mGestureScrollEnable = true;
35 |
36 | public BaseGestureCallbackHandler(OnTouchGestureListener onTouchGestureListener){
37 | this.mOnTouchGestureListener = onTouchGestureListener;
38 | }
39 |
40 | public void setGestureEnable(boolean enable){
41 | this.mGestureEnable = enable;
42 | }
43 |
44 | public void setGestureScrollEnable(boolean gestureScrollEnable) {
45 | this.mGestureScrollEnable = gestureScrollEnable;
46 | }
47 |
48 | @Override
49 | public boolean onSingleTapConfirmed(MotionEvent e) {
50 | if(mOnTouchGestureListener !=null){
51 | mOnTouchGestureListener.onSingleTapConfirmed(e);
52 | }
53 | return super.onSingleTapConfirmed(e);
54 | }
55 |
56 | @Override
57 | public void onLongPress(MotionEvent e) {
58 | super.onLongPress(e);
59 | if(mOnTouchGestureListener !=null){
60 | mOnTouchGestureListener.onLongPress(e);
61 | }
62 | }
63 |
64 | @Override
65 | public boolean onDoubleTap(MotionEvent e) {
66 | if(mOnTouchGestureListener !=null){
67 | mOnTouchGestureListener.onDoubleTap(e);
68 | }
69 | return super.onDoubleTap(e);
70 | }
71 |
72 | @Override
73 | public boolean onDown(MotionEvent e) {
74 | PLog.d(TAG,"onDown...");
75 | if(mOnTouchGestureListener !=null){
76 | mOnTouchGestureListener.onDown(e);
77 | }
78 | return mGestureEnable;
79 | }
80 |
81 | @Override
82 | public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
83 | if(mOnTouchGestureListener != null && mGestureScrollEnable){
84 | mOnTouchGestureListener.onScroll(e1, e2, distanceX, distanceY);
85 | }
86 | return super.onScroll(e1, e2, distanceX, distanceY);
87 | }
88 |
89 | public void onEndGesture(MotionEvent event){
90 | if(mOnTouchGestureListener !=null){
91 | mOnTouchGestureListener.onEndGesture();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/touch/ContainerTouchHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.touch;
18 |
19 | import android.content.Context;
20 | import android.view.GestureDetector;
21 | import android.view.MotionEvent;
22 |
23 | import com.kk.taurus.playerbase.touch.BaseGestureCallbackHandler;
24 |
25 | /**
26 | * Created by Taurus on 2017/11/20.
27 | */
28 |
29 | public class ContainerTouchHelper{
30 |
31 | private GestureDetector mGestureDetector;
32 | private BaseGestureCallbackHandler mGestureCallback;
33 |
34 | public ContainerTouchHelper(Context context, BaseGestureCallbackHandler gestureCallback){
35 | this.mGestureCallback = gestureCallback;
36 | mGestureDetector = new GestureDetector(context,gestureCallback);
37 | }
38 |
39 | public boolean onTouch(MotionEvent event){
40 | switch (event.getAction()){
41 | case MotionEvent.ACTION_UP:
42 | onEndGesture(event);
43 | break;
44 | }
45 | return mGestureDetector.onTouchEvent(event);
46 | }
47 |
48 | public void setGestureEnable(boolean enable) {
49 | this.mGestureCallback.setGestureEnable(enable);
50 | }
51 |
52 | public void setGestureScrollEnable(boolean enable) {
53 | this.mGestureCallback.setGestureScrollEnable(enable);
54 | }
55 |
56 | public void onEndGesture(MotionEvent event) {
57 | mGestureCallback.onEndGesture(event);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/touch/OnTouchGestureListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.touch;
18 |
19 | import android.view.MotionEvent;
20 |
21 | /**
22 | * Created by Taurus on 2017/3/26.
23 | */
24 |
25 | public interface OnTouchGestureListener {
26 | /**
27 | * on gesture single tap up
28 | * @param event
29 | */
30 | void onSingleTapConfirmed(MotionEvent event);
31 |
32 | /**
33 | * on gesture long press
34 | * @param event
35 | */
36 | void onLongPress(MotionEvent event);
37 |
38 | /**
39 | * on gesture double tap
40 | * @param event
41 | */
42 | void onDoubleTap(MotionEvent event);
43 |
44 | void onDown(MotionEvent event);
45 |
46 | /**
47 | * on scroll
48 | * @param e1
49 | * @param e2
50 | * @param distanceX
51 | * @param distanceY
52 | */
53 | void onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
54 |
55 | void onEndGesture();
56 | }
57 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/touch/TouchEventIndicator.java:
--------------------------------------------------------------------------------
1 | package com.kk.taurus.playerbase.touch;
2 |
3 | /**
4 | * @ClassName TouchEventIndicator
5 | * @Description
6 | * @Author Taurus
7 | * @Date 2020/9/1 9:26 PM
8 | */
9 | public interface TouchEventIndicator {
10 |
11 | /**
12 | * If you don't want to receive a touch event, the method returns true
13 | *
14 | * @return
15 | */
16 | boolean disallowReceiveTouchEvent();
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/utils/PUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.utils;
18 |
19 | import android.content.Context;
20 |
21 | public class PUtils {
22 |
23 | public static int getStatusBarHeight(Context context){
24 | int height = getStatusBarHeightMethod1(context);
25 | if(height<=0){
26 | height = getStatusBarHeightMethod2(context);
27 | }
28 | return height;
29 | }
30 |
31 | private static int getStatusBarHeightMethod1(Context context){
32 | int statusBarHeight = -1;
33 | //获取status_bar_height资源的ID
34 | int resourceId = context.getResources()
35 | .getIdentifier("status_bar_height", "dimen", "android");
36 | if (resourceId > 0) {
37 | //根据资源ID获取响应的尺寸值
38 | statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
39 | }
40 | return statusBarHeight;
41 | }
42 |
43 | private static int getStatusBarHeightMethod2(Context context){
44 | return (int) Math.ceil(20 * context.getResources().getDisplayMetrics().density);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/utils/RectUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.utils;
18 |
19 | import android.graphics.Rect;
20 |
21 | /**
22 | * Created by Taurus on 2017/12/10.
23 | */
24 |
25 | public class RectUtils {
26 |
27 | public static Rect getOvalRect(Rect rect){
28 | int width = rect.right - rect.left;
29 | int height = rect.bottom - rect.top;
30 |
31 | int left;
32 | int top;
33 | int right;
34 | int bottom;
35 | int dW = width/2;
36 | int dH = height/2;
37 | if(width > height){
38 | left = dW - dH;
39 | top = 0;
40 | right = dW + dH;
41 | bottom = dH * 2;
42 | }else{
43 | left = dH - dW;
44 | top = 0;
45 | right = dH + dW;
46 | bottom = dW * 2;
47 | }
48 | return new Rect(left, top, right, bottom);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/utils/TimeUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.utils;
18 |
19 | import android.text.TextUtils;
20 |
21 | /**
22 | * ------------------------------------
23 | * Created by Taurus on 2016/8/3.
24 | * ------------------------------------
25 | */
26 | public class TimeUtil {
27 |
28 | private static final long SECONDS_ONE_HOUR = 60*60;
29 |
30 | public static final String TIME_FORMAT_01 = "%02d:%02d";
31 | public static final String TIME_FORMAT_02 = "%02d:%02d:%02d";
32 |
33 | public static String getTimeFormat1(long timeMs){
34 | return getTime(TIME_FORMAT_01, timeMs);
35 | }
36 |
37 | public static String getTimeFormat2(long timeMs){
38 | return getTime(TIME_FORMAT_02, timeMs);
39 | }
40 |
41 | public static String getTimeSmartFormat(long timeMs){
42 | int totalSeconds = (int) (timeMs / 1000);
43 | if(totalSeconds >= SECONDS_ONE_HOUR){
44 | return getTimeFormat2(timeMs);
45 | }else{
46 | return getTimeFormat1(timeMs);
47 | }
48 | }
49 |
50 | public static String getFormat(long maxTimeMs){
51 | int totalSeconds = (int) (maxTimeMs / 1000);
52 | if(totalSeconds >= SECONDS_ONE_HOUR){
53 | return TIME_FORMAT_02;
54 | }
55 | return TIME_FORMAT_01;
56 | }
57 |
58 | public static String getTime(String format, long time){
59 | if(time <= 0)
60 | time = 0;
61 | int totalSeconds = (int) (time / 1000);
62 | int seconds = totalSeconds % 60;
63 | int minutes = (totalSeconds / 60) % 60;
64 | int hours = totalSeconds / 3600;
65 | if(TIME_FORMAT_01.equals(format)){
66 | return String.format(format, minutes, seconds);
67 | }else if(TIME_FORMAT_02.equals(format)){
68 | return String.format(format, hours, minutes, seconds);
69 | }
70 | if(TextUtils.isEmpty(format)){
71 | format = TIME_FORMAT_02;
72 | }
73 | return String.format(format, hours, minutes, seconds);
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/playerbase/src/main/java/com/kk/taurus/playerbase/widget/IVideoView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 jiajunhui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.kk.taurus.playerbase.widget;
18 |
19 | import com.kk.taurus.playerbase.entity.DataSource;
20 | import com.kk.taurus.playerbase.render.AspectRatio;
21 | import com.kk.taurus.playerbase.render.IRender;
22 |
23 | /**
24 | * Created by Taurus on 2018/3/17.
25 | */
26 |
27 | public interface IVideoView {
28 |
29 | void setDataSource(DataSource dataSource);
30 |
31 | void setRenderType(int renderType);
32 | void setAspectRatio(AspectRatio aspectRatio);
33 | boolean switchDecoder(int decoderPlanId);
34 |
35 | void setVolume(float left, float right);
36 | void setSpeed(float speed);
37 | void setLooping(boolean looping);
38 |
39 | IRender getRender();
40 |
41 | boolean isInPlaybackState();
42 | boolean isPlaying();
43 | int getCurrentPosition();
44 | int getDuration();
45 | int getAudioSessionId();
46 | int getBufferPercentage();
47 | int getState();
48 |
49 | void start();
50 | void start(int msc);
51 | void pause();
52 | void resume();
53 | void seekTo(int msc);
54 | void stop();
55 | void stopPlayback();
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/screenshot/Screenshot_001.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/Screenshot_001.jpeg
--------------------------------------------------------------------------------
/screenshot/Screenshot_002.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/Screenshot_002.jpeg
--------------------------------------------------------------------------------
/screenshot/Screenshot_003.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/Screenshot_003.jpeg
--------------------------------------------------------------------------------
/screenshot/Screenshot_004.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/Screenshot_004.jpeg
--------------------------------------------------------------------------------
/screenshot/Screenshot_005.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/Screenshot_005.jpeg
--------------------------------------------------------------------------------
/screenshot/Screenshot_006.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/Screenshot_006.jpeg
--------------------------------------------------------------------------------
/screenshot/frame_structure01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/frame_structure01.jpg
--------------------------------------------------------------------------------
/screenshot/frame_structure02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/frame_structure02.png
--------------------------------------------------------------------------------
/screenshot/frame_structure03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/frame_structure03.png
--------------------------------------------------------------------------------
/screenshot/frame_structure04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/frame_structure04.png
--------------------------------------------------------------------------------
/screenshot/mtime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/mtime.png
--------------------------------------------------------------------------------
/screenshot/piaoshen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/piaoshen.png
--------------------------------------------------------------------------------
/screenshot/playerbase_top_slogen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/playerbase_top_slogen.png
--------------------------------------------------------------------------------
/screenshot/qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/qrcode.png
--------------------------------------------------------------------------------
/screenshot/qrcode_qq_group.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/qrcode_qq_group.jpg
--------------------------------------------------------------------------------
/screenshot/receiver_cover_life_cycle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/receiver_cover_life_cycle.jpg
--------------------------------------------------------------------------------
/screenshot/widget_struct.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/widget_struct.jpg
--------------------------------------------------------------------------------
/screenshot/yingmidayuan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiajunhui/PlayerBase/35e204437766f95dfce9e0449625584a7c64bc7f/screenshot/yingmidayuan.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':playerbase', ':ijkplayer', ':exoplayer'
2 |
--------------------------------------------------------------------------------