diff --git a/README.md b/README.md index 21b92fe5..bb708c7c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ --

- +

@@ -39,7 +39,7 @@ ## 文档 -- [文档 - API](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-API),下载安装demo[jiaozivideoplayer-7.2.2.apk](https://github.com/Jzvd/JiaoZiVideoPlayer/releases/download/v7.2.2/jiaozivideoplayer-7.2.2.apk),仔细过一遍demo +- [文档 - API](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-API),下载安装demo[jiaozivideoplayer-7.2.3.apk](https://github.com/Jzvd/JiaoZiVideoPlayer/releases/download/v7.2.3/jiaozivideoplayer-7.2.3.apk),仔细过一遍demo - [文档 - 自定义Jzvd](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-%E8%87%AA%E5%AE%9A%E4%B9%89Jzvd),继承JzvdStd实现自己的播放器 - [文档 - 自定义播放内核](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-%E8%87%AA%E5%AE%9A%E4%B9%89%E6%92%AD%E6%94%BE%E5%86%85%E6%A0%B8),测试哪个播放内核适合自己的项目 @@ -53,7 +53,7 @@ 1.添加类库 ```gradle -compile 'cn.jzvd:jiaozivideoplayer:7.2.2' +compile 'cn.jzvd:jiaozivideoplayer:7.2.3' ``` 2.添加布局 diff --git a/app/src/main/res/drawable-xxhdpi/ic_comment_normal.png b/app/src/main/res/drawable-xxhdpi/ic_comment_normal.png deleted file mode 100644 index 4901df0f..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_comment_normal.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_douyin_icon.png b/app/src/main/res/drawable-xxhdpi/ic_douyin_icon.png deleted file mode 100644 index 53842e22..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_douyin_icon.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_star_normal.png b/app/src/main/res/drawable-xxhdpi/ic_star_normal.png deleted file mode 100644 index d6c1185b..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_star_normal.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_star_selected.png b/app/src/main/res/drawable-xxhdpi/ic_star_selected.png deleted file mode 100644 index 19c8823b..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_star_selected.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_star_selector.xml b/app/src/main/res/drawable/ic_star_selector.xml deleted file mode 100644 index 7e1a685d..00000000 --- a/app/src/main/res/drawable/ic_star_selector.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/skin_enlarge_video.png b/app/src/main/res/drawable/skin_enlarge_video.png deleted file mode 100644 index a7f47e20..00000000 Binary files a/app/src/main/res/drawable/skin_enlarge_video.png and /dev/null differ diff --git a/app/src/main/res/drawable/skin_shrink_video.png b/app/src/main/res/drawable/skin_shrink_video.png deleted file mode 100644 index 5daa02b2..00000000 Binary files a/app/src/main/res/drawable/skin_shrink_video.png and /dev/null differ diff --git a/app/src/main/res/layout/activity_ui_big_change.xml b/app/src/main/res/layout/activity_ui_big_change.xml deleted file mode 100644 index c9edfbd8..00000000 --- a/app/src/main/res/layout/activity_ui_big_change.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-xhdpi/add_bg.png b/app/src/main/res/mipmap-xhdpi/add_bg.png deleted file mode 100644 index a5308d6c..00000000 Binary files a/app/src/main/res/mipmap-xhdpi/add_bg.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/btn_share_to.png b/app/src/main/res/mipmap-xhdpi/btn_share_to.png deleted file mode 100644 index 7a35d10e..00000000 Binary files a/app/src/main/res/mipmap-xhdpi/btn_share_to.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/lock.png b/app/src/main/res/mipmap-xxhdpi/lock.png deleted file mode 100644 index ff2bf0ee..00000000 Binary files a/app/src/main/res/mipmap-xxhdpi/lock.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/share_normal.png b/app/src/main/res/mipmap-xxhdpi/share_normal.png deleted file mode 100644 index d72a0c40..00000000 Binary files a/app/src/main/res/mipmap-xxhdpi/share_normal.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/share_pressed.png b/app/src/main/res/mipmap-xxhdpi/share_pressed.png deleted file mode 100644 index 9fc94b79..00000000 Binary files a/app/src/main/res/mipmap-xxhdpi/share_pressed.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/unlock.png b/app/src/main/res/mipmap-xxhdpi/unlock.png deleted file mode 100644 index f6893313..00000000 Binary files a/app/src/main/res/mipmap-xxhdpi/unlock.png and /dev/null differ diff --git a/build.gradle b/build.gradle index 0cc143e0..2d1d9aae 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:3.6.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/app/build.gradle b/demo/build.gradle similarity index 84% rename from app/build.gradle rename to demo/build.gradle index 4d64f720..005717ea 100755 --- a/app/build.gradle +++ b/demo/build.gradle @@ -2,13 +2,14 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 + buildToolsVersion = '29.0.3' defaultConfig { applicationId "cn.jzvd.demo" minSdkVersion 16 targetSdkVersion 29 - versionCode 97 - versionName "7.2.2" + versionCode 98 + versionName "7.2.3" ndk { // add support lib abiFilters 'armeabi-v7a' //, 'arm64-v8a'//, "mips" //,'armeabi''x86',, 'x86_64', @@ -47,12 +48,14 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') testImplementation 'junit:junit:4.12' implementation 'androidx.appcompat:appcompat:1.1.0' - implementation project(':jiaozivideoplayer') + implementation 'com.android.support:design:28.0.0' + implementation project(':library') implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8' implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.4' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'com.danikula:videocache:2.7.0' - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.google.android.exoplayer:exoplayer:2.10.4' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' } diff --git a/app/jzvd-keystore b/demo/jzvd-keystore similarity index 100% rename from app/jzvd-keystore rename to demo/jzvd-keystore diff --git a/app/proguard-rules.pro b/demo/proguard-rules.pro similarity index 100% rename from app/proguard-rules.pro rename to demo/proguard-rules.pro diff --git a/app/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml similarity index 96% rename from app/src/main/AndroidManifest.xml rename to demo/src/main/AndroidManifest.xml index b728ed8f..fb32a504 100644 --- a/app/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -124,6 +124,9 @@ + \ No newline at end of file diff --git a/app/src/main/assets/jzvd.html b/demo/src/main/assets/jzvd.html similarity index 100% rename from app/src/main/assets/jzvd.html rename to demo/src/main/assets/jzvd.html diff --git a/app/src/main/assets/local_video.mp4 b/demo/src/main/assets/local_video.mp4 similarity index 100% rename from app/src/main/assets/local_video.mp4 rename to demo/src/main/assets/local_video.mp4 diff --git a/app/src/main/ic_launcher-web.png b/demo/src/main/ic_launcher-web.png similarity index 100% rename from app/src/main/ic_launcher-web.png rename to demo/src/main/ic_launcher-web.png diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApi.java b/demo/src/main/java/cn/jzvd/demo/ActivityApi.java similarity index 95% rename from app/src/main/java/cn/jzvd/demo/ActivityApi.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApi.java index 3f1ebf20..4f489f6f 100644 --- a/app/src/main/java/cn/jzvd/demo/ActivityApi.java +++ b/demo/src/main/java/cn/jzvd/demo/ActivityApi.java @@ -63,7 +63,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { /** Play video in local localVideoPath, eg:record by system camera **/ // cpAssertVideoToLocalPath(); -// mJzvdStd.setUp(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/local_video.mp4" +// mJzvdStd.setUp(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/activity_local_video.mp4" // , "饺子不信", Jzvd.SCREEN_NORMAL); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorEventListener = new Jzvd.JZAutoFullscreenListener(); @@ -109,7 +109,7 @@ public void cpAssertVideoToLocalPath() { verifyStoragePermissions(); try { InputStream myInput; - OutputStream myOutput = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/local_video.mp4"); + OutputStream myOutput = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/activity_local_video.mp4"); myInput = this.getAssets().open("local_video.mp4"); byte[] buffer = new byte[1024]; int length = myInput.read(buffer); @@ -146,8 +146,8 @@ public void clickSmallChange(View view) { } public void clickBigChange(View view) { - Toast.makeText(ActivityApi.this, "Comming Soon", Toast.LENGTH_SHORT).show(); -// startActivity(new Intent(ActivityApi.this, ActivityApiUIBigChange.class)); +// Toast.makeText(ActivityApi.this, "Comming Soon", Toast.LENGTH_SHORT).show(); + startActivity(new Intent(ActivityApi.this, ActivityApiUIBigChange.class)); } public void clickOrientation(View view) { diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApiCustomMedia.java b/demo/src/main/java/cn/jzvd/demo/ActivityApiCustomMedia.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityApiCustomMedia.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApiCustomMedia.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApiExtendsNormal.java b/demo/src/main/java/cn/jzvd/demo/ActivityApiExtendsNormal.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityApiExtendsNormal.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApiExtendsNormal.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApiOrientation.java b/demo/src/main/java/cn/jzvd/demo/ActivityApiOrientation.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityApiOrientation.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApiOrientation.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApiRotationVideoSize.java b/demo/src/main/java/cn/jzvd/demo/ActivityApiRotationVideoSize.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityApiRotationVideoSize.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApiRotationVideoSize.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApiUIBigChange.java b/demo/src/main/java/cn/jzvd/demo/ActivityApiUIBigChange.java similarity index 83% rename from app/src/main/java/cn/jzvd/demo/ActivityApiUIBigChange.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApiUIBigChange.java index d78e7ac2..78b72cd8 100644 --- a/app/src/main/java/cn/jzvd/demo/ActivityApiUIBigChange.java +++ b/demo/src/main/java/cn/jzvd/demo/ActivityApiUIBigChange.java @@ -1,12 +1,15 @@ package cn.jzvd.demo; +import android.content.Intent; import android.os.Bundle; import android.view.MenuItem; +import android.view.View; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import cn.jzvd.Jzvd; +import cn.jzvd.demo.BigUIChangeAG.ActivityApiUIBigChangeAG; /** * Created by Nathen on 16/7/31. @@ -38,6 +41,10 @@ protected void onPause() { Jzvd.releaseAllVideos(); } + public void clickUiAGBigChange(View view) { + startActivity(new Intent(ActivityApiUIBigChange.this, ActivityApiUIBigChangeAG.class)); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { diff --git a/app/src/main/java/cn/jzvd/demo/ActivityApiUISmallChange.java b/demo/src/main/java/cn/jzvd/demo/ActivityApiUISmallChange.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityApiUISmallChange.java rename to demo/src/main/java/cn/jzvd/demo/ActivityApiUISmallChange.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityDirectPlay.java b/demo/src/main/java/cn/jzvd/demo/ActivityDirectPlay.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityDirectPlay.java rename to demo/src/main/java/cn/jzvd/demo/ActivityDirectPlay.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListView.java b/demo/src/main/java/cn/jzvd/demo/ActivityListView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListView.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListView.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewAutoPlay.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewAutoPlay.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewAutoPlay.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewAutoPlay.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewDetail.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewDetail.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewDetail.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewDetail.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewFragmentViewPager.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewFragmentViewPager.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewFragmentViewPager.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewFragmentViewPager.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewMultiHolder.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewMultiHolder.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewMultiHolder.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewMultiHolder.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewNormal.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewNormal.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewNormal.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewNormal.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewRecyclerView.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewRecyclerView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewRecyclerView.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewRecyclerView.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityListViewToDetail.java b/demo/src/main/java/cn/jzvd/demo/ActivityListViewToDetail.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityListViewToDetail.java rename to demo/src/main/java/cn/jzvd/demo/ActivityListViewToDetail.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityLocalVideo.java b/demo/src/main/java/cn/jzvd/demo/ActivityLocalVideo.java similarity index 97% rename from app/src/main/java/cn/jzvd/demo/ActivityLocalVideo.java rename to demo/src/main/java/cn/jzvd/demo/ActivityLocalVideo.java index 077cfbf0..adb15f8f 100644 --- a/app/src/main/java/cn/jzvd/demo/ActivityLocalVideo.java +++ b/demo/src/main/java/cn/jzvd/demo/ActivityLocalVideo.java @@ -44,10 +44,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setTitle("PlayLocalVideo"); - setContentView(R.layout.local_video); + setContentView(R.layout.activity_local_video); jzvdLocalPath = findViewById(cn.jzvd.demo.R.id.lcoal_path); jzvdAssertPath = findViewById(cn.jzvd.demo.R.id.assert_path); - localVideoPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/local_video.mp4"; + localVideoPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/activity_local_video.mp4"; //checkPermission int permission = ActivityCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE"); diff --git a/app/src/main/java/cn/jzvd/demo/ActivityMain.java b/demo/src/main/java/cn/jzvd/demo/ActivityMain.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityMain.java rename to demo/src/main/java/cn/jzvd/demo/ActivityMain.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityPreloading.java b/demo/src/main/java/cn/jzvd/demo/ActivityPreloading.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityPreloading.java rename to demo/src/main/java/cn/jzvd/demo/ActivityPreloading.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityPreloadingList.java b/demo/src/main/java/cn/jzvd/demo/ActivityPreloadingList.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityPreloadingList.java rename to demo/src/main/java/cn/jzvd/demo/ActivityPreloadingList.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityScreenRotate.java b/demo/src/main/java/cn/jzvd/demo/ActivityScreenRotate.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityScreenRotate.java rename to demo/src/main/java/cn/jzvd/demo/ActivityScreenRotate.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityTinyWindow.java b/demo/src/main/java/cn/jzvd/demo/ActivityTinyWindow.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityTinyWindow.java rename to demo/src/main/java/cn/jzvd/demo/ActivityTinyWindow.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleView.java b/demo/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleView.java rename to demo/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleView.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleViewMultiHolder.java b/demo/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleViewMultiHolder.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleViewMultiHolder.java rename to demo/src/main/java/cn/jzvd/demo/ActivityTinyWindowRecycleViewMultiHolder.java diff --git a/app/src/main/java/cn/jzvd/demo/ActivityWebView.java b/demo/src/main/java/cn/jzvd/demo/ActivityWebView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ActivityWebView.java rename to demo/src/main/java/cn/jzvd/demo/ActivityWebView.java diff --git a/app/src/main/java/cn/jzvd/demo/AdapterComment.java b/demo/src/main/java/cn/jzvd/demo/AdapterComment.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/AdapterComment.java rename to demo/src/main/java/cn/jzvd/demo/AdapterComment.java diff --git a/app/src/main/java/cn/jzvd/demo/AdapterListView.java b/demo/src/main/java/cn/jzvd/demo/AdapterListView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/AdapterListView.java rename to demo/src/main/java/cn/jzvd/demo/AdapterListView.java diff --git a/app/src/main/java/cn/jzvd/demo/AdapterRecyclerView.java b/demo/src/main/java/cn/jzvd/demo/AdapterRecyclerView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/AdapterRecyclerView.java rename to demo/src/main/java/cn/jzvd/demo/AdapterRecyclerView.java diff --git a/app/src/main/java/cn/jzvd/demo/AdapterRecyclerViewTiny.java b/demo/src/main/java/cn/jzvd/demo/AdapterRecyclerViewTiny.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/AdapterRecyclerViewTiny.java rename to demo/src/main/java/cn/jzvd/demo/AdapterRecyclerViewTiny.java diff --git a/app/src/main/java/cn/jzvd/demo/AdapterSmoothRecyclerView.java b/demo/src/main/java/cn/jzvd/demo/AdapterSmoothRecyclerView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/AdapterSmoothRecyclerView.java rename to demo/src/main/java/cn/jzvd/demo/AdapterSmoothRecyclerView.java diff --git a/app/src/main/java/cn/jzvd/demo/ApplicationDemo.java b/demo/src/main/java/cn/jzvd/demo/ApplicationDemo.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ApplicationDemo.java rename to demo/src/main/java/cn/jzvd/demo/ApplicationDemo.java diff --git a/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/AGEpsodeEntity.java b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/AGEpsodeEntity.java new file mode 100644 index 00000000..f776ec16 --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/AGEpsodeEntity.java @@ -0,0 +1,37 @@ +package cn.jzvd.demo.BigUIChangeAG; + +public class AGEpsodeEntity { + private String videoUrl; + private String videoName; + /**是否被选中播放(默认没有播放)*/ + private boolean isPlay=false; + + public AGEpsodeEntity(String videoUrl, String videoName) { + this.videoUrl = videoUrl; + this.videoName = videoName; + } + + public boolean isPlay() { + return isPlay; + } + + public void setPlay(boolean play) { + isPlay = play; + } + + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } + + public String getVideoName() { + return videoName; + } + + public void setVideoName(String videoName) { + this.videoName = videoName; + } +} diff --git a/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/AGVideo.java b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/AGVideo.java new file mode 100644 index 00000000..2f43157b --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/AGVideo.java @@ -0,0 +1,805 @@ +package cn.jzvd.demo.BigUIChangeAG; + +import android.content.Context; +import android.graphics.Color; +import android.util.AttributeSet; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.PopupWindow; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + +import java.util.Timer; +import java.util.TimerTask; + +import cn.jzvd.JZDataSource; +import cn.jzvd.JZUtils; +import cn.jzvd.JzvdStd; +import cn.jzvd.demo.R; +import cn.jzvd.demo.utils.NetworkUtils; +import cn.jzvd.demo.widget.LoadingView; + +public class AGVideo extends JzvdStd { + private JzVideoListener jzVideoListener; + //视频控制布局 + private RelativeLayout videoPlayControlLayout; + private ImageView screenIV, quickRetreat, fastForward, start_bottom, next_bottom; + private CheckBox lock; + private TextView tvSpeed, tvSelectPart,next_set; + private LinearLayout startLayout; + //无网络布局 + private LoadingView loadingView; + + //是否锁屏状态 + private boolean isLock = false; + //是否有下一集 + private boolean isNext; + private int nextTimerDate=3; + private Timer mDismissLockViewTimer,mDismissNextViewTimer; + protected DismissLockViewTimerTask mDismissLockViewTimerTask; + private DismissNextViewTimerTask mDismissNextViewTimerTask; + + public AGVideo(Context context) { + super(context); + } + + public AGVideo(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public JzVideoListener getJzVideoListener() { + return jzVideoListener; + } + + public void setJzVideoListener(JzVideoListener jzVideoListener) { + this.jzVideoListener = jzVideoListener; + } + + @Override + public int getLayoutId() { + return R.layout.layout_ag_video; + } + + @Override + public void init(Context context) { + super.init(context); + loadingView = findViewById(R.id.player_newLoading); + + videoPlayControlLayout = findViewById(R.id.video_control_layout); + tvSpeed = findViewById(R.id.tv_speed); + tvSelectPart = findViewById(R.id.tv_select_parts); + screenIV = findViewById(R.id.screen); + startLayout = findViewById(R.id.start_layout); + quickRetreat = findViewById(R.id.quick_retreat); + fastForward = findViewById(R.id.fast_forward); + start_bottom = findViewById(R.id.start_bottom); + next_bottom = findViewById(R.id.next_bottom); + lock = findViewById(R.id.lock); + next_set = findViewById(R.id.next_set); + + next_set.setOnClickListener(this); + replayTextView.setOnClickListener(this); + tvSpeed.setOnClickListener(this); + tvSelectPart.setOnClickListener(this); + start_bottom.setOnClickListener(this); + next_bottom.setOnClickListener(this); + quickRetreat.setOnClickListener(this); + fastForward.setOnClickListener(this); + screenIV.setOnClickListener(this); + lock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + isLock = isChecked; + if (isChecked) { + //锁屏按钮单独延迟隐藏 + goneLock(); + //隐藏其他功能 + dissmissControlView(); + } else { + cancelDismissControlViewTimer(); + startDismissControlViewTimer(); + //取消锁屏按钮的单独延迟隐藏,使锁屏按钮的延迟隐藏和其他功能按钮相同 + cancelGoneLock(); + onClickUiToggle(); + } + } + }); + } + + private void cancelGoneLock() { + cancelDismissLockViewTimer(); + } + + private void goneLock() { + startDismissLockViewTimer(); + } + + @Override + public void onClick(View v) { + int id = v.getId(); + switch (id) { + case R.id.start: + if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(cn.jzvd.R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (state == STATE_NORMAL) { + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! + jzDataSource.getCurrentUrl().toString().startsWith("/") && + !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) {//这个可以放到std中 + showWifiDialog(); + return; + } + startVideo(); + } else if (state == STATE_PLAYING) { + Log.d(TAG, "pauseVideo [" + this.hashCode() + "] "); + mediaInterface.pause(); + onStatePause(); + } else if (state == STATE_PAUSE) { + mediaInterface.start(); + onStatePlaying(); + } else if (state == STATE_AUTO_COMPLETE) { + startVideo(); + } + break; + case R.id.poster: + if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(cn.jzvd.R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (state == STATE_NORMAL) { + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && + !jzDataSource.getCurrentUrl().toString().startsWith("/") && + !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) { + showWifiDialog(); + return; + } + startVideo(); + } else if (state == STATE_AUTO_COMPLETE) { + onClickUiToggle(); + } + break; + case R.id.surface_container: + startDismissControlViewTimer(); + break; + case R.id.back_tiny: + clearFloatScreen(); + break; + case R.id.clarity: + LayoutInflater inflater = (LayoutInflater) getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + final LinearLayout layout = (LinearLayout) inflater.inflate(cn.jzvd.R.layout.jz_layout_clarity, null); + + OnClickListener mQualityListener = v1 -> { + int index = (int) v1.getTag(); + +// this.seekToInAdvance = getCurrentPositionWhenPlaying(); + jzDataSource.currentUrlIndex = index; +// onStatePreparingChangeUrl(); + + changeUrl(jzDataSource, getCurrentPositionWhenPlaying()); + + + clarity.setText(jzDataSource.getCurrentKey().toString()); + for (int j = 0; j < layout.getChildCount(); j++) {//设置点击之后的颜色 + if (j == jzDataSource.currentUrlIndex) { + ((TextView) layout.getChildAt(j)).setTextColor(Color.parseColor("#fff85959")); + } else { + ((TextView) layout.getChildAt(j)).setTextColor(Color.parseColor("#ffffff")); + } + } + if (clarityPopWindow != null) { + clarityPopWindow.dismiss(); + } + }; + + for (int j = 0; j < jzDataSource.urlsMap.size(); j++) { + String key = jzDataSource.getKeyFromDataSource(j); + TextView clarityItem = (TextView) View.inflate(getContext(), cn.jzvd.R.layout.jz_layout_clarity_item, null); + clarityItem.setText(key); + clarityItem.setTag(j); + layout.addView(clarityItem, j); + clarityItem.setOnClickListener(mQualityListener); + if (j == jzDataSource.currentUrlIndex) { + clarityItem.setTextColor(Color.parseColor("#fff85959")); + } + } + + clarityPopWindow = new PopupWindow(layout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true); + clarityPopWindow.setContentView(layout); + clarityPopWindow.showAsDropDown(clarity); + layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); + int offsetX = clarity.getMeasuredWidth() / 3; + int offsetY = clarity.getMeasuredHeight() / 3; + clarityPopWindow.update(clarity, -offsetX, -offsetY, Math.round(layout.getMeasuredWidth() * 2), layout.getMeasuredHeight()); + break; + case R.id.retry_btn: + if (jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(cn.jzvd.R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! + jzDataSource.getCurrentUrl().toString().startsWith("/") && + !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) { + showWifiDialog(); + return; + } + addTextureView(); + onStatePreparing(); + break; + + case R.id.replay_text: + if (state == STATE_AUTO_COMPLETE) { + replayTextView.setVisibility(View.GONE); + next_set.setVisibility(View.GONE); + //点击重播,取消下一集倒计时 + dismissNextView(); + cancelDismissNextViewTimer(); + resetProgressAndTime(); + mediaInterface.seekTo(0); + } + break; + case R.id.next_set: + dismissNextView(); + cancelDismissNextViewTimer(); + if (jzVideoListener != null) { + jzVideoListener.nextClick(); + } + break; + case R.id.back: + case R.id.top_back: + if (jzVideoListener != null) { + jzVideoListener.backClick(); + } + break; + case R.id.tv_speed: + if (jzVideoListener != null) { + jzVideoListener.speedClick(); + } + break; + case R.id.tv_select_parts: + if (jzVideoListener != null) { + jzVideoListener.selectPartsClick(); + } + break; + case R.id.next_bottom: + if (jzVideoListener != null) { + jzVideoListener.nextClick(); + } + break; + case R.id.start_bottom: + if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(cn.jzvd.R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (state == STATE_NORMAL) { + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! + jzDataSource.getCurrentUrl().toString().startsWith("/") && + !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) {//这个可以放到std中 + showWifiDialog(); + return; + } + startVideo(); + } else if (state == STATE_PLAYING) { + Log.d(TAG, "pauseVideo [" + this.hashCode() + "] "); + mediaInterface.pause(); + onStatePause(); + } else if (state == STATE_PAUSE) { + mediaInterface.start(); + onStatePlaying(); + } else if (state == STATE_AUTO_COMPLETE) { + startVideo(); + } + break; + case R.id.fast_forward: + //总时间长度 + long duration = getDuration(); + //当前时间 + long currentPositionWhenPlaying = getCurrentPositionWhenPlaying(); + //快进(15S) + long fastForwardProgress = currentPositionWhenPlaying + 15 * 1000; + if (duration > fastForwardProgress) { + mediaInterface.seekTo(fastForwardProgress); + } else { + mediaInterface.seekTo(duration); + } + break; + case R.id.quick_retreat: + //当前时间 + long quickRetreatCurrentPositionWhenPlaying = getCurrentPositionWhenPlaying(); + //快退(15S) + long quickRetreatProgress = quickRetreatCurrentPositionWhenPlaying - 15 * 1000; + if (quickRetreatProgress > 0) { + mediaInterface.seekTo(quickRetreatProgress); + } else { + mediaInterface.seekTo(0); + } + break; + case R.id.fullscreen: + if (state == STATE_AUTO_COMPLETE) return; + if (screen == SCREEN_FULLSCREEN) { + //quit fullscreen + backPress(); + } else { + gotoScreenFullscreen(); + } + break; + case R.id.screen: + if (jzVideoListener != null) { + jzVideoListener.throwingScreenClick(); + } + break; + } + } + + + @Override + public void changeUrl(JZDataSource jzDataSource, long seekToInAdvance) { + next_set.setVisibility(GONE); + showProgress(); + super.changeUrl(jzDataSource, seekToInAdvance); +// //切换播放地址之后继续以1倍速播放 + if (jzDataSource.objects == null) { + Object[] object = {1}; + jzDataSource.objects = object; + } + speedChange(1.0f); + resetProgressAndTime(); + } + + @Override + public void dissmissControlView() { + if (state != STATE_NORMAL + && state != STATE_ERROR + && state != STATE_AUTO_COMPLETE) { + post(() -> { + bottomContainer.setVisibility(View.INVISIBLE); + topContainer.setVisibility(View.INVISIBLE); + startButton.setVisibility(View.INVISIBLE); + fastForward.setVisibility(View.INVISIBLE); + quickRetreat.setVisibility(View.INVISIBLE); + if (!isLock) { + lock.setVisibility(View.INVISIBLE); + } + if (clarityPopWindow != null) { + clarityPopWindow.dismiss(); + } + if (screen != SCREEN_TINY && screen != SCREEN_FULLSCREEN) { + bottomProgressBar.setVisibility(View.VISIBLE); + } + }); + } + } + + public void dismissLockView() { + if (state != STATE_NORMAL + && state != STATE_ERROR + && state != STATE_AUTO_COMPLETE) { + post(() -> { + lock.setVisibility(GONE); + }); + } + } + + + @Override + public void changeUiToPreparing() { + switch (screen) { + case SCREEN_NORMAL: + case SCREEN_FULLSCREEN: + screenIV.setVisibility(GONE); + titleTextView.setVisibility(GONE); + batteryTimeLayout.setVisibility(GONE); + setAllControlsVisiblity(View.VISIBLE, View.INVISIBLE, View.INVISIBLE, + View.VISIBLE, View.VISIBLE, View.INVISIBLE, View.INVISIBLE); + updateStartImage(); + break; + case SCREEN_TINY: + break; + } + + } + + + @Override + public void updateStartImage() { + Log.e("AGVideo","state:"+state); + if (state == STATE_PLAYING) { + startButton.setVisibility(VISIBLE); + startButton.setImageResource(R.mipmap.ag_btn_movie_suspend); + start_bottom.setImageResource(R.mipmap.ag_btn_movie_stop_bottom); + fastForward.setVisibility(VISIBLE); + quickRetreat.setVisibility(VISIBLE); + replayTextView.setVisibility(GONE); + } else if (state == STATE_PREPARING) { + backButton.setVisibility(VISIBLE); + } else if (state == STATE_ERROR) { + startButton.setVisibility(INVISIBLE); + replayTextView.setVisibility(GONE); + fastForward.setVisibility(GONE); + quickRetreat.setVisibility(GONE); + } else if (state == STATE_AUTO_COMPLETE) { + //视频播放完成状态 + startButton.setVisibility(View.GONE); + replayTextView.setVisibility(VISIBLE); + if (isNext) { + next_set.setVisibility(VISIBLE); + } + fastForward.setVisibility(GONE); + quickRetreat.setVisibility(GONE); + } else { + startButton.setImageResource(R.mipmap.ag_btn_movie_play); + start_bottom.setImageResource(R.mipmap.ag_btn_movie_play_bottom); + replayTextView.setVisibility(GONE); + fastForward.setVisibility(GONE); + quickRetreat.setVisibility(GONE); + } + } + + @Override + public void setScreenNormal() { + screen = SCREEN_NORMAL; + fullscreenButton.setImageResource(cn.jzvd.R.drawable.jz_enlarge); + backButton.setVisibility(View.VISIBLE); + tinyBackImageView.setVisibility(View.INVISIBLE); + changeStartButtonSize((int) getResources().getDimension(cn.jzvd.R.dimen.jz_start_button_w_h_normal)); + batteryTimeLayout.setVisibility(View.GONE); + clarity.setVisibility(View.GONE); + fullscreenButton.setVisibility(View.VISIBLE); + next_bottom.setVisibility(View.GONE); + tvSpeed.setVisibility(View.GONE); + tvSelectPart.setVisibility(View.GONE); + lock.setVisibility(View.GONE); + changeUiToPlayingShow(); + startDismissControlViewTimer(); + } + + @Override + public void setScreenFullscreen() { + super.setScreenFullscreen(); + next_bottom.setVisibility(View.VISIBLE); + tvSpeed.setVisibility(View.VISIBLE); + tvSelectPart.setVisibility(View.VISIBLE); + fullscreenButton.setVisibility(View.GONE); + lock.setVisibility(View.VISIBLE); + changeUiToPlayingShow(); + startDismissControlViewTimer(); + if (jzDataSource.objects == null) { + Object[] object = {1}; + jzDataSource.objects = object; + } + } + + @Override + public void onStatePlaying() { + super.onStatePlaying(); + titleTextView.setVisibility(VISIBLE); + screenIV.setVisibility(VISIBLE); + } + + @Override + public void onAutoCompletion() { + Runtime.getRuntime().gc(); + Log.i(TAG, "onAutoCompletion " + " [" + this.hashCode() + "] "); + cancelProgressTimer(); + dismissBrightnessDialog(); + dismissProgressDialog(); + dismissVolumeDialog(); + onStateAutoComplete(); + JZUtils.scanForActivity(getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + JZUtils.saveProgress(getContext(), jzDataSource.getCurrentUrl(), 0); + cancelDismissControlViewTimer(); + } + + @Override + public void onStateAutoComplete() { + super.onStateAutoComplete(); + if (isNext){ + startDismissNextViewTimer(); + } + } + + @Override + public void changeUiToPlayingShow() { + switch (screen) { + case SCREEN_NORMAL: + setAllControlsVisiblity(View.VISIBLE, View.VISIBLE, View.VISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + updateStartImage(); + break; + case SCREEN_FULLSCREEN: + if (!isLock) { + setAllControlsVisiblity(View.VISIBLE, View.VISIBLE, View.VISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + updateStartImage(); + } + lock.setVisibility(View.VISIBLE); + break; + case SCREEN_TINY: + break; + } + } + + + @Override + public void changeUiToPlayingClear() { + switch (screen) { + case SCREEN_NORMAL: + setAllControlsVisiblity(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, + View.INVISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); + break; + case SCREEN_FULLSCREEN: + setAllControlsVisiblity(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + lock.setVisibility(View.INVISIBLE); + break; + case SCREEN_TINY: + break; + } + } + + @Override + public void changeUiToPauseShow() { + switch (screen) { + case SCREEN_NORMAL: + setAllControlsVisiblity(View.VISIBLE, View.VISIBLE, View.VISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + updateStartImage(); + break; + case SCREEN_FULLSCREEN: + setAllControlsVisiblity(View.VISIBLE, View.VISIBLE, View.VISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + lock.setVisibility(View.VISIBLE); + updateStartImage(); + break; + case SCREEN_TINY: + break; + } + + } + + @Override + public void changeUiToPauseClear() { + switch (screen) { + case SCREEN_NORMAL: + setAllControlsVisiblity(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, + View.INVISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); + break; + case SCREEN_FULLSCREEN: + setAllControlsVisiblity(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, + View.INVISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); + lock.setVisibility(View.INVISIBLE); + break; + case SCREEN_TINY: + break; + } + } + + @Override + public void changeUiToComplete() { + switch (screen) { + case SCREEN_NORMAL: + setAllControlsVisiblity(View.VISIBLE, View.INVISIBLE, View.VISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + updateStartImage(); + break; + case SCREEN_FULLSCREEN: + setAllControlsVisiblity(View.VISIBLE, View.INVISIBLE, View.VISIBLE, + View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); + updateStartImage(); + break; + case SCREEN_TINY: + break; + } + } + + @Override + public void onClickUiToggle() { + if (bottomContainer.getVisibility() != View.VISIBLE) { + setSystemTimeAndBattery(); + clarity.setText(jzDataSource.getCurrentKey().toString()); + } + if (state == STATE_PREPARING) { + changeUiToPreparing(); + if (bottomContainer.getVisibility() == View.VISIBLE) { + } else { + setSystemTimeAndBattery(); + } + } else if (state == STATE_PLAYING) { + if (isLock) { + if (lock.getVisibility() == View.VISIBLE) { + lock.setVisibility(INVISIBLE); + } else { + lock.setVisibility(View.VISIBLE); + goneLock(); + } + } else { + if (bottomContainer.getVisibility() == View.VISIBLE) { + changeUiToPlayingClear(); + } else { + changeUiToPlayingShow(); + } + } + } else if (state == STATE_PAUSE) { + if (isLock) { + if (lock.getVisibility() == View.VISIBLE) { + lock.setVisibility(INVISIBLE); + } else { + lock.setVisibility(View.VISIBLE); + goneLock(); + } + } else { + if (bottomContainer.getVisibility() == View.VISIBLE) { + changeUiToPauseClear(); + } else { + changeUiToPauseShow(); + } + } + } + } + + @Override + public void changeStartButtonSize(int size) { + //修改框架原本的图标大小 + size = (int) getResources().getDimension(R.dimen.jz_start_button_w_h_normal_ag); + ViewGroup.LayoutParams lp = startButton.getLayoutParams(); + lp.height = size; + lp.width = size; + lp = loadingProgressBar.getLayoutParams(); + lp.height = size; + lp.width = size; + } + + @Override + public void setAllControlsVisiblity(int topCon, int bottomCon, int startBtn, int loadingPro, int thumbImg, int bottomPro, int retryLayout) { + topContainer.setVisibility(topCon); + bottomContainer.setVisibility(bottomCon); + startButton.setVisibility(startBtn); + loadingView.setVisibility(loadingPro); + posterImageView.setVisibility(thumbImg); + bottomProgressBar.setVisibility(bottomPro); + mRetryLayout.setVisibility(retryLayout); + fastForward.setVisibility(startBtn); + quickRetreat.setVisibility(startBtn); + } + + /** + * 是否有网络并显示布局 + */ + public boolean isHaveNetWork() { + if (!NetworkUtils.isConnected(this.getApplicationContext()) || !NetworkUtils.isAvailable(this.getApplicationContext())) { + return false; + } + return true; + } + + + /** + * 点击播放下一集时设置按钮状态 + * + * @param isNext + */ + public void changeNextBottonUi(boolean isNext) { + this.isNext = isNext; + if (isNext) { + next_bottom.setImageResource(R.mipmap.ag_btn_movie_next); + next_bottom.setClickable(true); + } else { + next_bottom.setImageResource(R.mipmap.ag_btn_movie_unll_next); + next_bottom.setClickable(false); + } + } + + + public void hideProgress() { + if (loadingView != null) { + loadingView.setVisibility(GONE); + } + } + + public void showProgress() { + if (loadingView.getVisibility() != View.VISIBLE) { + loadingView.setVisibility(VISIBLE); + } + } + + public class DismissLockViewTimerTask extends TimerTask { + + @Override + public void run() { + dismissLockView(); + } + } + + public class DismissNextViewTimerTask extends TimerTask{ + + @Override + public void run() { + post(()->{ + if (nextTimerDate<=0){ + dismissNextView(); + cancelDismissNextViewTimer(); + if (jzVideoListener != null) { + jzVideoListener.nextClick(); + } + }else { + next_set.setText(nextTimerDate + "秒后播放下一集"); + nextTimerDate--; + } + }); + } + } + + + public void startDismissLockViewTimer() { + cancelDismissLockViewTimer(); + mDismissLockViewTimer = new Timer(); + mDismissLockViewTimerTask = new DismissLockViewTimerTask(); + mDismissLockViewTimer.schedule(mDismissLockViewTimerTask, 2500); + } + + public void cancelDismissLockViewTimer() { + if (mDismissLockViewTimer != null) { + mDismissLockViewTimer.cancel(); + } + if (mDismissLockViewTimerTask != null) { + mDismissLockViewTimerTask.cancel(); + } + + } + + public void startDismissNextViewTimer() { + cancelDismissLockViewTimer(); + nextTimerDate=3; + mDismissNextViewTimer = new Timer(); + mDismissNextViewTimerTask = new DismissNextViewTimerTask(); + mDismissNextViewTimer.schedule(mDismissNextViewTimerTask, 0,1000); + } + + public void cancelDismissNextViewTimer() { + if (mDismissNextViewTimer != null) { + mDismissNextViewTimer.cancel(); + } + if (mDismissNextViewTimerTask != null) { + mDismissNextViewTimerTask.cancel(); + } + } + + private void dismissNextView(){ + replayTextView.setVisibility(GONE); + next_set.setVisibility(View.GONE); + } + + /** + * 改变倍数之后 + */ + public void speedChange(float speed) { + if (speed == 1f) { + tvSpeed.setText("倍数"); + } else { + tvSpeed.setText(speed + "X"); + } + } + + public interface JzVideoListener { + + void nextClick(); + + void backClick(); + + void throwingScreenClick(); + + void selectPartsClick(); + + void speedClick(); + + } +} diff --git a/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/ActivityApiUIBigChangeAG.java b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/ActivityApiUIBigChangeAG.java new file mode 100644 index 00000000..ab77cbc1 --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/ActivityApiUIBigChangeAG.java @@ -0,0 +1,341 @@ +package cn.jzvd.demo.BigUIChangeAG; + +import android.os.Bundle; +import android.view.Gravity; +import android.view.MenuItem; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.google.android.material.tabs.TabLayout; + +import java.util.ArrayList; +import java.util.List; + +import cn.jzvd.JZDataSource; +import cn.jzvd.Jzvd; +import cn.jzvd.JzvdStd; +import cn.jzvd.demo.CustomMedia.JZMediaExo; +import cn.jzvd.demo.R; +import cn.jzvd.demo.ScreenRotateUtils; + +public class ActivityApiUIBigChangeAG extends AppCompatActivity implements AGVideo.JzVideoListener, ScreenRotateUtils.OrientationChangeListener +,VideoSpeedPopup.SpeedChangeListener,VideoEpisodePopup.EpisodeClickListener{ + private AGVideo mPlayer; + private JZDataSource mJzDataSource; + private List episodeList; + private TabLayout episodes; + private int playingNum=0; + //倍数弹窗 + private VideoSpeedPopup videoSpeedPopup; + private VideoEpisodePopup videoEpisodePopup; + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getSupportActionBar().hide(); + setContentView(R.layout.activity_ui_big_change_ag); + initVideoData(); + initView(); + ScreenRotateUtils.getInstance(this.getApplicationContext()).setOrientationChangeListener(this); + } + + private void initView(){ + episodes = findViewById(R.id.video_episodes); + mPlayer=findViewById(R.id.ag_player); + initEpisodesTablayout(); + mPlayer.setJzVideoListener(this); + mJzDataSource = new JZDataSource(episodeList.get(0).getVideoUrl(), episodeList.get(0).getVideoName()); + mPlayer.setUp(mJzDataSource + , JzvdStd.SCREEN_NORMAL, JZMediaExo.class); + mPlayer.startVideo(); + } + + private void initEpisodesTablayout(){ + episodes.clearOnTabSelectedListeners(); + episodes.removeAllTabs(); + for (int i = 0; i < episodeList.size(); i++) { + episodes.addTab(episodes.newTab().setText(String.valueOf((i + 1)))); + } + //用来循环适配器中的视图总数 + for (int i = 0; i < episodes.getTabCount(); i++) { + //获取每一个tab对象 + TabLayout.Tab tabAt = episodes.getTabAt(i); + //将每一个条目设置我们自定义的视图 + tabAt.setCustomView(R.layout.tab_video_episodes); + //通过tab对象找到自定义视图的ID + TextView textView = tabAt.getCustomView().findViewById(R.id.tab_video_episodes_tv); + //设置tab上的文字 + textView.setText(episodes.getTabAt(i).getText()); + int current = playingNum; + if (i == current) { + //选中后字体 + textView.setTextColor(getResources().getColor(R.color.ThemeColor)); + } else { + textView.setTextColor(getResources().getColor(R.color.font_color)); + + } + } + + episodes.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + //定义方法,判断是否选中 + int tag = Integer.parseInt(tab.getText().toString()); + AGEpsodeEntity entity=episodeList.get(tag-1); + mJzDataSource=new JZDataSource(entity.getVideoUrl(),entity.getVideoName()); + updateTabView(tab, true); + playChangeUrl(); + isNext(tab.getPosition()); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + //定义方法,判断是否选中 + updateTabView(tab, false); + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + } + }); + isNext(episodes.getSelectedTabPosition()); + } + + + + + @Override + protected void onResume() { + Jzvd.goOnPlayOnResume(); + super.onResume(); + ScreenRotateUtils.getInstance(this).start(this); + } + + @Override + public void onBackPressed() { + if (Jzvd.backPress()) { + return; + } + super.onBackPressed(); + } + + @Override + protected void onPause() { + super.onPause(); + ScreenRotateUtils.getInstance(this).stop(); + Jzvd.goOnPlayOnPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + Jzvd.releaseAllVideos(); + ScreenRotateUtils.getInstance(this.getApplicationContext()).setOrientationChangeListener(null); + } + + /** + * 用来改变tabLayout选中后的字体大小及颜色 + * + * @param tab + * @param isSelect + */ + private void updateTabView(TabLayout.Tab tab, boolean isSelect) { + //找到自定义视图的控件ID + TextView tv_tab = tab.getCustomView().findViewById(R.id.tab_video_episodes_tv); + if (isSelect) { + //设置标签选中 + tv_tab.setSelected(true); + //选中后字体 + tv_tab.setTextColor(getResources().getColor(R.color.ThemeColor)); + } else { + //设置标签取消选中 + tv_tab.setSelected(false); + //恢复为默认字体 + tv_tab.setTextColor(getResources().getColor(R.color.font_color)); + } + } + + /** + * 判断是否有下一集 + */ + private void isNext(int position) { + //判断是否还有下一集 + if (position == (episodeList.size() - 1)) { + mPlayer.changeNextBottonUi(false); + } else { + mPlayer.changeNextBottonUi(true); + } + } + + /** + * 更换播放地址 + */ + private void playChangeUrl() { + long progress = 0; + mPlayer.changeUrl(mJzDataSource, progress); + } + + @Override + public void orientationChange(int orientation) { + if (Jzvd.CURRENT_JZVD != null + && (mPlayer.state == Jzvd.STATE_PLAYING || mPlayer.state == Jzvd.STATE_PAUSE) + && mPlayer.screen != Jzvd.SCREEN_TINY) { + if (orientation >= 45 && orientation <= 315 && mPlayer.screen == Jzvd.SCREEN_NORMAL) { + changeScreenFullLandscape(ScreenRotateUtils.orientationDirection); + } else if (((orientation >= 0 &&orientation <45) || orientation > 315) && mPlayer.screen == Jzvd.SCREEN_FULLSCREEN) { + changeScrenNormal(); + } + } + } + + + /** + * 竖屏并退出全屏 + */ + private void changeScrenNormal() { + if (mPlayer != null && mPlayer.screen == Jzvd.SCREEN_FULLSCREEN) { + mPlayer.autoQuitFullscreen(); + } + } + + /** + * 横屏 + */ + private void changeScreenFullLandscape(float x) { + //从竖屏状态进入横屏 + if (mPlayer != null && mPlayer.screen != Jzvd.SCREEN_FULLSCREEN) { + if ((System.currentTimeMillis() - Jzvd.lastAutoFullscreenTime) > 2000) { + mPlayer.autoFullscreen(x); + Jzvd.lastAutoFullscreenTime = System.currentTimeMillis(); + } + } + } + + + /** + * 关闭倍速播放弹窗和选集弹窗 + */ + private void dismissSpeedPopAndEpisodePop() { + if (videoSpeedPopup != null) { + videoSpeedPopup.dismiss(); + } + if (videoEpisodePopup != null) { + videoEpisodePopup.dismiss(); + } + } + + /** + * 改变播放倍速 + * + * @param speed + */ + private void changeSpeed(float speed) { + Object[] object = {speed}; + mPlayer.mediaInterface.setSpeed(speed); + mJzDataSource.objects[0] = object; + Toast.makeText(this,"正在以" + speed + "X倍速播放",Toast.LENGTH_SHORT).show(); + mPlayer.speedChange(speed); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + break; + } + return super.onOptionsItemSelected(item); + } + + + @Override + public void nextClick() { + int position = episodes.getSelectedTabPosition() + 1; + AGEpsodeEntity entity=episodeList.get(position); + mJzDataSource=new JZDataSource(entity.getVideoUrl(),entity.getVideoName()); + TabLayout.Tab tab = episodes.getTabAt(position); + if (tab != null) { + tab.select(); + } + } + + @Override + public void backClick() { + if (mPlayer.screen == mPlayer.SCREEN_FULLSCREEN) { + dismissSpeedPopAndEpisodePop(); + AGVideo.backPress(); + } else { + finish(); + } + } + + @Override + public void throwingScreenClick() { + Toast.makeText(this, "投屏", Toast.LENGTH_SHORT).show(); + } + + + @Override + public void selectPartsClick() { + if (videoEpisodePopup == null) { + videoEpisodePopup = new VideoEpisodePopup(this, episodeList); + videoEpisodePopup.setEpisondeClickListener(this); + } + videoEpisodePopup.setPlayNum(1); + videoEpisodePopup.showAtLocation(getWindow().getDecorView(), Gravity.RIGHT,0,0); + } + + @Override + public void speedClick() { + if (videoSpeedPopup==null){ + videoSpeedPopup=new VideoSpeedPopup(this); + videoSpeedPopup.setSpeedChangeListener(this); + } + videoSpeedPopup.showAtLocation(getWindow().getDecorView(), Gravity.RIGHT,0,0); + } + + + + @Override + public void speedChange(float speed) { + changeSpeed(speed); + } + + @Override + public void onEpisodeClickListener(AGEpsodeEntity entity, int position) { + TabLayout.Tab tab=episodes.getTabAt(position); + if (tab!=null){ + tab.select(); + } + } + private void initVideoData(){ + episodeList=new ArrayList<>(); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/QSeTc4nj/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第01集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/Qtgy7SjP/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第02集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/AXkWBoLb/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第03集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/P6oGsmgK/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第04集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/PdWWKahH/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第05集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/eoCI1M65/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第06集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/pXP2NPFc/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第07集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/aA6UwOvW/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","谢尔顿 第一季 第08集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/lLmVLxJQ/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第09集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/Ddt92vAR/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第10集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/90R6x9rF/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第11集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/nMfWnUQr/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第12集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/myJUPq6V/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第13集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/fC10illG/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第14集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/7jA5lpyB/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第15集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/6MKcJRT3/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第16集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/qPeGRErs/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第17集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/mhBHwiIw/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第18集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/vAYMt0AA/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第19集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/7R1KU2R2/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第20集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/bkuLrOEX/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第21集")); + episodeList.add(new AGEpsodeEntity("http://agmjjzyi.ixibeiren.com/20181108/SuL66DB3/index.m3u8?wsSecret=3158b8e5e257118f6132f86cf45bf8aa&wsTime=1584361106","小谢尔顿 第一季 第22集")); + } + + + +} diff --git a/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoEpisodeAdapter.java b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoEpisodeAdapter.java new file mode 100644 index 00000000..b355814a --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoEpisodeAdapter.java @@ -0,0 +1,76 @@ +package cn.jzvd.demo.BigUIChangeAG; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +import cn.jzvd.demo.R; + +public class VideoEpisodeAdapter extends RecyclerView.Adapter { + private Context mC; + private List entities; + private OnItemClickListener mOnItemClickListener; + + public VideoEpisodeAdapter(Context context,List entities) { + this.mC=context; + this.entities = entities; + } + + public void setmOnItemClickListener(OnItemClickListener mOnItemClickListener) { + this.mOnItemClickListener = mOnItemClickListener; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_video_episode,parent,false); + ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + holder.textView.setText(position+1+""); + if (entities.get(position).isPlay()){ + holder.textView.setTextColor(mC.getResources().getColor(R.color.ThemeColor)); + holder.textView.setBackground(mC.getResources().getDrawable(R.drawable.bg_video_episodes_check)); + }else { + holder.textView.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + holder.textView.setBackground(mC.getResources().getDrawable(R.drawable.bg_video_episodes_uncheck)); + } + + holder.textView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mOnItemClickListener!=null){ + mOnItemClickListener.onItemClicked(v,position); + } + } + }); + } + + @Override + public int getItemCount() { + return entities.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + TextView textView; + public ViewHolder(@NonNull View itemView) { + super(itemView); + textView=itemView.findViewById(R.id.item_episodeNum); + } + } + + + public interface OnItemClickListener { + void onItemClicked(View view, int position); + } +} diff --git a/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoEpisodePopup.java b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoEpisodePopup.java new file mode 100644 index 00000000..b3d47b1c --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoEpisodePopup.java @@ -0,0 +1,169 @@ +package cn.jzvd.demo.BigUIChangeAG; + +import android.content.Context; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.PopupWindow; + +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +import cn.jzvd.demo.R; +import cn.jzvd.demo.utils.DpOrPxUtils; + +public class VideoEpisodePopup extends PopupWindow { + private static final int COMPLETED = 0; + private Context mC; + private LinearLayout main; + private LayoutInflater inflater; + private View contentView; + private RecyclerView episodeRecycler; + private VideoEpisodeAdapter episodeAdapter; + private List episodeList; + private EpisodeClickListener episondeClickListener; + /** + * 当前正在播放的集数 + */ + private int playNum = 0; + private Timer mDismissTimer; + protected DismissTimerTask mDismissTimerTask; + public EpisodeClickListener getEpisondeClickListener() { + return episondeClickListener; + } + + public void setEpisondeClickListener(EpisodeClickListener episondeClickListener) { + this.episondeClickListener = episondeClickListener; + } + + public VideoEpisodePopup(Context context, List entities){ + super(context); + this.mC=context; + mC=context; + this.episodeList=entities; + inflater=(LayoutInflater)mC.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + contentView=inflater.inflate(R.layout.popup_video_episode,null); + setContentView(contentView); + setHeight(WindowManager.LayoutParams.MATCH_PARENT); + setWidth(DpOrPxUtils.dip2px(context,320)); + setOutsideTouchable(true); + //不设置该属性,弹窗于屏幕边框会有缝隙并且背景不是半透明 + setBackgroundDrawable(new BitmapDrawable()); + main=contentView.findViewById(R.id.video_main); + episodeRecycler = contentView.findViewById(R.id.video_episode); + episodeRecycler.setLayoutManager(new GridLayoutManager(context, 5)); + episodeAdapter = new VideoEpisodeAdapter(mC,episodeList); + episodeRecycler.setAdapter(episodeAdapter); + + episodeAdapter.setmOnItemClickListener(new VideoEpisodeAdapter.OnItemClickListener() { + @Override + public void onItemClicked(View view, int position) { + if (episondeClickListener!=null){ + episondeClickListener.onEpisodeClickListener(episodeList.get(position),position); + } + //更换当前正在播放的集数 + if (playNum<1){ + playNum=1; + } + episodeList.get(playNum - 1).setPlay(false); + playNum = position + 1; + episodeList.get(playNum - 1).setPlay(true); + episodeAdapter.notifyDataSetChanged(); + } + }); + + main.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + startDismissTimer(); + return false; + } + }); + episodeRecycler.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + startDismissTimer(); + return false; + } + }); + } + + @Override + public void showAtLocation(View parent, int gravity, int x, int y) { + super.showAtLocation(parent, gravity, x, y); + startDismissTimer(); + } + + @Override + public void dismiss() { + super.dismiss(); + cancelDismissTimer(); + } + + public void setPlayNum(int playNum) { + if (this.playNum != 0) { + episodeList.get(this.playNum - 1).setPlay(false); + this.playNum = playNum; + episodeList.get(playNum - 1).setPlay(true); + } else { + this.playNum = playNum; + episodeList.get(this.playNum - 1).setPlay(true); + } + } + + public void startDismissTimer() { + cancelDismissTimer(); + mDismissTimer = new Timer(); + mDismissTimerTask = new DismissTimerTask(); + mDismissTimer.schedule(mDismissTimerTask, 2500); + } + + public void cancelDismissTimer() { + if (mDismissTimer != null) { + mDismissTimer.cancel(); + } + if (mDismissTimerTask != null) { + mDismissTimerTask.cancel(); + } + + } + + + public interface EpisodeClickListener { + /** + * 选集发生变化 + * @param entity + * @param position + */ + void onEpisodeClickListener(AGEpsodeEntity entity, int position); + } + + public class DismissTimerTask extends TimerTask { + + @Override + public void run() { + Message message = new Message(); + message.what = COMPLETED; + handler.sendMessage(message); + } + } + + private Handler handler = new Handler(){ + @Override + public void handleMessage(Message msg) { + if (msg.what == COMPLETED) { + dismiss(); + + } + } + }; +} diff --git a/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoSpeedPopup.java b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoSpeedPopup.java new file mode 100644 index 00000000..9b7da996 --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/BigUIChangeAG/VideoSpeedPopup.java @@ -0,0 +1,159 @@ +package cn.jzvd.demo.BigUIChangeAG; + +import android.content.Context; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.View; +import android.view.WindowManager; +import android.widget.PopupWindow; +import android.widget.TextView; + +import java.util.Timer; +import java.util.TimerTask; + +import cn.jzvd.demo.R; +import cn.jzvd.demo.utils.DpOrPxUtils; + +public class VideoSpeedPopup extends PopupWindow implements View.OnClickListener { + private static final int COMPLETED = 0; + private TextView speedOne,speedTwo,speedThree,speedFour,speedFive; + private SpeedChangeListener speedChangeListener; + private Context mC; + private LayoutInflater inflater; + private View contentView; + private Timer mDismissTimer; + protected DismissTimerTask mDismissTimerTask; + public VideoSpeedPopup(Context context){ + super(context); + mC=context; + inflater=(LayoutInflater)mC.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + contentView=inflater.inflate(R.layout.popup_video_speed,null); + setContentView(contentView); + setHeight(WindowManager.LayoutParams.MATCH_PARENT); + setWidth(DpOrPxUtils.dip2px(context,200)); + speedOne=contentView.findViewById(R.id.pop_speed_1); + speedTwo=contentView.findViewById(R.id.pop_speed_1_25); + speedThree=contentView.findViewById(R.id.pop_speed_1_5); + speedFour=contentView.findViewById(R.id.pop_speed_1_75); + speedFive=contentView.findViewById(R.id.pop_speed_2); + setOutsideTouchable(true); + //不设置该属性,弹窗于屏幕边框会有缝隙并且背景不是半透明 + setBackgroundDrawable(new BitmapDrawable()); + speedOne.setOnClickListener(this); + speedTwo.setOnClickListener(this); + speedThree.setOnClickListener(this); + speedFour.setOnClickListener(this); + speedFive.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (speedChangeListener!=null){ + switch (v.getId()){ + case R.id.pop_speed_1: + speedOne.setTextColor(mC.getResources().getColor(R.color.ThemeColor)); + speedTwo.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedThree.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFour.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFive.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedChangeListener.speedChange(1f); + break; + case R.id.pop_speed_1_25: + speedOne.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedTwo.setTextColor(mC.getResources().getColor(R.color.ThemeColor)); + speedThree.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFour.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFive.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedChangeListener.speedChange(1.25f); + break; + case R.id.pop_speed_1_5: + speedOne.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedTwo.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedThree.setTextColor(mC.getResources().getColor(R.color.ThemeColor)); + speedFour.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFive.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedChangeListener.speedChange(1.5f); + break; + case R.id.pop_speed_1_75: + speedOne.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedTwo.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedThree.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFour.setTextColor(mC.getResources().getColor(R.color.ThemeColor)); + speedFive.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedChangeListener.speedChange(1.75f); + break; + case R.id.pop_speed_2: + speedOne.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedTwo.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedThree.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFour.setTextColor(mC.getResources().getColor(R.color.colorWhite)); + speedFive.setTextColor(mC.getResources().getColor(R.color.ThemeColor)); + speedChangeListener.speedChange(2f); + break; + } + } + } + + @Override + public void showAtLocation(View parent, int gravity, int x, int y) { + super.showAtLocation(parent, gravity, x, y); + startDismissTimer(); + } + + @Override + public void dismiss() { + super.dismiss(); + cancelDismissTimer(); + } + + public void startDismissTimer() { + cancelDismissTimer(); + mDismissTimer = new Timer(); + mDismissTimerTask = new DismissTimerTask(); + mDismissTimer.schedule(mDismissTimerTask, 2500); + } + + public void cancelDismissTimer() { + if (mDismissTimer != null) { + mDismissTimer.cancel(); + } + if (mDismissTimerTask != null) { + mDismissTimerTask.cancel(); + } + + } + + public SpeedChangeListener getSpeedChangeListener() { + return speedChangeListener; + } + + public void setSpeedChangeListener(SpeedChangeListener speedChangeListener) { + this.speedChangeListener = speedChangeListener; + } + + public interface SpeedChangeListener{ + void speedChange(float speed); + } + + public class DismissTimerTask extends TimerTask { + + @Override + public void run() { + Message message = new Message(); + message.what = COMPLETED; + handler.sendMessage(message); + } + } + + private Handler handler = new Handler(){ + @Override + public void handleMessage(Message msg) { + if (msg.what == COMPLETED) { + dismiss(); + + } + } + }; +} diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/AutoPlayUtils.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/AutoPlayUtils.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/AutoPlayUtils.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/AutoPlayUtils.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAssert.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAssert.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAssert.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAssert.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAutoCompleteAfterFullscreen.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAutoCompleteAfterFullscreen.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAutoCompleteAfterFullscreen.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdAutoCompleteAfterFullscreen.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdList.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdList.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdList.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdList.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdLockScreen.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdLockScreen.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdLockScreen.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdLockScreen.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdMp3.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdMp3.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdMp3.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdMp3.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdRv.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdRv.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdRv.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdRv.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowShareButtonAfterFullscreen.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowShareButtonAfterFullscreen.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowShareButtonAfterFullscreen.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowShareButtonAfterFullscreen.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTextureViewAfterAutoComplete.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTextureViewAfterAutoComplete.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTextureViewAfterAutoComplete.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTextureViewAfterAutoComplete.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTitleAfterFullscreen.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTitleAfterFullscreen.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTitleAfterFullscreen.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdShowTitleAfterFullscreen.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdSpeed.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdSpeed.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdSpeed.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdSpeed.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTikTok.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTikTok.java similarity index 93% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTikTok.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTikTok.java index 9ee5f093..d5102ab5 100644 --- a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTikTok.java +++ b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTikTok.java @@ -80,17 +80,17 @@ public void onClickUiToggle() { public void updateStartImage() { if (state == STATE_PLAYING) { startButton.setVisibility(VISIBLE); - startButton.setImageResource(R.drawable.ic_play_tiktok); + startButton.setImageResource(R.drawable.tiktok_play_tiktok); replayTextView.setVisibility(GONE); } else if (state == STATE_ERROR) { startButton.setVisibility(INVISIBLE); replayTextView.setVisibility(GONE); } else if (state == STATE_AUTO_COMPLETE) { startButton.setVisibility(VISIBLE); - startButton.setImageResource(R.drawable.ic_play_tiktok); + startButton.setImageResource(R.drawable.tiktok_play_tiktok); replayTextView.setVisibility(VISIBLE); } else { - startButton.setImageResource(R.drawable.ic_play_tiktok); + startButton.setImageResource(R.drawable.tiktok_play_tiktok); replayTextView.setVisibility(GONE); } } diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTinyWindow.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTinyWindow.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTinyWindow.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdTinyWindow.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdVolumeAfterFullscreen.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdVolumeAfterFullscreen.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdVolumeAfterFullscreen.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/JzvdStdVolumeAfterFullscreen.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/MyJzvdStd.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/MyJzvdStd.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/MyJzvdStd.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/MyJzvdStd.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomJzvd/ViewAttr.java b/demo/src/main/java/cn/jzvd/demo/CustomJzvd/ViewAttr.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomJzvd/ViewAttr.java rename to demo/src/main/java/cn/jzvd/demo/CustomJzvd/ViewAttr.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java b/demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java similarity index 92% rename from app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java rename to demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java index b2c59244..e22b8fe9 100755 --- a/app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java +++ b/demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java @@ -38,6 +38,7 @@ import cn.jzvd.JZMediaInterface; import cn.jzvd.Jzvd; +import cn.jzvd.demo.BigUIChangeAG.AGVideo; import cn.jzvd.demo.R; /** @@ -112,7 +113,12 @@ public void prepare() { simpleExoPlayer.setPlayWhenReady(true); callback = new onBufferingUpdate(); - simpleExoPlayer.setVideoSurface(new Surface(jzvd.textureView.getSurfaceTexture())); + if (jzvd.textureView != null) { + SurfaceTexture surfaceTexture=jzvd.textureView.getSurfaceTexture(); + if (surfaceTexture!=null){ + simpleExoPlayer.setVideoSurface(new Surface(surfaceTexture)); + } + } }); } @@ -139,10 +145,19 @@ public boolean isPlaying() { @Override public void seekTo(long time) { + if (simpleExoPlayer==null){ + return; + } if (time != previousSeek) { + if (time >= simpleExoPlayer.getBufferedPosition()) { + if (jzvd instanceof AGVideo) { + ((AGVideo) jzvd).showProgress(); + } + } simpleExoPlayer.seekTo(time); previousSeek = time; jzvd.seekToInAdvance = time; + } } @@ -217,6 +232,9 @@ public void onPlayerStateChanged(final boolean playWhenReady, final int playback } break; case Player.STATE_BUFFERING: { + if (jzvd instanceof AGVideo) { + ((AGVideo) jzvd).showProgress(); + } handler.post(callback); } break; @@ -268,7 +286,11 @@ public void onSeekProcessed() { @Override public void setSurface(Surface surface) { - simpleExoPlayer.setVideoSurface(surface); + if (simpleExoPlayer!=null){ + simpleExoPlayer.setVideoSurface(surface); + }else { + Log.e("AGVideo","simpleExoPlayer为空"); + } } @Override diff --git a/app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaIjk.java b/demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaIjk.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaIjk.java rename to demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaIjk.java diff --git a/app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaSystemAssertFolder.java b/demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaSystemAssertFolder.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaSystemAssertFolder.java rename to demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaSystemAssertFolder.java diff --git a/app/src/main/java/cn/jzvd/demo/FragmentDemo.java b/demo/src/main/java/cn/jzvd/demo/FragmentDemo.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/FragmentDemo.java rename to demo/src/main/java/cn/jzvd/demo/FragmentDemo.java diff --git a/app/src/main/java/cn/jzvd/demo/ScreenRotateUtils.java b/demo/src/main/java/cn/jzvd/demo/ScreenRotateUtils.java similarity index 95% rename from app/src/main/java/cn/jzvd/demo/ScreenRotateUtils.java rename to demo/src/main/java/cn/jzvd/demo/ScreenRotateUtils.java index e116ffab..340b7ecb 100644 --- a/app/src/main/java/cn/jzvd/demo/ScreenRotateUtils.java +++ b/demo/src/main/java/cn/jzvd/demo/ScreenRotateUtils.java @@ -45,11 +45,11 @@ public static ScreenRotateUtils getInstance(Context context) { return instance; } - void setOrientationChangeListener(OrientationChangeListener changeListener) { + public void setOrientationChangeListener(OrientationChangeListener changeListener) { this.changeListener = changeListener; } - interface OrientationChangeListener { + public interface OrientationChangeListener { void orientationChange(int orientation); } @@ -113,7 +113,7 @@ public void onAccuracyChanged(Sensor sensor, int i) { * * @param activity */ - void start(Activity activity) { + public void start(Activity activity) { mActivity = activity; sm.registerListener(listener, sensor, SensorManager.SENSOR_DELAY_NORMAL); } @@ -121,7 +121,7 @@ void start(Activity activity) { /** * 注销监听 */ - void stop() { + public void stop() { sm.unregisterListener(listener); mActivity = null; // 防止内存泄漏 } diff --git a/app/src/main/java/cn/jzvd/demo/VideoConstant.java b/demo/src/main/java/cn/jzvd/demo/VideoConstant.java similarity index 99% rename from app/src/main/java/cn/jzvd/demo/VideoConstant.java rename to demo/src/main/java/cn/jzvd/demo/VideoConstant.java index 9950ee6a..fc6d0c29 100644 --- a/app/src/main/java/cn/jzvd/demo/VideoConstant.java +++ b/demo/src/main/java/cn/jzvd/demo/VideoConstant.java @@ -1,5 +1,7 @@ package cn.jzvd.demo; +import cn.jzvd.demo.BigUIChangeAG.AGVideo; + /** * Created by shengjun on 16/9/10. */ @@ -265,5 +267,4 @@ public class VideoConstant { "饺子好喜欢" } }; - } diff --git a/app/src/main/java/cn/jzvd/demo/ViewMoveHelper.java b/demo/src/main/java/cn/jzvd/demo/ViewMoveHelper.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/ViewMoveHelper.java rename to demo/src/main/java/cn/jzvd/demo/ViewMoveHelper.java diff --git a/app/src/main/java/cn/jzvd/demo/tiktok/ActivityTikTok.java b/demo/src/main/java/cn/jzvd/demo/tiktok/ActivityTikTok.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/tiktok/ActivityTikTok.java rename to demo/src/main/java/cn/jzvd/demo/tiktok/ActivityTikTok.java diff --git a/app/src/main/java/cn/jzvd/demo/tiktok/AdapterTikTokRecyclerView.java b/demo/src/main/java/cn/jzvd/demo/tiktok/AdapterTikTokRecyclerView.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/tiktok/AdapterTikTokRecyclerView.java rename to demo/src/main/java/cn/jzvd/demo/tiktok/AdapterTikTokRecyclerView.java diff --git a/demo/src/main/java/cn/jzvd/demo/utils/DpOrPxUtils.java b/demo/src/main/java/cn/jzvd/demo/utils/DpOrPxUtils.java new file mode 100644 index 00000000..89b89ce6 --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/utils/DpOrPxUtils.java @@ -0,0 +1,18 @@ +package cn.jzvd.demo.utils; + +import android.content.Context; + +/** + * @author HRR + * @date 2019/12/19 + */ +public class DpOrPxUtils { + public static int dip2px(Context context, float dpValue) { + final float scale = context.getResources().getDisplayMetrics().density; + return (int) (dpValue * scale + 0.5f); + } + public static int px2dip(Context context, float pxValue) { + final float scale = context.getResources().getDisplayMetrics().density; + return (int) (pxValue / scale + 0.5f); + } +} diff --git a/demo/src/main/java/cn/jzvd/demo/utils/NetworkUtils.java b/demo/src/main/java/cn/jzvd/demo/utils/NetworkUtils.java new file mode 100644 index 00000000..be592e92 --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/utils/NetworkUtils.java @@ -0,0 +1,44 @@ +package cn.jzvd.demo.utils; + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; + +public class NetworkUtils { + /** + * 判断网络是否连接 + *

需添加权限 {@code }

+ * + * @param context 上下文 + * @return {@code true}: 是
{@code false}: 否 + */ + public static boolean isConnected(Context context) { + NetworkInfo info = getActiveNetworkInfo(context); + return info != null && info.isConnected(); + } + + /** + * 获取活动网络信息 + * + * @param context 上下文 + * @return NetworkInfo + */ + private static NetworkInfo getActiveNetworkInfo(Context context) { + ConnectivityManager cm = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + return cm.getActiveNetworkInfo(); + } + + + /** + * 判断网络是否可用 + *

需添加权限 {@code }

+ * + * @param context 上下文 + * @return {@code true}: 可用
{@code false}: 不可用 + */ + public static boolean isAvailable(Context context) { + NetworkInfo info = getActiveNetworkInfo(context); + return info != null && info.isAvailable(); + } +} diff --git a/demo/src/main/java/cn/jzvd/demo/widget/LoadingView.java b/demo/src/main/java/cn/jzvd/demo/widget/LoadingView.java new file mode 100644 index 00000000..6ba50a84 --- /dev/null +++ b/demo/src/main/java/cn/jzvd/demo/widget/LoadingView.java @@ -0,0 +1,110 @@ +package cn.jzvd.demo.widget; + +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; +import android.util.AttributeSet; +import android.view.View; +import android.view.animation.CycleInterpolator; +import android.view.animation.LinearInterpolator; + +import androidx.annotation.Nullable; + +import cn.jzvd.demo.R; +import cn.jzvd.demo.utils.DpOrPxUtils; + + +/** + * @author HRR + * @date 2019/12/19 + */ +public class LoadingView extends View { + //画笔 + private Paint mPaint; + //圆圈边框宽度 + private int borderWidth = DpOrPxUtils.dip2px(getContext(), 2); + //圆形的矩形轮廓 + RectF rectF; + //圆弧扫过的角度 + float sweepAngle; + float rotateAngle; + ObjectAnimator objectAnimator; + ObjectAnimator rotateAnimator; + AnimatorSet animatorSet; + + public LoadingView(Context context) { + super(context); + init(); + } + + public LoadingView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + init(); + } + + public LoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + private void init() { + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPaint.setStrokeCap(Paint.Cap.ROUND); + mPaint.setStrokeWidth(borderWidth); + mPaint.setStyle(Paint.Style.STROKE); + mPaint.setColor(getContext().getResources().getColor(R.color.ThemeColor)); + rectF = new RectF(); + objectAnimator = ObjectAnimator.ofFloat( + this, + "sweepAngle", + 0, 180); + objectAnimator.setRepeatCount(ValueAnimator.INFINITE); + objectAnimator.setInterpolator(new CycleInterpolator(0.5f)); + rotateAnimator = ObjectAnimator.ofFloat(this,"rotateAngle",0,720); + rotateAnimator.setInterpolator(new LinearInterpolator()); + rotateAnimator.setRepeatCount(ValueAnimator.INFINITE); + animatorSet = new AnimatorSet(); + animatorSet.playTogether(objectAnimator,rotateAnimator); + animatorSet.setDuration(1000); + animatorSet.start(); + } + + + @Override + protected void onDraw(Canvas canvas) { + //绘制圆弧 + canvas.rotate(rotateAngle,getHeight()/2,getWidth()/2); + canvas.drawArc(rectF, 0, sweepAngle, false, mPaint); + super.onDraw(canvas); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + //圆形的矩形轮廓 + rectF.set(borderWidth, borderWidth, getMeasuredWidth() - borderWidth, getMeasuredHeight() - borderWidth); + } + + public float getSweepAngle() { + return sweepAngle; + } + + public void setSweepAngle(float sweepAngle) { + this.sweepAngle = sweepAngle; + postInvalidate(); + } + + public float getRotateAngle() { + return rotateAngle; + } + + public void setRotateAngle(float rotateAngle) { + this.rotateAngle = rotateAngle; + postInvalidate(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/cn/jzvd/demo/widget/OnViewPagerListener.java b/demo/src/main/java/cn/jzvd/demo/widget/OnViewPagerListener.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/widget/OnViewPagerListener.java rename to demo/src/main/java/cn/jzvd/demo/widget/OnViewPagerListener.java diff --git a/app/src/main/java/cn/jzvd/demo/widget/ViewPagerLayoutManager.java b/demo/src/main/java/cn/jzvd/demo/widget/ViewPagerLayoutManager.java similarity index 100% rename from app/src/main/java/cn/jzvd/demo/widget/ViewPagerLayoutManager.java rename to demo/src/main/java/cn/jzvd/demo/widget/ViewPagerLayoutManager.java diff --git a/demo/src/main/res/drawable-xxhdpi/tiktok_comment_normal.png b/demo/src/main/res/drawable-xxhdpi/tiktok_comment_normal.png new file mode 100644 index 00000000..0f164a7d Binary files /dev/null and b/demo/src/main/res/drawable-xxhdpi/tiktok_comment_normal.png differ diff --git a/demo/src/main/res/drawable-xxhdpi/tiktok_douyin_icon.png b/demo/src/main/res/drawable-xxhdpi/tiktok_douyin_icon.png new file mode 100644 index 00000000..b2ed5470 Binary files /dev/null and b/demo/src/main/res/drawable-xxhdpi/tiktok_douyin_icon.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_music_play.png b/demo/src/main/res/drawable-xxhdpi/tiktok_music_play.png similarity index 100% rename from app/src/main/res/drawable-xxhdpi/ic_music_play.png rename to demo/src/main/res/drawable-xxhdpi/tiktok_music_play.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_play_tiktok.png b/demo/src/main/res/drawable-xxhdpi/tiktok_play_tiktok.png similarity index 100% rename from app/src/main/res/drawable-xxhdpi/ic_play_tiktok.png rename to demo/src/main/res/drawable-xxhdpi/tiktok_play_tiktok.png diff --git a/demo/src/main/res/drawable-xxhdpi/tiktok_star_normal.png b/demo/src/main/res/drawable-xxhdpi/tiktok_star_normal.png new file mode 100644 index 00000000..88872ede Binary files /dev/null and b/demo/src/main/res/drawable-xxhdpi/tiktok_star_normal.png differ diff --git a/demo/src/main/res/drawable-xxhdpi/tiktok_star_selected.png b/demo/src/main/res/drawable-xxhdpi/tiktok_star_selected.png new file mode 100644 index 00000000..d4f6b5ff Binary files /dev/null and b/demo/src/main/res/drawable-xxhdpi/tiktok_star_selected.png differ diff --git a/demo/src/main/res/drawable/bg_tab_video_episodes.xml b/demo/src/main/res/drawable/bg_tab_video_episodes.xml new file mode 100644 index 00000000..3ca2eac4 --- /dev/null +++ b/demo/src/main/res/drawable/bg_tab_video_episodes.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/bg_video_button.xml b/demo/src/main/res/drawable/bg_video_button.xml new file mode 100644 index 00000000..62ec6aa9 --- /dev/null +++ b/demo/src/main/res/drawable/bg_video_button.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/bg_video_episodes_check.xml b/demo/src/main/res/drawable/bg_video_episodes_check.xml new file mode 100644 index 00000000..8a1c473c --- /dev/null +++ b/demo/src/main/res/drawable/bg_video_episodes_check.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/bg_video_episodes_uncheck.xml b/demo/src/main/res/drawable/bg_video_episodes_uncheck.xml new file mode 100644 index 00000000..7bf1007d --- /dev/null +++ b/demo/src/main/res/drawable/bg_video_episodes_uncheck.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_border_white.xml b/demo/src/main/res/drawable/ic_border_white.xml similarity index 100% rename from app/src/main/res/drawable/ic_border_white.xml rename to demo/src/main/res/drawable/ic_border_white.xml diff --git a/app/src/main/res/drawable/ic_circle_red.xml b/demo/src/main/res/drawable/ic_circle_red.xml similarity index 100% rename from app/src/main/res/drawable/ic_circle_red.xml rename to demo/src/main/res/drawable/ic_circle_red.xml diff --git a/demo/src/main/res/drawable/ic_star_selector.xml b/demo/src/main/res/drawable/ic_star_selector.xml new file mode 100644 index 00000000..dd84df80 --- /dev/null +++ b/demo/src/main/res/drawable/ic_star_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/player_ag_bg_retry.xml b/demo/src/main/res/drawable/player_ag_bg_retry.xml new file mode 100644 index 00000000..ecebf098 --- /dev/null +++ b/demo/src/main/res/drawable/player_ag_bg_retry.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/player_ag_bottom_progress.xml b/demo/src/main/res/drawable/player_ag_bottom_progress.xml new file mode 100644 index 00000000..c8f00a33 --- /dev/null +++ b/demo/src/main/res/drawable/player_ag_bottom_progress.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/skin_seek_progress.xml b/demo/src/main/res/drawable/player_ag_bottom_seek_progress.xml similarity index 66% rename from app/src/main/res/drawable/skin_seek_progress.xml rename to demo/src/main/res/drawable/player_ag_bottom_seek_progress.xml index 75d77cb7..84621f26 100644 --- a/app/src/main/res/drawable/skin_seek_progress.xml +++ b/demo/src/main/res/drawable/player_ag_bottom_seek_progress.xml @@ -2,16 +2,16 @@ - - + + - - + + @@ -19,10 +19,10 @@ - - + + - + \ No newline at end of file diff --git a/demo/src/main/res/drawable/player_ag_lock.xml b/demo/src/main/res/drawable/player_ag_lock.xml new file mode 100644 index 00000000..0bad846f --- /dev/null +++ b/demo/src/main/res/drawable/player_ag_lock.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/share_selector.xml b/demo/src/main/res/drawable/share_selector.xml similarity index 100% rename from app/src/main/res/drawable/share_selector.xml rename to demo/src/main/res/drawable/share_selector.xml diff --git a/app/src/main/res/layout/activity_api.xml b/demo/src/main/res/layout/activity_api.xml similarity index 98% rename from app/src/main/res/layout/activity_api.xml rename to demo/src/main/res/layout/activity_api.xml index 79ad0acd..ab974746 100644 --- a/app/src/main/res/layout/activity_api.xml +++ b/demo/src/main/res/layout/activity_api.xml @@ -95,7 +95,7 @@ android:layout_gravity="center_horizontal" android:layout_marginBottom="8dp" android:onClick="clickScreenRotate" - android:text="ScreenRotate" /> + android:text="Screen Rotate" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_api_custom_mediaplayer.xml b/demo/src/main/res/layout/activity_api_custom_mediaplayer.xml similarity index 100% rename from app/src/main/res/layout/activity_api_custom_mediaplayer.xml rename to demo/src/main/res/layout/activity_api_custom_mediaplayer.xml diff --git a/app/src/main/res/layout/activity_api_rotation_videosize.xml b/demo/src/main/res/layout/activity_api_rotation_videosize.xml similarity index 100% rename from app/src/main/res/layout/activity_api_rotation_videosize.xml rename to demo/src/main/res/layout/activity_api_rotation_videosize.xml diff --git a/app/src/main/res/layout/activity_auto_tiny.xml b/demo/src/main/res/layout/activity_auto_tiny.xml similarity index 100% rename from app/src/main/res/layout/activity_auto_tiny.xml rename to demo/src/main/res/layout/activity_auto_tiny.xml diff --git a/app/src/main/res/layout/activity_auto_tiny_list.xml b/demo/src/main/res/layout/activity_auto_tiny_list.xml similarity index 100% rename from app/src/main/res/layout/activity_auto_tiny_list.xml rename to demo/src/main/res/layout/activity_auto_tiny_list.xml diff --git a/app/src/main/res/layout/activity_directly_play.xml b/demo/src/main/res/layout/activity_directly_play.xml similarity index 100% rename from app/src/main/res/layout/activity_directly_play.xml rename to demo/src/main/res/layout/activity_directly_play.xml diff --git a/app/src/main/res/layout/activity_extends_normal.xml b/demo/src/main/res/layout/activity_extends_normal.xml similarity index 100% rename from app/src/main/res/layout/activity_extends_normal.xml rename to demo/src/main/res/layout/activity_extends_normal.xml diff --git a/app/src/main/res/layout/activity_listview.xml b/demo/src/main/res/layout/activity_listview.xml similarity index 95% rename from app/src/main/res/layout/activity_listview.xml rename to demo/src/main/res/layout/activity_listview.xml index f193e643..0c715963 100644 --- a/app/src/main/res/layout/activity_listview.xml +++ b/demo/src/main/res/layout/activity_listview.xml @@ -42,14 +42,14 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:onClick="clickListSmoothToDetail" - android:text="ListSmoothToDetail" /> + android:text="List Smooth To Detail" />