作者 qin

Merge branch 'master' into zhangtao

... ... @@ -67,6 +67,11 @@ android {
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
configurations.all {
... ... @@ -83,6 +88,7 @@ configurations.all {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
... ... @@ -102,10 +108,8 @@ dependencies {
implementation 'com.jcodecraeer:xrecyclerview:1.5.9'*/
implementation 'com.android.support:recyclerview-v7:28.1.1'
implementation 'com.jcodecraeer:xrecyclerview:1.5.9'
implementation 'fm.jiecao:jiecaovideoplayer:5.5.2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'jp.wasabeef:glide-transformations:2.0.0'
implementation 'fm.jiecao:jiecaovideoplayer:5.5'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation files('libs/AMap3DMap_7.1.0_AMapSearch_7.1.0_AMapLocation_4.7.2_20191030.jar')
implementation 'com.youth.banner:banner:1.4.10'
... ... @@ -113,29 +117,37 @@ dependencies {
// implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
// implementation 'com.zhy:okhttputils:2.4.1'
//ijkplayer
implementation 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
// implementation 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
// implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
implementation 'com.hyman:flowlayout-lib:1.1.2'
//顶部导航栏
implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
//ijkplayer
implementation 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
// implementation 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
// implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
// implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
implementation files('libs/umeng-share-wechat-simplify-6.9.2.jar')
implementation files('libs/umeng-common-2.1.0.jar')
implementation files('libs/umeng-share-core-6.9.6.jar')
implementation files('libs/umeng-share-QQ-simplify-6.9.6.jar')
// 添加下面这句即可
implementation 'com.android.support:support-v4:28.0.0'
//完整版引入
// implementation 'com.shuyu:GSYVideoPlayer:7.1.2'
implementation 'com.shuyu:gsyVideoPlayer-java:6.0.3'
implementation 'com.shuyu:GSYVideoPlayer-exo2:6.0.3'
implementation 'com.shuyu:gsyVideoPlayer-ex_so:6.0.3'
}
... ...
package com.hh.xuetubao.activity.study;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
... ... @@ -15,13 +16,9 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.dou361.ijkplayer.listener.OnShowThumbnailListener;
import com.dou361.ijkplayer.widget.PlayStateParams;
import com.dou361.ijkplayer.widget.PlayerView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.OptimizeViewpager;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
... ... @@ -34,6 +31,9 @@ import com.hh.xuetubao.model.LearnModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
... ... @@ -53,7 +53,7 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
private String lessonOid;
private String accountOid;
PlayerView play;
// PlayerView play;
OptimizeViewpager pager;
FrameLayout course_A, course_B, back;
... ... @@ -71,8 +71,9 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
boolean isFinish = false;//判断视频是否加载完毕
boolean isCanStudy = false;//判断是否有权限观看这条视频
TextView time_video;
private Event event;
private StandardGSYVideoPlayer player;
OrientationUtils orientationUtils;
@Override
public void initView() {
... ... @@ -92,11 +93,10 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
tv_list = this.findViewById(R.id.tv_list); // 目录
titleValue = this.findViewById(R.id.titleValue);
time_video = this.findViewById(R.id.app_video_endTime);
titleValue.setText(title);
player = this.findViewById(R.id.videoplay);
start.setOnClickListener(this);
back.setOnClickListener(this);
introduce.setOnClickListener(this);
... ... @@ -150,12 +150,6 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
});
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public int initLayout() {
return R.layout.activity_course_detail_two;
... ... @@ -179,9 +173,6 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
@Override //添加,避免旋转屏幕之后只显示半个屏幕
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (play != null) {
play.onConfigurationChanged(newConfig);
}
}
@Override
... ... @@ -264,21 +255,40 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
@Override
protected void onPause() {
super.onPause();
player.onVideoPause();
}
@Override
protected void onResume() {
super.onResume();
player.onVideoResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
GSYVideoManager.releaseAllVideos();
if (orientationUtils != null)
orientationUtils.releaseListener();
}
@Override
protected void onStop() {
super.onStop();
if (play != null) {
play.stopPlay();
}
@Override
public void onBackPressed() {
//先返回正常状态
if (orientationUtils.getScreenType() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
player.getFullscreenButton().performClick();
return;
}
//释放所有
player.setVideoAllCallBack(null);
super.onBackPressed();
}
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
... ... @@ -293,34 +303,29 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
final String urlA = event.getPlayUrl();
play = new PlayerView(this)
.setTitle("视频")
.setScaleType(PlayStateParams.fitparent)
.hideMenu(true)
.forbidTouch(false)
.showThumbnail(new OnShowThumbnailListener() {
@Override
public void onShowThumbnail(ImageView ivThumbnail) {
switch (urlA.substring(urlA.length() - 3, urlA.length()).trim()) {
case "tml":
// 跳转
// Intent intent = new Intent(CourseDetailActivity_Video.this, WebActivity.class);
// intent.putExtra("tml",urlA);
// startActivity(intent);
// Toast.makeText(CourseDetailActivity_Video.this, "链接需网页打开", Toast.LENGTH_SHORT).show();
break;
default: // mp4 , wav ..
ivThumbnail.setImageBitmap(getNetVideoBitmap(urlA));
break;
}
}
})
.setPlaySource((urlA.substring(urlA.length() - 3, urlA.length())).trim().equals("tml") ? "" : urlA)
.setAutoReConnect(true, 0)
.startPlay();
time_video.setText(play.getDuration() + "");
player.setUp(urlA,true,"视频");
player.getBackButton().setVisibility(View.VISIBLE);
//设置旋转
orientationUtils = new OrientationUtils(this, player);
//设置全屏按键功能,这是使用的是选择屏幕,而不是全屏
player.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
orientationUtils.resolveByClick();
}
});
//是否可以滑动调整
player.setIsTouchWiget(true);
//设置返回按键功能
player.getBackButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
player.startPlayLogic();
if ((urlA.substring(urlA.length() - 3, urlA.length())).trim().equals("tml")) {
course_A.setVisibility(View.GONE);
... ... @@ -336,32 +341,30 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
// 播放视频
private void playVideo(final String url) {
play = new PlayerView(this)
.setTitle("视频")
.setScaleType(PlayStateParams.fitparent)
.hideMenu(true)
.forbidTouch(false)
.showThumbnail(new OnShowThumbnailListener() {
@Override
public void onShowThumbnail(ImageView ivThumbnail) {
switch (url.substring(url.length() - 3, url.length()).trim()) {
case "tml":
Intent intent = new Intent(CourseDetailActivity_Video.this, WebActivity.class);
intent.putExtra("tml", url);
startActivity(intent);
// Toast.makeText(CourseDetailActivity_Video.this, "链接需网页打开", Toast.LENGTH_SHORT).show();
break;
default: // mp4 , wav ..
ivThumbnail.setImageBitmap(getNetVideoBitmap(url));
break;
}
}
})
.setPlaySource((url.substring(url.length() - 3, url.length())).trim().equals("tml") ? "" : url)
.startPlay();
player.setUp(url,true,"视频");
player.getBackButton().setVisibility(View.VISIBLE);
//设置旋转
orientationUtils = new OrientationUtils(this, player);
//设置全屏按键功能,这是使用的是选择屏幕,而不是全屏
player.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
orientationUtils.resolveByClick();
}
});
//是否可以滑动调整
player.setIsTouchWiget(true);
//设置返回按键功能
player.getBackButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
player.startPlayLogic();
if ((url.substring(url.length() - 3, url.length())).trim().equals("tml")) {
course_A.setVisibility(View.GONE);
... ... @@ -395,14 +398,13 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
@Override
public void run() {
try {
playing = play.getCurrentPosition();
duration = (int) play.getDuration();
duration = player.getDuration(); // 总时长
playing = player.getCurrentPositionWhenPlaying();
// playing = play.getCurrentPosition();
// duration = (int) play.getDuration();
Log.e("Course_Play", "playing:" + playing + ", duration:" + duration);
String s = refreshTime();
Log.e("Course_refresh", s + "");
mPresenter.getPresenter(6,
1,
accountOid,
... ... @@ -432,14 +434,14 @@ public class CourseDetailActivity_Video extends BaseMvpActivity<CommonPresenter,
}
//视频开始播放时使用handle.sendMessageDelayed更新时间显示
private String refreshTime() {
int totalSeconds = play.getCurrentPosition() / 1000;
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;
String ti = hours > 0 ? String.format("%02d:%02d:%02d", hours, minutes, seconds) : String.format("%02d:%02d", minutes, seconds);
return ti;
}
// private String refreshTime() {
// int totalSeconds = play.getCurrentPosition() / 1000;
// int seconds = totalSeconds % 60;
// int minutes = (totalSeconds / 60) % 60;
// int hours = totalSeconds / 3600;
// String ti = hours > 0 ? String.format("%02d:%02d:%02d", hours, minutes, seconds) : String.format("%02d:%02d", minutes, seconds);
// return ti;
// }
//第一帧
public static Bitmap getNetVideoBitmap(String videoUrl) {
... ...
... ... @@ -15,16 +15,11 @@
android:layout_height="wrap_content"
android:visibility="gone">
<com.dou361.ijkplayer.widget.IjkVideoView
<com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
android:layout_width="match_parent"
android:layout_height="@dimen/dp_100"
android:id="@+id/ss"
></com.dou361.ijkplayer.widget.IjkVideoView>
<!---->
<include
layout="@layout/simple_player_view_player"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_230" />
android:layout_height="@dimen/dp_230"
android:id="@+id/videoplay"
></com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer>
</FrameLayout>
... ...