From 7703bf68598a2dc1d84e0ec726beca82d1e6d14e Mon Sep 17 00:00:00 2001 From: jiajunhui <309812983@qq.com> Date: Wed, 20 Jan 2021 22:55:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9A=E6=97=B6=E5=99=A8?= =?UTF-8?q?=E9=97=B4=E9=9A=94=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=AE=8C=E5=96=84?= =?UTF-8?q?VideoView=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++----- .../RecyclerBaseVideoContentAdapter.java | 20 ++++++++++++++----- .../taurus/avplayer/ui/MusicPlayActivity.java | 4 ++++ .../ui/RecyclerBaseVideoActivity.java | 11 ++++++++-- app/src/main/res/layout/activity_home.xml | 12 +++++------ ...ctivity_recycler_base_video_type_video.xml | 4 ++-- build.gradle | 8 ++++---- .../com/kk/taurus/playerbase/AVPlayer.java | 3 ++- .../playerbase/config/PlayerConfig.java | 11 ++++++++++ .../playerbase/player/TimerCounterProxy.java | 4 ++++ .../style/ViewOvalRectOutlineProvider.java | 1 + 11 files changed, 63 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ef7005ab..84631486 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ dependencies { //该依赖仅包含MediaPlayer解码 - implementation 'com.kk.taurus.playerbase:playerbase:3.4.1' + implementation 'com.kk.taurus.playerbase:playerbase:3.4.2' } ``` @@ -46,7 +46,7 @@ dependencies { //该依赖包含exoplayer解码和MediaPlayer解码 //注意exoplayer的最小支持SDK版本为16 - implementation 'cn.jiajunhui:exoplayer:341_2122_017' + implementation 'cn.jiajunhui:exoplayer:342_2123_018' } ``` @@ -57,7 +57,7 @@ dependencies { dependencies { //该依赖包含ijkplayer解码和MediaPlayer解码 - implementation 'cn.jiajunhui:ijkplayer:341_088_012' + implementation 'cn.jiajunhui:ijkplayer:342_088_012' //ijk官方的解码库依赖,较少格式版本且不支持HTTPS。 implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8' # Other ABIs: optional @@ -76,10 +76,10 @@ dependencies { //该依赖包含exoplayer解码和MediaPlayer解码 //注意exoplayer的最小支持SDK版本为16 - implementation 'cn.jiajunhui:exoplayer:340_2120_016' + implementation 'cn.jiajunhui:exoplayer:342_2123_018' //该依赖包含ijkplayer解码和MediaPlayer解码 - implementation 'cn.jiajunhui:ijkplayer:340_088_011' + implementation 'cn.jiajunhui:ijkplayer:342_088_012' //ijk官方的解码库依赖,较少格式版本且不支持HTTPS。 implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8' # Other ABIs: optional diff --git a/app/src/main/java/com/kk/taurus/avplayer/adapter/RecyclerBaseVideoContentAdapter.java b/app/src/main/java/com/kk/taurus/avplayer/adapter/RecyclerBaseVideoContentAdapter.java index ec3e91af..fee0f14a 100644 --- a/app/src/main/java/com/kk/taurus/avplayer/adapter/RecyclerBaseVideoContentAdapter.java +++ b/app/src/main/java/com/kk/taurus/avplayer/adapter/RecyclerBaseVideoContentAdapter.java @@ -1,6 +1,6 @@ package com.kk.taurus.avplayer.adapter; -import android.graphics.Rect; +import android.os.Build; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -11,12 +11,15 @@ import com.kk.taurus.avplayer.R; import com.kk.taurus.avplayer.bean.RecyclerBaseVideoBean; +import com.kk.taurus.avplayer.cover.LoadingCover; import com.kk.taurus.playerbase.entity.DataSource; -import com.kk.taurus.playerbase.render.AspectRatio; +import com.kk.taurus.playerbase.receiver.ReceiverGroup; import com.kk.taurus.playerbase.widget.BaseVideoView; import java.util.List; +import static com.kk.taurus.avplayer.play.DataInter.ReceiverKey.KEY_LOADING_COVER; + /** * @author KaraShokZ (张耀中) * DESCRIPTION @@ -32,6 +35,11 @@ public RecyclerBaseVideoContentAdapter(List dataList) { this.dataList = dataList; } + public void onDestroy(){ + if(typeLiveVideoBvv!=null) + typeLiveVideoBvv.stopPlayback(); + } + @NonNull @Override public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -54,9 +62,11 @@ public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) { if (bean.itemType == 1){ if (typeLiveVideoBvv == null){ typeLiveVideoBvv = holder.getView(R.id.activity_recycler_base_video_type_video_bvv); - typeLiveVideoBvv.setOvalRectShape(); -// typeLiveVideoBvv.setRoundRectShape(30); - typeLiveVideoBvv.setAspectRatio(AspectRatio.AspectRatio_MATCH_PARENT); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + typeLiveVideoBvv.setRoundRectShape(30); + ReceiverGroup receiverGroup = new ReceiverGroup(); + receiverGroup.addReceiver(KEY_LOADING_COVER, new LoadingCover(typeLiveVideoBvv.getContext())); + typeLiveVideoBvv.setReceiverGroup(receiverGroup); typeLiveVideoBvv.setDataSource(new DataSource(bean.videoUrl)); typeLiveVideoBvv.start(); } diff --git a/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java b/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java index 3244d5e4..d79107c9 100644 --- a/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java +++ b/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java @@ -18,6 +18,7 @@ import com.kk.taurus.avplayer.R; import com.kk.taurus.avplayer.view.VisualizerView; import com.kk.taurus.playerbase.AVPlayer; +import com.kk.taurus.playerbase.config.PlayerConfig; import com.kk.taurus.playerbase.entity.DataSource; import com.kk.taurus.playerbase.event.EventKey; import com.kk.taurus.playerbase.event.OnErrorEventListener; @@ -62,6 +63,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { setVolumeControlStream(AudioManager.STREAM_MUSIC); + PlayerConfig.setTimerCounterInterval(50); + mPlayer = new AVPlayer(); mPlayer.setLooping(mSwitchCompat.isChecked()); mPlayer.setVolume(mVolumeLeft, mVolumeRight); @@ -193,6 +196,7 @@ public void volumeReduce(View view){ @Override protected void onDestroy() { super.onDestroy(); + PlayerConfig.setTimerCounterInterval(1000); mPlayer.destroy(); releaseVisualizer(); } diff --git a/app/src/main/java/com/kk/taurus/avplayer/ui/RecyclerBaseVideoActivity.java b/app/src/main/java/com/kk/taurus/avplayer/ui/RecyclerBaseVideoActivity.java index 9f370ce5..9b7f869a 100644 --- a/app/src/main/java/com/kk/taurus/avplayer/ui/RecyclerBaseVideoActivity.java +++ b/app/src/main/java/com/kk/taurus/avplayer/ui/RecyclerBaseVideoActivity.java @@ -12,13 +12,20 @@ public class RecyclerBaseVideoActivity extends AppCompatActivity { + RecyclerBaseVideoContentAdapter mAdapter; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recycler_base_video); RecyclerView contentRv = findViewById(R.id.content_rv); contentRv.setLayoutManager(new LinearLayoutManager(this)); -// contentRv.setLayoutManager(new LinearLayoutManager(this,RecyclerView.HORIZONTAL,false)); - contentRv.setAdapter(new RecyclerBaseVideoContentAdapter(RecyclerBaseVideoBean.getItemList())); + contentRv.setAdapter(mAdapter = new RecyclerBaseVideoContentAdapter(RecyclerBaseVideoBean.getItemList())); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mAdapter.onDestroy(); } } diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 570d8606..74552507 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -33,26 +33,26 @@ android:textColor="@color/colorPrimary"/>