Repository navigation
Expand file tree
/
Copy pathFloatPlayerView.java
More file actions
70 lines (49 loc) · 1.78 KB
/
Copy pathFloatPlayerView.java
File metadata and controls
70 lines (49 loc) · 1.78 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
package com.example.gsyvideoplayer.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.example.gsyvideoplayer.utils.DemoVideoUrls;
import com.example.gsyvideoplayer.video.FloatingVideo;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
/**
* 适配了悬浮窗的view
* Created by guoshuyu on 2017/12/25.
*/
public class FloatPlayerView extends FrameLayout {
FloatingVideo videoPlayer;
public FloatPlayerView(Context context) {
super(context);
init();
}
public FloatPlayerView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public FloatPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
videoPlayer = new FloatingVideo(getContext());
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.CENTER;
addView(videoPlayer, layoutParams);
String source1 = DemoVideoUrls.MP4_BBB;
videoPlayer.setUp(source1, true, "测试视频");
//增加封面
/*ImageView imageView = new ImageView(getContext());
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(R.mipmap.xxx1);
videoPlayer.setThumbImageView(imageView);*/
//是否可以滑动调整
videoPlayer.setIsTouchWiget(false);
}
public void onPause() {
videoPlayer.getCurrentPlayer().onVideoPause();
}
public void onResume() {
videoPlayer.getCurrentPlayer().onVideoResume();
}
}