From 3f33b204af6d7c689c5abbaac76e2b38feddee66 Mon Sep 17 00:00:00 2001 From: shuyu <359369982@qq.com> Date: Thu, 31 May 2018 18:38:15 +0800 Subject: [PATCH 1/2] update ad list --- .../video/ListADVideoPlayer.java | 34 +++++++++++++++++++ .../main/res/layout/list_video_item_ad.xml | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java diff --git a/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java b/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java new file mode 100644 index 000000000..ae553eb05 --- /dev/null +++ b/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java @@ -0,0 +1,34 @@ +package com.example.gsyvideoplayer.video; + +import android.content.Context; +import android.util.AttributeSet; + +import com.shuyu.gsyvideoplayer.video.GSYADVideoPlayer; + +public class ListADVideoPlayer extends GSYADVideoPlayer { + + public ListADVideoPlayer(Context context, Boolean fullFlag) { + super(context, fullFlag); + } + + public ListADVideoPlayer(Context context) { + super(context); + } + + public ListADVideoPlayer(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void startPrepare() { + if (getGSYVideoManager().listener() != null) { + getGSYVideoManager().listener().onAutoCompletion(); + } + super.startPrepare(); + } + + @Override + public void onCompletion() { + super.onCompletion(); + } +} diff --git a/app/src/main/res/layout/list_video_item_ad.xml b/app/src/main/res/layout/list_video_item_ad.xml index e88e4657c..b7a339af4 100644 --- a/app/src/main/res/layout/list_video_item_ad.xml +++ b/app/src/main/res/layout/list_video_item_ad.xml @@ -9,7 +9,7 @@ android:layout_height="@dimen/post_media_height" /> - Date: Thu, 31 May 2018 23:17:38 +0800 Subject: [PATCH 2/2] update ad list --- .../gsyvideoplayer/ListADVideoActivity.java | 7 ++++++- .../video/ListADVideoPlayer.java | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/gsyvideoplayer/ListADVideoActivity.java b/app/src/main/java/com/example/gsyvideoplayer/ListADVideoActivity.java index b9a538126..3c5ccc522 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/ListADVideoActivity.java +++ b/app/src/main/java/com/example/gsyvideoplayer/ListADVideoActivity.java @@ -257,8 +257,13 @@ public void onAutoComplete(String url, Object... objects) { holder.adVideoPlayer.getCurrentPlayer().release(); holder.adVideoPlayer.onVideoReset(); holder.adVideoPlayer.setVisibility(View.GONE); + //开始播放原视频,根据是否处于全屏状态判断 - holder.gsyVideoPlayer.getCurrentPlayer().startAfterPrepared(); + int playPosition = holder.gsyVideoPlayer.getGSYVideoManager().getPlayPosition(); + if (position == playPosition) { + holder.gsyVideoPlayer.getCurrentPlayer().startAfterPrepared(); + } + if (holder.adVideoPlayer.getCurrentPlayer().isIfCurrentIsFullscreen()) { holder.adVideoPlayer.removeFullWindowViewOnly(); if (!holder.gsyVideoPlayer.getCurrentPlayer().isIfCurrentIsFullscreen()) { diff --git a/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java b/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java index ae553eb05..5b4b031a5 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java +++ b/app/src/main/java/com/example/gsyvideoplayer/video/ListADVideoPlayer.java @@ -3,6 +3,8 @@ import android.content.Context; import android.util.AttributeSet; +import com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener; +import com.shuyu.gsyvideoplayer.utils.Debuger; import com.shuyu.gsyvideoplayer.video.GSYADVideoPlayer; public class ListADVideoPlayer extends GSYADVideoPlayer { @@ -21,10 +23,20 @@ public ListADVideoPlayer(Context context, AttributeSet attrs) { @Override protected void startPrepare() { - if (getGSYVideoManager().listener() != null) { - getGSYVideoManager().listener().onAutoCompletion(); - } + GSYMediaPlayerListener listener = getGSYVideoManager().listener(); super.startPrepare(); + if (listener != null) { + listener.onAutoCompletion(); + } + } + + @Override + public void onAutoCompletion() { + super.onAutoCompletion(); + if (!isCurrentMediaListener() && mVideoAllCallBack != null) { + Debuger.printfLog("onAutoComplete"); + mVideoAllCallBack.onAutoComplete(mOriginUrl, mTitle, this); + } } @Override