Skip to content

Commit

Permalink
Merge branch 'release/v7.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lipangit committed Jun 29, 2021
2 parents d8b78c7 + 8956c45 commit 5493534
Show file tree
Hide file tree
Showing 26 changed files with 433 additions and 51 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

[中文文档](http://jzvd.org)

[下载Demo](https://github.com/Jzvd/JZVideo/releases/download/v7.6.0/jiaozivideoplayer-7.6.0.apk)
[下载Demo](https://github.com/Jzvd/JZVideo/releases/download/v7.7.0/jiaozivideoplayer-7.7.0.apk)

## QuickStart

1.添加类库
```gradle
implementation 'cn.jzvd:jiaozivideoplayer:7.6.0'
implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'
```

2.添加布局
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = "1.5.20"
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
jcenter()
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.aliyun.com/repository/public" } //jcenter & central
maven { url "https://maven.aliyun.com/repository/google" }
Expand Down
5 changes: 3 additions & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "cn.jzvd.demo"
minSdkVersion 16
targetSdkVersion 30
versionCode 106
versionName "7.6.0"
versionCode 107
versionName "7.7.0"
multiDexEnabled true
ndk {
// add support lib
Expand Down Expand Up @@ -69,6 +69,7 @@ dependencies {
implementation 'com.scwang.smart:refresh-footer-classics:2.0.1'
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.4'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3'

}
8 changes: 3 additions & 5 deletions demo/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-keep public class cn.jzvd.JZMediaSystem {*; }
-keep public class cn.jzvd.demo.CustomMedia.CustomMedia {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaIjk {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaSystemAssertFolder {*; }
-keep class cn.jzvd.**{*;}
-keep public class * extends cn.jzvd.JZMediaInterface
-keep public class * extends cn.jzvd.JzvdStd


-keep class tv.danmaku.ijk.media.player.** {*; }
Expand Down
1 change: 1 addition & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:networkSecurityConfig="@xml/jz_network_security_config"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning,LockedOrientationActivity,MissingTranslation">
<activity android:name=".Tab_4_More.SlideZoomActivity"></activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
Expand Down
8 changes: 4 additions & 4 deletions demo/src/main/java/cn/jzvd/demo/CustomMedia/JZMediaExo.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public void prepare() {
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory();
TrackSelector trackSelector =
new DefaultTrackSelector(context,videoTrackSelectionFactory);
new DefaultTrackSelector(context, videoTrackSelectionFactory);

LoadControl loadControl = new DefaultLoadControl.Builder()
.setAllocator(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE))
.setBufferDurationsMs( 360000, 600000, 1000, 5000)
.setBufferDurationsMs(360000, 600000, 1000, 5000)
.setPrioritizeTimeOverSizeThresholds(false)
.setTargetBufferBytes(C.LENGTH_UNSET)
.createDefaultLoadControl();
Expand All @@ -90,7 +90,7 @@ public void prepare() {
.setTrackSelector(trackSelector)
.setLoadControl(loadControl)
.setBandwidthMeter(bandwidthMeter)
.build() ;
.build();
// Produces DataSource instances through which media data is loaded.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,
Util.getUserAgent(context, context.getResources().getString(R.string.app_name)));
Expand Down Expand Up @@ -135,7 +135,7 @@ public void prepare() {

@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
handler.post(() -> jzvd.onVideoSizeChanged(width, height));
handler.post(() -> jzvd.onVideoSizeChanged((int) (width * pixelWidthHeightRatio), height));
}

@Override
Expand Down
10 changes: 7 additions & 3 deletions demo/src/main/java/cn/jzvd/demo/Fragment_4_More.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import cn.jzvd.demo.Tab_4_More.DanmuActivity;
import cn.jzvd.demo.Tab_4_More.DirectPlayActivity;
import cn.jzvd.demo.Tab_4_More.LocalVideoActivity;
import cn.jzvd.demo.Tab_4_More.SlideZoomActivity;
import cn.jzvd.demo.Tab_4_More.WebViewActivity;

/**
Expand All @@ -27,7 +28,7 @@
public class Fragment_4_More extends Fragment implements View.OnClickListener {

TextView versionTextView;
private Button mDirectPlay, mWebView, mLocalVideo, mTinyWindow, mGetGif,mDanmu;
private Button mDirectPlay, mWebView, mLocalVideo, mTinyWindow, mGetGif,mDanmu,mSlideZoom;

public static String getAppVersionName(Context context) {
String appVersionName = "";
Expand All @@ -54,8 +55,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mTinyWindow = view.findViewById(R.id.tiny_window);
mGetGif = view.findViewById(R.id.get_gif);
mDanmu = view.findViewById(R.id.danmu_view);


mSlideZoom= view.findViewById(R.id.slide_zoom);
mSlideZoom.setOnClickListener(this);
mDirectPlay.setOnClickListener(this);
mWebView.setOnClickListener(this);
mLocalVideo.setOnClickListener(this);
Expand Down Expand Up @@ -93,6 +94,9 @@ public void onClick(View view) {
case R.id.danmu_view:
startActivity(new Intent(getContext(), DanmuActivity.class));
break;
case R.id.slide_zoom:
startActivity(new Intent(getContext(), SlideZoomActivity.class));
break;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public void onBackPressed() {
@Override
protected void onPause() {
super.onPause();
Jzvd.goOnPlayOnPause();
}

@Override
protected void onDestroy() {
super.onDestroy();
Jzvd.releaseAllVideos();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_preloading);
jzvdStd = findViewById(R.id.jz_video);

jzvdStd.setUp(UrlsKt.getTitles()[7]
jzvdStd.setUp(UrlsKt.getVideos()[7]
, UrlsKt.getTitles()[7], Jzvd.SCREEN_NORMAL, JZMediaIjk.class);

Glide.with(this).load(UrlsKt.getTitles()[7]).into(jzvdStd.posterImageView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_api_rotation_videosize);

myJzvdStd = findViewById(R.id.jz_video);
myJzvdStd.setUp(UrlsKt.getVideos()[30], UrlsKt.getTitles()[30]
myJzvdStd.setUp(UrlsKt.getVideos()[26], UrlsKt.getTitles()[26]
, JzvdStd.SCREEN_NORMAL);
Glide.with(this)
.load(UrlsKt.getThumbnails()[30])
.load(UrlsKt.getThumbnails()[26])
.into(myJzvdStd.posterImageView);
// The Point IS 或者这样写也可以
// myJzvdStd.videoRotation = 180;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder> {
int[] videoIndexs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int[] videoIndexs = {0, 1, 2, 3, 4, 5, 6, 7, 8};

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Expand All @@ -43,7 +43,7 @@ public int getItemCount() {
}


class ViewHolder extends RecyclerView.ViewHolder {
class ViewHolder extends RecyclerView.ViewHolder {
ImageView ivHead;
TextView tvName;
TextView tvContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class SmoothRecyclerViewAdapter extends RecyclerView.Adapter<SmoothRecyclerViewAdapter.MyViewHolder> {

public static final String TAG = "AdapterSmoothRecyclerView";
int[] videoIndexs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int[] videoIndexs = {0, 1, 2, 3, 4, 5, 6, 7, 8};
private Context context;
private OnVideoClick onVideoClick;

Expand Down
74 changes: 74 additions & 0 deletions demo/src/main/java/cn/jzvd/demo/Tab_4_More/SlideZoomActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package cn.jzvd.demo.Tab_4_More;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.MenuItem;

import com.bumptech.glide.Glide;

import org.jzvd.jzvideo.UrlsKt;

import cn.jzvd.JZUtils;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;
import cn.jzvd.demo.R;
import cn.jzvd.demo.Tab_3_List.ListView.adapter.CommentAdapter;

public class SlideZoomActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(false);
getSupportActionBar().setTitle(getString(R.string.slide_zoom));
CommentAdapter commentAdapter = new CommentAdapter();
setContentView(R.layout.activity_slide_zoom);
JzvdStd mJzvdStd = findViewById(R.id.jzvd);
mJzvdStd.setUp(UrlsKt.getVideos()[14], UrlsKt.getTitles()[14], JzvdStd.SCREEN_NORMAL);
Glide.with(this).load(UrlsKt.getThumbnails()[14]).into(mJzvdStd.posterImageView);
RecyclerView recyclerView = findViewById(R.id.rv_comment);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(commentAdapter);
}

@Override
protected void onPause() {
super.onPause();
Jzvd.releaseAllVideos();
}
@Override
protected void onResume() {
super.onResume();
Jzvd.goOnPlayOnResume();
}

@Override
public void onBackPressed() {
if (Jzvd.backPress()) {
return;
}
super.onBackPressed();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}

@Override
protected void onDestroy() {
super.onDestroy();
Jzvd.releaseAllVideos();
}
}
25 changes: 14 additions & 11 deletions demo/src/main/java/cn/jzvd/demo/utils/AutoPlayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,24 @@ private AutoPlayUtils() {
* @param lastVisiblePosition 最后一个可见item位置
*/
public static void onScrollPlayVideo(RecyclerView recyclerView, int jzvdId, int firstVisiblePosition, int lastVisiblePosition) {
if (JZUtils.isWifiConnected(recyclerView.getContext())) {
for (int i = 0; i <= lastVisiblePosition - firstVisiblePosition; i++) {
View child = recyclerView.getChildAt(i);
View view = child.findViewById(jzvdId);
if (view != null && view instanceof Jzvd) {
Jzvd player = (Jzvd) view;
if (getViewVisiblePercent(player) == 1f) {
if (positionInList != i + firstVisiblePosition) {
player.startButton.performClick();
}
break;
if (!JZUtils.isWifiConnected(recyclerView.getContext())) {
return;
}
for (int i = 0; i <= lastVisiblePosition - firstVisiblePosition; i++) {
View child = recyclerView.getChildAt(i);
View view = child.findViewById(jzvdId);
if (view != null && view instanceof Jzvd) {
Jzvd player = (Jzvd) view;
if (getViewVisiblePercent(player) == 1f) {
if (positionInList != i + firstVisiblePosition) {
if (player.state != Jzvd.STATE_PLAYING) player.startButton.performClick();
}
break;
}
}
}


}

/**
Expand Down
65 changes: 65 additions & 0 deletions demo/src/main/java/cn/jzvd/demo/utils/JzvdDependBehavior.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cn.jzvd.demo.utils;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;

import cn.jzvd.demo.R;


public class JzvdDependBehavior extends CoordinatorLayout.Behavior<View> {

private int dependId;

public JzvdDependBehavior() {

}

public JzvdDependBehavior(Context context, AttributeSet attributeSet) {
TypedArray array = context.obtainStyledAttributes(attributeSet, R.styleable.JzvdDependBehavior, 0, 0);
dependId = array.getResourceId(R.styleable.JzvdDependBehavior_depend, 0);
array.recycle();
}


@Override
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) {
return dependId == dependency.getId();
}


@Override
public boolean onMeasureChild(@NonNull CoordinatorLayout parent,
@NonNull View child,
int parentWidthMeasureSpec,
int widthUsed,
int parentHeightMeasureSpec,
int heightUsed) {


View dependView = parent.findViewById(dependId);
if (dependView == null) {
return false;
}
parent.onMeasureChild(child, parentWidthMeasureSpec, 0, parentHeightMeasureSpec, dependView.getBottom());
return true;
}


@Override
public boolean onLayoutChild(@NonNull CoordinatorLayout parent,
@NonNull View child,
int layoutDirection) {
View anchorView = parent.findViewById(dependId);
if (anchorView == null) {
return false;
}
parent.onLayoutChild(child, layoutDirection);
child.offsetTopAndBottom(anchorView.getBottom());
return true;
}
}
Loading

0 comments on commit 5493534

Please sign in to comment.