GSYVideoPlayer
2020-11-11 本文已影响0人
Anwfly
- 添加依赖
implementation 'com.shuyu:GSYVideoPlayer:7.1.8'
- 修改清单列表
<activity
android:name=".MpActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:screenOrientation="portrait" />
- 单独使用
(1)添加控件
(2)界面中使用<com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer android:id="@+id/gsy_vv" android:layout_width="match_parent" android:layout_height="200dp" app:layout_constraintTop_toTopOf="parent" />
package com.anfly.day16;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
public class ThirdActivity extends AppCompatActivity {
private StandardGSYVideoPlayer videoPlayer;
private String vvUrl = "http://jzvd.nathen.cn/c6e3dc12a1154626b3476d9bf3bd7266/6b56c5f0dc31428083757a45764763b0-5287d2089db37e62345123a1be272f8b.mp4";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
initView();
}
private void initView() {
videoPlayer = (StandardGSYVideoPlayer) findViewById(R.id.gsy_vv);
String source1 = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
videoPlayer.setUp(vvUrl, false, "测试视频");
//增加封面
ImageView imageView = new ImageView(this);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(R.mipmap.ic_launcher);
videoPlayer.setThumbImageView(imageView);
//增加title
videoPlayer.getTitleTextView().setVisibility(View.VISIBLE);
//设置返回键
videoPlayer.getBackButton().setVisibility(View.VISIBLE);
//是否可以滑动调整
videoPlayer.setIsTouchWiget(true);
//设置返回按键功能
videoPlayer.getBackButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
videoPlayer.startPlayLogic();
}
@Override
protected void onPause() {
super.onPause();
videoPlayer.onVideoPause();
}
@Override
protected void onResume() {
super.onResume();
videoPlayer.onVideoResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
GSYVideoManager.releaseAllVideos();
}
@Override
public void onBackPressed() {
//释放所有
videoPlayer.setVideoAllCallBack(null);
super.onBackPressed();
}
}
- 列表中使用
地址