4
4
import android .animation .AnimatorListenerAdapter ;
5
5
import android .annotation .TargetApi ;
6
6
import android .content .Context ;
7
+ import android .content .res .ColorStateList ;
7
8
import android .content .res .Resources ;
8
9
import android .content .res .TypedArray ;
9
10
import android .graphics .Color ;
28
29
import android .util .AttributeSet ;
29
30
import android .util .Log ;
30
31
import android .util .TypedValue ;
31
- import android .view .GestureDetector ;
32
32
import android .view .LayoutInflater ;
33
33
import android .view .MotionEvent ;
34
34
import android .view .Surface ;
44
44
import android .widget .RelativeLayout ;
45
45
import android .widget .SeekBar ;
46
46
import android .widget .TextView ;
47
-
48
- import com .github .ybq .android .spinkit .SpinKitView ;
49
- import com .github .ybq .android .spinkit .style .ChasingDots ;
50
- import com .github .ybq .android .spinkit .style .Circle ;
51
- import com .github .ybq .android .spinkit .style .CubeGrid ;
52
- import com .github .ybq .android .spinkit .style .DoubleBounce ;
53
- import com .github .ybq .android .spinkit .style .FadingCircle ;
54
- import com .github .ybq .android .spinkit .style .Pulse ;
55
- import com .github .ybq .android .spinkit .style .RotatingCircle ;
56
- import com .github .ybq .android .spinkit .style .RotatingPlane ;
57
- import com .github .ybq .android .spinkit .style .ThreeBounce ;
58
- import com .github .ybq .android .spinkit .style .WanderingCubes ;
59
- import com .github .ybq .android .spinkit .style .Wave ;
60
47
import com .halilibo .bettervideoplayer .subtitle .CaptionsView ;
61
48
import com .halilibo .bettervideoplayer .utility .EmptyCallback ;
62
49
import com .halilibo .bettervideoplayer .utility .Util ;
63
50
64
51
import java .io .IOException ;
65
52
import java .lang .annotation .Retention ;
66
53
import java .lang .annotation .RetentionPolicy ;
54
+ import java .util .HashMap ;
67
55
import java .util .Map ;
68
56
57
+ import me .zhanghai .android .materialprogressbar .MaterialProgressBar ;
58
+
69
59
/**
70
60
* @author Aidan Follestad
71
61
* Modified and improved by Halil Ozercan
@@ -79,7 +69,7 @@ public class BetterVideoPlayer extends RelativeLayout implements IUserMethods,
79
69
private static final String BETTER_VIDEO_PLAYER_BRIGHTNESS = "BETTER_VIDEO_PLAYER_BRIGHTNESS" ;
80
70
private static final int UPDATE_INTERVAL = 100 ;
81
71
82
- private SpinKitView mProgressBar ;
72
+ private MaterialProgressBar mProgressBar ;
83
73
private TextView mPositionTextView , viewForward , viewBackward ;
84
74
85
75
private CaptionsView mSubView ;
@@ -88,33 +78,12 @@ public class BetterVideoPlayer extends RelativeLayout implements IUserMethods,
88
78
private String mTitle ;
89
79
private int mSubViewTextSize ;
90
80
private int mSubViewTextColor ;
91
- private Context context ;
92
81
93
82
/**
94
83
* Window that hold the player. Necessary for setting brightness.
95
84
*/
96
85
private Window mWindow ;
97
86
98
- private static final int DOUBLE_BOUNCE = 0 ;
99
- private static final int ROTATING_PLANE = 1 ;
100
- private static final int WAVE = 2 ;
101
- private static final int WANDERING_CUBES = 3 ;
102
- private static final int PULSE = 4 ;
103
- private static final int CHASING_DOTS = 5 ;
104
- private static final int THREE_BOUNCE = 6 ;
105
- private static final int CIRCLE = 7 ;
106
- private static final int CUBE_GRID = 8 ;
107
- private static final int FADING_CIRCLE = 9 ;
108
- private static final int ROTATING_CIRCLE = 10 ;
109
-
110
- @ IntDef ({DOUBLE_BOUNCE , ROTATING_PLANE , WAVE ,
111
- WANDERING_CUBES , PULSE , CHASING_DOTS ,
112
- THREE_BOUNCE , CIRCLE , CUBE_GRID ,
113
- FADING_CIRCLE , ROTATING_CIRCLE })
114
- @ Retention (RetentionPolicy .SOURCE )
115
- public @interface LoadingStyle {
116
- }
117
-
118
87
private static final int PLAY_BUTTON = 0 ;
119
88
private static final int PAUSE_BUTTON = 1 ;
120
89
private static final int RESTART_BUTTON = 2 ;
@@ -172,7 +141,7 @@ public BetterVideoPlayer(Context context, AttributeSet attrs, int defStyleAttr)
172
141
private int viewVisibility ;
173
142
174
143
private Uri mSource ;
175
- private Map <String , String > headers ;
144
+ private Map <String , String > headers = new HashMap <>() ;
176
145
177
146
private BetterVideoCallback mCallback ;
178
147
private BetterVideoProgressCallback mProgressCallback ;
@@ -189,15 +158,13 @@ public BetterVideoPlayer(Context context, AttributeSet attrs, int defStyleAttr)
189
158
private int mGestureType = NO_GESTURE ;
190
159
private boolean mAutoPlay = false ;
191
160
private boolean mControlsDisabled = false ;
192
- private int mLoadingStyle = CHASING_DOTS ;
193
161
private int mInitialPosition = -1 ;
194
162
private int mHideControlsDuration = 2000 ; // defaults to 2 seconds.
195
163
private int mDoubleTapSeekDuration ;
196
164
197
165
198
166
private void init (Context context , AttributeSet attrs ) {
199
167
setBackgroundColor (Color .BLACK );
200
- this .context = context ;
201
168
if (attrs != null ) {
202
169
TypedArray a = context .getTheme ().obtainStyledAttributes (
203
170
attrs ,
@@ -219,8 +186,6 @@ private void init(Context context, AttributeSet attrs) {
219
186
R .styleable .BetterVideoPlayer_bvp_pauseDrawable );
220
187
mRestartDrawable = a .getDrawable (
221
188
R .styleable .BetterVideoPlayer_bvp_restartDrawable );
222
- mLoadingStyle = a .getInt (
223
- R .styleable .SpinKitView_SpinKit_Style , 0 );
224
189
mHideControlsDuration = a .getInteger (
225
190
R .styleable .BetterVideoPlayer_bvp_hideControlsDuration , mHideControlsDuration );
226
191
@@ -245,7 +210,7 @@ private void init(Context context, AttributeSet attrs) {
245
210
getResources ().getDimensionPixelSize (R .dimen .bvp_subtitle_size ));
246
211
mSubViewTextColor = a .getColor (
247
212
R .styleable .BetterVideoPlayer_bvp_captionColor ,
248
- ContextCompat .getColor (context , R .color .bvp_subtitle_color ));
213
+ getResources () .getColor (R .color .bvp_subtitle_color ));
249
214
250
215
} catch (Exception e ) {
251
216
LOG ("Exception " + e .getMessage ());
@@ -255,7 +220,7 @@ private void init(Context context, AttributeSet attrs) {
255
220
}
256
221
} else {
257
222
mSubViewTextSize = getResources ().getDimensionPixelSize (R .dimen .bvp_subtitle_size );
258
- mSubViewTextColor = ContextCompat .getColor (context , R .color .bvp_subtitle_color );
223
+ mSubViewTextColor = getResources () .getColor (R .color .bvp_subtitle_color );
259
224
}
260
225
261
226
if (mPlayDrawable == null )
@@ -874,15 +839,14 @@ protected void onFinishInflate() {
874
839
875
840
// Inflate and add progress
876
841
mProgressFrame = li .inflate (R .layout .bvp_include_progress , this , false );
877
- mProgressBar = mProgressFrame .findViewById (R .id .spin_kit );
842
+ mProgressBar = mProgressFrame .findViewById (R .id .material_progress_bar );
878
843
mBottomProgressBar = mProgressFrame .findViewById (R .id .progressBarBottom );
879
844
880
845
TypedValue typedValue = new TypedValue ();
881
846
Resources .Theme theme = getContext ().getTheme ();
882
847
theme .resolveAttribute (R .attr .colorAccent , typedValue , true );
883
848
int color = typedValue .data ;
884
- mProgressBar .setColor (color );
885
- setLoadingStyle (mLoadingStyle );
849
+ mProgressBar .setProgressTintList (ColorStateList .valueOf (color ));
886
850
887
851
mPositionTextView = mProgressFrame .findViewById (R .id .position_textview );
888
852
mPositionTextView .setShadowLayer (3 , 3 , 3 , Color .BLACK );
@@ -1067,50 +1031,6 @@ public void setLoop(boolean loop) {
1067
1031
this .mLoop = loop ;
1068
1032
}
1069
1033
1070
- @ Override
1071
- public void setLoadingStyle (@ LoadingStyle int style ) {
1072
- Drawable drawable ;
1073
- switch (style ) {
1074
- case DOUBLE_BOUNCE :
1075
- drawable = new DoubleBounce ();
1076
- break ;
1077
- case ROTATING_PLANE :
1078
- drawable = new RotatingPlane ();
1079
- break ;
1080
- case WAVE :
1081
- drawable = new Wave ();
1082
- break ;
1083
- case WANDERING_CUBES :
1084
- drawable = new WanderingCubes ();
1085
- break ;
1086
- case PULSE :
1087
- drawable = new Pulse ();
1088
- break ;
1089
- case CHASING_DOTS :
1090
- drawable = new ChasingDots ();
1091
- break ;
1092
- case THREE_BOUNCE :
1093
- drawable = new ThreeBounce ();
1094
- break ;
1095
- case CIRCLE :
1096
- drawable = new Circle ();
1097
- break ;
1098
- case CUBE_GRID :
1099
- drawable = new CubeGrid ();
1100
- break ;
1101
- case FADING_CIRCLE :
1102
- drawable = new FadingCircle ();
1103
- break ;
1104
- case ROTATING_CIRCLE :
1105
- drawable = new RotatingCircle ();
1106
- break ;
1107
- default :
1108
- drawable = new ThreeBounce ();
1109
- break ;
1110
- }
1111
- mProgressBar .setIndeterminateDrawable (drawable );
1112
- }
1113
-
1114
1034
OnSwipeTouchListener clickFrameSwipeListener =
1115
1035
new OnSwipeTouchListener (true ) {
1116
1036
0 commit comments