-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathRecyclerItemPlayNormalHolder.java
More file actions
123 lines (97 loc) · 4.37 KB
/
RecyclerItemPlayNormalHolder.java
File metadata and controls
123 lines (97 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.example.gsyvideoplayer.holder;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import com.example.gsyvideoplayer.R;
import com.example.gsyvideoplayer.model.VideoModel;
import com.example.gsyvideoplayer.video.SampleCoverVideo;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import java.util.HashMap;
import java.util.Map;
/**
* Created by guoshuyu on 2017/1/9.
*/
public class RecyclerItemPlayNormalHolder extends RecyclerItemBaseHolder {
public final static String TAG = "RecyclerView2List";
protected Context context;
SampleCoverVideo gsyVideoPlayer;
ImageView imageView;
GSYVideoOptionBuilder gsyVideoOptionBuilder;
public RecyclerItemPlayNormalHolder(Context context, View v) {
super(v);
this.context = context;
gsyVideoPlayer = v.findViewById(R.id.video_item_player);
imageView = new ImageView(context);
gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
}
public void onBind(final int position, VideoModel videoModel) {
String url;
String title;
if (position % 2 == 0) {
url = "https://www.w3schools.com/html/mov_bbb.mp4";
title = "这是title";
} else {
url = "https://www.w3schools.com/html/mov_bbb.mp4";
title = "哦?Title?";
}
Map<String, String> header = new HashMap<>();
header.put("ee", "33");
int playPosition = GSYVideoManager.instance().getPlayPosition();
if (!GSYVideoManager.instance().isPlaying() && (position != playPosition)) {
//防止错位,离开释放
//gsyVideoPlayer.initUIState();
gsyVideoOptionBuilder.setIsTouchWiget(false)
//.setThumbImageView(imageView)
.setUrl(url).setVideoTitle(title).setCacheWithPlay(false).setRotateViewAuto(true).setLockLand(true).setPlayTag(TAG).setMapHeadData(header).setShowFullAnimation(true).setNeedLockFull(true).setPlayPosition(position).setVideoAllCallBack(new GSYSampleCallBack() {
@Override
public void onPrepared(String url, Object... objects) {
super.onPrepared(url, objects);
if (!gsyVideoPlayer.isIfCurrentIsFullscreen()) {
//静音
GSYVideoManager.instance().setNeedMute(true);
}
}
@Override
public void onAutoComplete(String url, Object... objects) {
super.onAutoComplete(url, objects);
}
@Override
public void onQuitFullscreen(String url, Object... objects) {
super.onQuitFullscreen(url, objects);
//全屏不静音
GSYVideoManager.instance().setNeedMute(true);
}
@Override
public void onEnterFullscreen(String url, Object... objects) {
super.onEnterFullscreen(url, objects);
GSYVideoManager.instance().setNeedMute(false);
gsyVideoPlayer.getCurrentPlayer().getTitleTextView().setText((String) objects[0]);
}
}).build(gsyVideoPlayer);
//增加title
gsyVideoPlayer.getTitleTextView().setVisibility(View.GONE);
//设置返回键
gsyVideoPlayer.getBackButton().setVisibility(View.GONE);
//设置全屏按键功能
gsyVideoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resolveFullBtn(gsyVideoPlayer);
}
});
gsyVideoPlayer.loadCoverImageBy(R.mipmap.xxx2, R.mipmap.xxx2);
}
}
/**
* 全屏幕按键处理
*/
private void resolveFullBtn(final StandardGSYVideoPlayer standardGSYVideoPlayer) {
standardGSYVideoPlayer.startWindowFullscreen(context, true, true);
}
public SampleCoverVideo getPlayer() {
return gsyVideoPlayer;
}
}