@@ -39,8 +39,10 @@ public final class IVideoPlayer implements OnMediaEventListener , AudioFocus.OnA
39
39
private AudioFocus mAudioFocusManager ;//多媒体焦点监听,失去焦点暂停播放
40
40
//内部播放器状态,初始为默认/重置状态
41
41
private PlayerState sPlayerState = PlayerState .STATE_RESET ;
42
- //是否循环播放/是否静音
43
- private boolean mLoop =false ,mSoundMute =false ;
42
+ //是否循环播放/是否静音/是否镜像
43
+ private boolean mLoop =false ,mSoundMute =false ,mMirrors =false ;
44
+ //裁剪缩放模式,默认为原始大小,定宽等高,可能高度会留有黑边
45
+ private int mZoomMode =IMediaPlayer .MODE_ZOOM_TO_FIT ;
44
46
//远程资源地址
45
47
private String mDataSource ;
46
48
private AssetFileDescriptor mAssetsSource ;//Assetss资产目录下的文件地址
@@ -54,7 +56,7 @@ public final class IVideoPlayer implements OnMediaEventListener , AudioFocus.OnA
54
56
private long mSeekDuration ;
55
57
//视频宽、高
56
58
private int mVideoWidth ,mVideoHeight ;
57
- //播放超时 \读取视频流超时时长
59
+ //链接视频源超时时长 \读取视频流超时时长
58
60
private int mPrepareTimeout =10 ,mReadTimeout =15 ;
59
61
60
62
/**
@@ -136,7 +138,6 @@ private void initTextureView(Context context){
136
138
if (null ==context ) return ;
137
139
mRenderView = newInstanceRenderView (context );
138
140
ILogger .d (TAG ,getString (R .string .player_render_name ,"渲染器内核:" )+mRenderView .getClass ().getSimpleName ());
139
- mRenderView .setZoomMode (IVideoManager .getInstance ().getZoomModel ());
140
141
}
141
142
142
143
//释放解码器\移除画面组件
@@ -200,7 +201,8 @@ public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sar_n
200
201
this .mVideoHeight =height ;
201
202
if (null != mRenderView ){
202
203
mRenderView .setVideoSize (width ,height );
203
- mRenderView .setZoomMode (IVideoManager .getInstance ().getZoomModel ());
204
+ mRenderView .setZoomMode (mZoomMode );
205
+ mRenderView .setMirror (mMirrors );
204
206
mRenderView .setSarSize (sar_num ,sar_den );
205
207
}
206
208
if (null != mBasePlayer ) mBasePlayer .onVideoSizeChanged (width ,height );
@@ -578,7 +580,7 @@ public boolean toggleMute() {
578
580
* @param zoomModel 请适用IMediaPlayer类中定义的常量值
579
581
*/
580
582
public void setZoomModel (int zoomModel ) {
581
- IVideoManager . getInstance (). setZoomModel ( zoomModel ) ;
583
+ this . mZoomMode = zoomModel ;
582
584
if (null != mRenderView ) mRenderView .setZoomMode (zoomModel );
583
585
}
584
586
@@ -604,6 +606,7 @@ public void setInterceptTAudioFocus(boolean interceptTAudioFocus){
604
606
* @return true:镜像 false:正常
605
607
*/
606
608
public boolean setMirror (boolean mirror ) {
609
+ this .mMirrors =mirror ;
607
610
if (null != mRenderView ){
608
611
return mRenderView .setMirror (mirror );
609
612
}
@@ -615,10 +618,8 @@ public boolean setMirror(boolean mirror) {
615
618
* @return true:镜像 false:正常
616
619
*/
617
620
public boolean toggleMirror () {
618
- if (null != mRenderView ){
619
- return mRenderView .toggleMirror ();
620
- }
621
- return false ;
621
+ boolean isMirrors = ! mMirrors ;
622
+ return setMirror (isMirrors );
622
623
}
623
624
624
625
/**
@@ -928,8 +929,7 @@ public void onDestroy() {
928
929
mAudioFocusManager .onDestroy ();
929
930
mAudioFocusManager =null ;
930
931
}
931
- mLoop =false ;mSoundMute =false ;mVideoWidth =0 ;mVideoHeight =0 ;mPrepareTimeout =0 ;mReadTimeout =0 ;
932
- IVideoManager .getInstance ().setZoomModel (IMediaPlayer .MODE_ZOOM_CROPPING );
932
+ mLoop =false ;mSoundMute =false ;mMirrors =false ;mVideoWidth =0 ;mVideoHeight =0 ;mPrepareTimeout =0 ;mReadTimeout =0 ;mZoomMode =0 ;
933
933
mBasePlayer =null ;mDataSource =null ;mAssetsSource =null ;
934
934
mCallBackSpaceMilliss =DEFAULT_CALLBACK_TIME ;
935
935
}
0 commit comments