@@ -124,6 +124,11 @@ public class VideoView<P extends AbstractPlayer> extends FrameLayout
124124 */
125125 protected boolean mIsLooping ;
126126
127+ /**
128+ * {@link #mPlayerContainer}背景色,默认黑色
129+ */
130+ private int mPlayerBackgroundColor ;
131+
127132 public VideoView (@ NonNull Context context ) {
128133 this (context , null );
129134 }
@@ -148,6 +153,7 @@ public VideoView(@NonNull Context context, @Nullable AttributeSet attrs, int def
148153 mEnableAudioFocus = a .getBoolean (R .styleable .VideoView_enableAudioFocus , mEnableAudioFocus );
149154 mIsLooping = a .getBoolean (R .styleable .VideoView_looping , false );
150155 mCurrentScreenScaleType = a .getInt (R .styleable .VideoView_screenScaleType , mCurrentScreenScaleType );
156+ mPlayerBackgroundColor = a .getColor (R .styleable .VideoView_playerBackgroundColor , Color .BLACK );
151157 a .recycle ();
152158
153159 initView ();
@@ -158,13 +164,20 @@ public VideoView(@NonNull Context context, @Nullable AttributeSet attrs, int def
158164 */
159165 protected void initView () {
160166 mPlayerContainer = new FrameLayout (getContext ());
161- mPlayerContainer .setBackgroundColor (Color . BLACK );
167+ mPlayerContainer .setBackgroundColor (mPlayerBackgroundColor );
162168 LayoutParams params = new LayoutParams (
163169 ViewGroup .LayoutParams .MATCH_PARENT ,
164170 ViewGroup .LayoutParams .MATCH_PARENT );
165171 this .addView (mPlayerContainer , params );
166172 }
167173
174+ /**
175+ * 设置{@link #mPlayerContainer}的背景色
176+ */
177+ public void setPlayerBackgroundColor (int color ) {
178+ mPlayerContainer .setBackgroundColor (color );
179+ }
180+
168181 /**
169182 * 开始播放,注意:调用此方法后必须调用{@link #release()}释放播放器,否则会导致内存泄漏
170183 */
0 commit comments