Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
tx_player_fork
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
tx_player_fork
Commits
caf58ffa
提交
caf58ffa
authored
7月 27, 2022
作者:
kongdywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SuperPlayer supports screen autorotation for Android&iOS platform
上级
5f170bba
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
221 行增加
和
59 行删除
+221
-59
FTXEvent.java
...droid/src/main/java/com/tencent/vod/flutter/FTXEvent.java
+13
-0
SuperPlayerPlugin.java
.../main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
+45
-3
superplayer_widget.dart
Flutter/example/lib/superplayer/ui/superplayer_widget.dart
+92
-53
FTXAudioManager.m
Flutter/ios/Classes/FTXAudioManager.m
+2
-0
FTXEvent.h
Flutter/ios/Classes/FTXEvent.h
+13
-0
SuperPlayerPlugin.m
Flutter/ios/Classes/SuperPlayerPlugin.m
+49
-2
superplayer_plugin.dart
Flutter/lib/Core/superplayer_plugin.dart
+1
-1
txplayer_define.dart
Flutter/lib/Core/txplayer_define.dart
+6
-0
没有找到文件。
Flutter/android/src/main/java/com/tencent/vod/flutter/FTXEvent.java
浏览文件 @
caf58ffa
...
@@ -58,4 +58,17 @@ public class FTXEvent {
...
@@ -58,4 +58,17 @@ public class FTXEvent {
// pip 错误,当前界面已销毁
// pip 错误,当前界面已销毁
public
static
final
int
ERROR_PIP_ACTIVITY_DESTROYED
=
-
103
;
public
static
final
int
ERROR_PIP_ACTIVITY_DESTROYED
=
-
103
;
// 屏幕旋转事件
public
static
final
int
EVENT_ORIENTATION_CHANGED
=
401
;
// 屏幕旋转方向
public
static
final
String
EXTRA_NAME_ORIENTATION
=
"orientation"
;
// 正竖屏
public
static
final
int
ORIENTATION_PORTRAIT_UP
=
411
;
// 横屏,底部在右
public
static
final
int
ORIENTATION_LANDSCAPE_RIGHT
=
412
;
// 竖屏,顶部在下
public
static
final
int
ORIENTATION_PORTRAIT_DOWN
=
413
;
// 横屏,底部在左
public
static
final
int
ORIENTATION_LANDSCAPE_LEFT
=
414
;
}
}
Flutter/android/src/main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
浏览文件 @
caf58ffa
...
@@ -7,8 +7,10 @@ import android.content.Intent;
...
@@ -7,8 +7,10 @@ import android.content.Intent;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
android.media.AudioManager
;
import
android.media.AudioManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.SparseArray
;
import
android.util.SparseArray
;
import
android.view.OrientationEventListener
;
import
android.view.Window
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
...
@@ -58,6 +60,9 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -58,6 +60,9 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
private
FTXAudioManager
mTxAudioManager
;
private
FTXAudioManager
mTxAudioManager
;
private
FTXPIPManager
mTxPipManager
;
private
FTXPIPManager
mTxPipManager
;
private
OrientationEventListener
mOrientationManager
;
private
int
mCurrentOrientation
=
FTXEvent
.
ORIENTATION_PORTRAIT_UP
;
private
final
FTXAudioManager
.
AudioFocusChangeListener
audioFocusChangeListener
=
private
final
FTXAudioManager
.
AudioFocusChangeListener
audioFocusChangeListener
=
new
FTXAudioManager
.
AudioFocusChangeListener
()
{
new
FTXAudioManager
.
AudioFocusChangeListener
()
{
@Override
@Override
...
@@ -78,8 +83,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -78,8 +83,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
channel
.
setMethodCallHandler
(
this
);
channel
.
setMethodCallHandler
(
this
);
mPlayers
=
new
SparseArray
();
mPlayers
=
new
SparseArray
();
initAudioManagerIfNeed
();
initAudioManagerIfNeed
();
mEventChannel
=
new
EventChannel
(
flutterPluginBinding
.
getBinaryMessenger
(),
"cloud.tencent"
+
mEventChannel
=
new
EventChannel
(
flutterPluginBinding
.
getBinaryMessenger
(),
"cloud.tencent.com/playerPlugin/event"
);
".com/playerPlugin/event"
);
mEventChannel
.
setStreamHandler
(
new
EventChannel
.
StreamHandler
()
{
mEventChannel
.
setStreamHandler
(
new
EventChannel
.
StreamHandler
()
{
@Override
@Override
public
void
onListen
(
Object
o
,
EventChannel
.
EventSink
eventSink
)
{
public
void
onListen
(
Object
o
,
EventChannel
.
EventSink
eventSink
)
{
...
@@ -92,6 +96,31 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -92,6 +96,31 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
}
}
});
});
mFTXDownloadManager
=
new
FTXDownloadManager
(
mFlutterPluginBinding
);
mFTXDownloadManager
=
new
FTXDownloadManager
(
mFlutterPluginBinding
);
mOrientationManager
=
new
OrientationEventListener
(
flutterPluginBinding
.
getApplicationContext
())
{
@Override
public
void
onOrientationChanged
(
int
orientation
)
{
if
(
isAutoRotateOn
())
{
int
orientationEvent
=
mCurrentOrientation
;
// 每个方向判断当前方向正负30度,共计60度的区间
if
(((
orientation
>=
0
)
&&
(
orientation
<
30
))
||
(
orientation
>
330
))
{
orientationEvent
=
FTXEvent
.
ORIENTATION_PORTRAIT_UP
;
}
else
if
(
orientation
>
240
&&
orientation
<
300
)
{
orientationEvent
=
FTXEvent
.
ORIENTATION_LANDSCAPE_RIGHT
;
}
else
if
(
orientation
>
150
&&
orientation
<
210
)
{
orientationEvent
=
FTXEvent
.
ORIENTATION_PORTRAIT_DOWN
;
}
else
if
(
orientation
>
60
&&
orientation
<
110
)
{
orientationEvent
=
FTXEvent
.
ORIENTATION_LANDSCAPE_LEFT
;
}
if
(
orientationEvent
!=
mCurrentOrientation
)
{
mCurrentOrientation
=
orientationEvent
;
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
FTXEvent
.
EXTRA_NAME_ORIENTATION
,
orientationEvent
);
mEventSink
.
success
(
getParams
(
FTXEvent
.
EVENT_ORIENTATION_CHANGED
,
bundle
));
}
}
}
};
mOrientationManager
.
enable
();
}
}
@Override
@Override
...
@@ -228,6 +257,9 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -228,6 +257,9 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
if
(
null
!=
mTxPipManager
)
{
if
(
null
!=
mTxPipManager
)
{
mTxPipManager
.
releaseReceiver
();
mTxPipManager
.
releaseReceiver
();
}
}
if
(
null
!=
mOrientationManager
)
{
mOrientationManager
.
disable
();
}
unregisterReceiver
();
unregisterReceiver
();
}
}
...
@@ -240,10 +272,20 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -240,10 +272,20 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
}
}
/**
/**
*
注册音量广播接收器
*
系统是否允许自动旋转屏幕
*
*
* @return
* @return
*/
*/
protected
boolean
isAutoRotateOn
()
{
//获取系统是否允许自动旋转屏幕
return
(
android
.
provider
.
Settings
.
System
.
getInt
(
mFlutterPluginBinding
.
getApplicationContext
().
getContentResolver
(),
Settings
.
System
.
ACCELEROMETER_ROTATION
,
0
)
==
1
);
}
/**
* 注册音量广播接收器
*/
public
void
registerReceiver
()
{
public
void
registerReceiver
()
{
// volume receiver
// volume receiver
mVolumeBroadcastReceiver
=
new
VolumeBroadcastReceiver
();
mVolumeBroadcastReceiver
=
new
VolumeBroadcastReceiver
();
...
...
Flutter/example/lib/superplayer/ui/superplayer_widget.dart
浏览文件 @
caf58ffa
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
part of
demo_super_player_lib
;
part of
demo_super_player_lib
;
final
double
topBottomOffset
=
0
;
final
double
topBottomOffset
=
0
;
DeviceOrientation
landscapeOrientation
=
DeviceOrientation
.
landscapeLeft
;
int
manualOrientationDirection
=
TXVodPlayEvent
.
ORIENTATION_LANDSCAPE_RIGHT
;
FullScreenController
_fullScreenController
=
FullScreenController
();
/// superplayer view widget
/// superplayer view widget
class
SuperPlayerView
extends
StatefulWidget
{
class
SuperPlayerView
extends
StatefulWidget
{
...
@@ -40,7 +41,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -40,7 +41,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
late
_BottomViewController
_bottomViewController
;
late
_BottomViewController
_bottomViewController
;
late
_QualityListViewController
_qualitListViewController
;
late
_QualityListViewController
_qualitListViewController
;
late
_VideoTitleController
_titleViewController
;
late
_VideoTitleController
_titleViewController
;
late
_SuperPlayerFullScreenController
_
fullScreen
Controller
;
late
_SuperPlayerFullScreenController
_
superPlayerFullUI
Controller
;
late
_CoverViewController
_coverViewController
;
late
_CoverViewController
_coverViewController
;
late
_MoreViewController
_moreViewController
;
late
_MoreViewController
_moreViewController
;
...
@@ -59,14 +60,8 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -59,14 +60,8 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
// ios need landscapeRight,android need landscapeLeft
if
(
defaultTargetPlatform
==
TargetPlatform
.
iOS
)
{
landscapeOrientation
=
DeviceOrientation
.
landscapeRight
;
}
else
{
landscapeOrientation
=
DeviceOrientation
.
landscapeLeft
;
}
_playController
=
widget
.
_controller
;
_playController
=
widget
.
_controller
;
_
fullScreen
Controller
=
_SuperPlayerFullScreenController
(
_updateState
);
_
superPlayerFullUI
Controller
=
_SuperPlayerFullScreenController
(
_updateState
);
_titleViewController
=
_VideoTitleController
(
_onTapBack
,
()
{
_titleViewController
=
_VideoTitleController
(
_onTapBack
,
()
{
_moreViewKey
.
currentState
?.
toggleShowMoreView
();
_moreViewKey
.
currentState
?.
toggleShowMoreView
();
});
});
...
@@ -90,8 +85,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -90,8 +85,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
}
}
});
});
// only register listen once
// only register listen once
_pipSubscription
=
_pipSubscription
=
SuperPlayerPlugin
.
instance
.
onExtraEventBroadcast
.
listen
((
event
)
{
SuperPlayerPlugin
.
instance
.
onExtraEventBroadcast
.
listen
((
event
)
{
int
eventCode
=
event
[
"event"
];
int
eventCode
=
event
[
"event"
];
if
(
eventCode
==
TXVodPlayEvent
.
EVENT_PIP_MODE_ALREADY_EXIT
)
{
if
(
eventCode
==
TXVodPlayEvent
.
EVENT_PIP_MODE_ALREADY_EXIT
)
{
// exit floatingMode
// exit floatingMode
...
@@ -133,8 +127,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -133,8 +127,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
print
(
'
$eventCode
'
);
print
(
'
$eventCode
'
);
}
}
});
});
_volumeSubscription
=
_volumeSubscription
=
SuperPlayerPlugin
.
instance
.
onEventBroadcast
.
listen
((
event
)
{
SuperPlayerPlugin
.
instance
.
onEventBroadcast
.
listen
((
event
)
{
int
eventCode
=
event
[
"event"
];
int
eventCode
=
event
[
"event"
];
if
(
_isFloatingMode
&&
_isPlaying
)
{
if
(
_isFloatingMode
&&
_isPlaying
)
{
if
(
eventCode
==
TXVodPlayEvent
.
EVENT_AUDIO_FOCUS_PAUSE
)
{
if
(
eventCode
==
TXVodPlayEvent
.
EVENT_AUDIO_FOCUS_PAUSE
)
{
...
@@ -143,6 +136,12 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -143,6 +136,12 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
_onResume
();
_onResume
();
}
}
}
}
// 画中画模式下,不进行旋转屏幕操作
if
(
eventCode
==
TXVodPlayEvent
.
EVENT_ORIENTATION_CHANGED
&&
!
_isFloatingMode
)
{
int
orientation
=
event
[
TXVodPlayEvent
.
EXTRA_NAME_ORIENTATION
];
_fullScreenController
.
switchToOrientation
(
orientation
);
}
});
});
_registerObserver
();
_registerObserver
();
_initPlayerState
();
_initPlayerState
();
...
@@ -214,6 +213,22 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -214,6 +213,22 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
// onDispose
// onDispose
_playController
.
_observer
=
null
;
// close observer
_playController
.
_observer
=
null
;
// close observer
});
});
_fullScreenController
.
setListener
(()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
{
return
SuperPlayerFullScreenView
(
_playController
,
_superPlayerFullUIController
);
}));
WidgetsBinding
.
instance
?.
removeObserver
(
this
);
_videoBottomKey
.
currentState
?.
updateFullScreen
(
true
);
_videoTitleKey
.
currentState
?.
updateFullScreen
(
true
);
_playController
.
_updateFullScreenState
(
true
);
hideControlView
();
},
()
{
Navigator
.
of
(
context
).
pop
();
_videoBottomKey
.
currentState
?.
updateFullScreen
(
false
);
_videoTitleKey
.
currentState
?.
updateFullScreen
(
false
);
_playController
.
_updateFullScreenState
(
false
);
hideControlView
();
});
WidgetsBinding
.
instance
?.
addObserver
(
this
);
WidgetsBinding
.
instance
?.
addObserver
(
this
);
}
}
...
@@ -238,11 +253,6 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -238,11 +253,6 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
_isLoading
=
true
;
_isLoading
=
true
;
break
;
break
;
}
}
if
(
_isFullScreen
)
{
SystemChrome
.
setPreferredOrientations
([
landscapeOrientation
]);
}
else
{
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
]);
}
}
}
void
_updateState
()
{
void
_updateState
()
{
...
@@ -268,10 +278,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -268,10 +278,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
Orientation
currentOrientation
=
MediaQuery
.
of
(
context
).
orientation
;
Orientation
currentOrientation
=
MediaQuery
.
of
(
context
).
orientation
;
bool
isLandscape
=
currentOrientation
==
Orientation
.
landscape
;
bool
isLandscape
=
currentOrientation
==
Orientation
.
landscape
;
if
(!
isLandscape
)
{
if
(!
isLandscape
)
{
///关闭状态栏,与RootViewController底部虚拟操作按钮
_fullScreenController
.
forceSwitchOrientation
(
manualOrientationDirection
);
SystemChrome
.
setPreferredOrientations
([
landscapeOrientation
]);
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
immersive
);
AutoOrientation
.
landscapeAutoMode
();
}
}
}
}
}
else
if
(
state
==
AppLifecycleState
.
inactive
)
{
}
else
if
(
state
==
AppLifecycleState
.
inactive
)
{
...
@@ -467,7 +474,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -467,7 +474,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
forwardIcon:
"images/ic_pip_play_forward.png"
);
forwardIcon:
"images/ic_pip_play_forward.png"
);
if
(
null
!=
result
)
{
if
(
null
!=
result
)
{
String
failedStr
=
""
;
String
failedStr
=
""
;
if
(
result
!=
TXVodPlayEvent
.
NO_ERROR
)
{
if
(
result
!=
TXVodPlayEvent
.
NO_ERROR
)
{
if
(
result
==
TXVodPlayEvent
.
ERROR_PIP_LOWER_VERSION
)
{
if
(
result
==
TXVodPlayEvent
.
ERROR_PIP_LOWER_VERSION
)
{
failedStr
=
"enterPip failed,because android version is too low,Minimum supported version is android 24"
;
failedStr
=
"enterPip failed,because android version is too low,Minimum supported version is android 24"
;
}
else
if
(
result
==
TXVodPlayEvent
.
ERROR_PIP_DENIED_PERMISSION
)
{
}
else
if
(
result
==
TXVodPlayEvent
.
ERROR_PIP_DENIED_PERMISSION
)
{
...
@@ -546,37 +553,17 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -546,37 +553,17 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
}
}
}
}
void
_fullScreenOrientation
()
{
void
_handleFullScreen
(
bool
toSwitchFullScreen
)
{
if
(
_isFullScreen
)
{
if
(
toSwitchFullScreen
)
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
{
_fullScreenController
.
switchToOrientation
(
manualOrientationDirection
);
return
SuperPlayerFullScreenView
(
_playController
,
_fullScreenController
);
}));
WidgetsBinding
.
instance
?.
removeObserver
(
this
);
}
else
{
}
else
{
// exit fullscreen widget
_fullScreenController
.
switchToOrientation
(
TXVodPlayEvent
.
ORIENTATION_PORTRAIT_UP
);
Navigator
.
of
(
context
).
pop
();
///显示状态栏,与底部虚拟操作按钮
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
]);
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
manual
,
overlays:
SystemUiOverlay
.
values
);
AutoOrientation
.
portraitAutoMode
();
/// 隐藏moreView
_moreViewKey
.
currentState
?.
hideShowMoreView
();
}
}
_videoBottomKey
.
currentState
?.
updateFullScreen
(
_isFullScreen
);
_videoTitleKey
.
currentState
?.
updateFullScreen
(
_isFullScreen
);
}
}
void
_onControlFullScreen
()
{
void
_onControlFullScreen
()
{
_isFullScreen
=
!
_isFullScreen
;
_isFullScreen
=
!
_isFullScreen
;
if
(
_isFullScreen
)
{
_handleFullScreen
(
_isFullScreen
);
hideControlView
();
_fullScreenOrientation
();
}
else
{
hideControlView
();
_fullScreenOrientation
();
}
_playController
.
_updateFullScreenState
(
_isFullScreen
);
_playController
.
_updateFullScreenState
(
_isFullScreen
);
}
}
...
@@ -625,6 +612,8 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
...
@@ -625,6 +612,8 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
if
(!
_isShowControlView
||
!
mounted
)
{
if
(!
_isShowControlView
||
!
mounted
)
{
return
;
return
;
}
}
/// 隐藏moreView
_moreViewKey
.
currentState
?.
hideShowMoreView
();
setState
(()
{
setState
(()
{
_isShowQualityListView
=
false
;
_isShowQualityListView
=
false
;
_isShowControlView
=
false
;
_isShowControlView
=
false
;
...
@@ -654,11 +643,6 @@ class SuperPlayerFullScreenState extends State<SuperPlayerFullScreenView> {
...
@@ -654,11 +643,6 @@ class SuperPlayerFullScreenState extends State<SuperPlayerFullScreenView> {
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
///关闭状态栏,与底部虚拟操作按钮
SystemChrome
.
setPreferredOrientations
([
landscapeOrientation
]);
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
immersive
);
AutoOrientation
.
landscapeAutoMode
();
}
}
@override
@override
...
@@ -834,3 +818,58 @@ class _SuperPlayerFloatState extends State<SuperPlayerFloatView> {
...
@@ -834,3 +818,58 @@ class _SuperPlayerFloatState extends State<SuperPlayerFloatView> {
sizeStreamSubscription
?.
cancel
();
sizeStreamSubscription
?.
cancel
();
}
}
}
}
class
FullScreenController
{
bool
_isInFullScreenUI
=
false
;
int
currentOrientation
=
TXVodPlayEvent
.
ORIENTATION_PORTRAIT_UP
;
Function
?
onEnterFullScreenUI
;
Function
?
onExitFullScreenUI
;
FullScreenController
();
void
switchToOrientation
(
int
orientationDirection
)
{
if
(
currentOrientation
!=
orientationDirection
)
{
forceSwitchOrientation
(
orientationDirection
);
}
}
void
forceSwitchOrientation
(
int
orientationDirection
)
{
currentOrientation
=
orientationDirection
;
if
(
orientationDirection
==
TXVodPlayEvent
.
ORIENTATION_PORTRAIT_UP
)
{
exitFullScreen
();
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
]);
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
manual
,
overlays:
SystemUiOverlay
.
values
);
AutoOrientation
.
portraitUpMode
();
}
else
if
(
orientationDirection
==
TXVodPlayEvent
.
ORIENTATION_LANDSCAPE_RIGHT
)
{
enterFullScreen
();
SystemChrome
.
setPreferredOrientations
(
Platform
.
isIOS
?
[
DeviceOrientation
.
landscapeRight
]
:
[
DeviceOrientation
.
landscapeLeft
]);
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
immersive
);
AutoOrientation
.
landscapeRightMode
();
}
else
if
(
orientationDirection
==
TXVodPlayEvent
.
ORIENTATION_PORTRAIT_DOWN
)
{
}
else
if
(
orientationDirection
==
TXVodPlayEvent
.
ORIENTATION_LANDSCAPE_LEFT
)
{
enterFullScreen
();
SystemChrome
.
setPreferredOrientations
(
Platform
.
isIOS
?
[
DeviceOrientation
.
landscapeLeft
]
:
[
DeviceOrientation
.
landscapeRight
]);
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
immersive
);
AutoOrientation
.
landscapeLeftMode
();
}
}
void
enterFullScreen
()
{
if
(!
_isInFullScreenUI
)
{
_isInFullScreenUI
=
true
;
onEnterFullScreenUI
?.
call
();
}
}
void
exitFullScreen
()
{
if
(
_isInFullScreenUI
)
{
_isInFullScreenUI
=
false
;
onExitFullScreenUI
?.
call
();
}
}
void
setListener
(
Function
enterfullScreen
,
Function
exitFullScreen
)
{
this
.
onExitFullScreenUI
=
exitFullScreen
;
this
.
onEnterFullScreenUI
=
enterfullScreen
;
}
}
Flutter/ios/Classes/FTXAudioManager.m
浏览文件 @
caf58ffa
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
[
volumeView
sizeToFit
];
[
volumeView
sizeToFit
];
// 单例slider
// 单例slider
_volumeSlider
=
nil
;
_volumeSlider
=
nil
;
//开始接收遥控事件
[[
UIApplication
sharedApplication
]
beginReceivingRemoteControlEvents
];
for
(
UIView
*
view
in
[
volumeView
subviews
])
{
for
(
UIView
*
view
in
[
volumeView
subviews
])
{
if
([
view
.
class
.
description
isEqualToString
:
@"MPVolumeSlider"
])
{
if
([
view
.
class
.
description
isEqualToString
:
@"MPVolumeSlider"
])
{
_volumeSlider
=
(
UISlider
*
)
view
;
_volumeSlider
=
(
UISlider
*
)
view
;
...
...
Flutter/ios/Classes/FTXEvent.h
浏览文件 @
caf58ffa
...
@@ -44,4 +44,17 @@
...
@@ -44,4 +44,17 @@
// 视频下载错误
// 视频下载错误
#define EVENT_DOWNLOAD_ERROR 305
#define EVENT_DOWNLOAD_ERROR 305
// 屏幕旋转事件
#define EVENT_ORIENTATION_CHANGED 401
// 屏幕旋转方向
#define EXTRA_NAME_ORIENTATION @"orientation"
// 正竖屏
#define ORIENTATION_PORTRAIT_UP 411
// 横屏,底部在右
#define ORIENTATION_LANDSCAPE_RIGHT 412
// 竖屏,顶部在下
#define ORIENTATION_PORTRAIT_DOWN 413
// 横屏,底部在左
#define ORIENTATION_LANDSCAPE_LEFT 414
#endif
/* FTXEvent_h */
#endif
/* FTXEvent_h */
Flutter/ios/Classes/SuperPlayerPlugin.m
浏览文件 @
caf58ffa
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
FTXPlayerEventSinkQueue
*
_pipEventSink
;
FTXPlayerEventSinkQueue
*
_pipEventSink
;
FTXAudioManager
*
audioManager
;
FTXAudioManager
*
audioManager
;
FTXDownloadManager
*
_FTXDownloadManager
;
FTXDownloadManager
*
_FTXDownloadManager
;
int
mCurrentOrientation
;
}
}
SuperPlayerPlugin
*
instance
;
SuperPlayerPlugin
*
instance
;
...
@@ -43,6 +44,7 @@ SuperPlayerPlugin* instance;
...
@@ -43,6 +44,7 @@ SuperPlayerPlugin* instance;
if
(
nil
!=
_FTXDownloadManager
)
{
if
(
nil
!=
_FTXDownloadManager
)
{
[
_FTXDownloadManager
destroy
];
[
_FTXDownloadManager
destroy
];
}
}
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
}
}
-
(
instancetype
)
initWithRegistrar
:
-
(
instancetype
)
initWithRegistrar
:
...
@@ -62,10 +64,18 @@ SuperPlayerPlugin* instance;
...
@@ -62,10 +64,18 @@ SuperPlayerPlugin* instance;
_eventChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"cloud.tencent.com/playerPlugin/event"
binaryMessenger
:[
registrar
messenger
]];
_eventChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"cloud.tencent.com/playerPlugin/event"
binaryMessenger
:[
registrar
messenger
]];
_pipEventChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"cloud.tencent.com/playerPlugin/pipEvent"
binaryMessenger
:[
registrar
messenger
]];
_pipEventChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"cloud.tencent.com/playerPlugin/pipEvent"
binaryMessenger
:[
registrar
messenger
]];
[
_eventChannel
setStreamHandler
:
self
];
[
_eventChannel
setStreamHandler
:
self
];
[
audioManager
registerVolumeChangeListener
:
self
selector
:
@selector
(
systemVolumeDidChangeNoti
:
)
name
:
@"AVSystemController_SystemVolumeDidChangeNotification"
object
:
nil
];
// pip
[
_pipEventChannel
setStreamHandler
:
self
];
[
_pipEventChannel
setStreamHandler
:
self
];
// download
[
audioManager
registerVolumeChangeListener
:
self
selector
:
@selector
(
systemVolumeDidChangeNoti
:
)
name
:
@"AVSystemController_SystemVolumeDidChangeNotification"
object
:
nil
];
_FTXDownloadManager
=
[[
FTXDownloadManager
alloc
]
initWithRegistrar
:
registrar
];
_FTXDownloadManager
=
[[
FTXDownloadManager
alloc
]
initWithRegistrar
:
registrar
];
// orientation
mCurrentOrientation
=
ORIENTATION_PORTRAIT_UP
;
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
onDeviceOrientationChange
:
)
name:
UIDeviceOrientationDidChangeNotification
object:
nil
];
return
self
;
return
self
;
}
}
...
@@ -203,6 +213,7 @@ SuperPlayerPlugin* instance;
...
@@ -203,6 +213,7 @@ SuperPlayerPlugin* instance;
if
([
arguments
isKindOfClass
:
NSString
.
class
])
{
if
([
arguments
isKindOfClass
:
NSString
.
class
])
{
if
([
arguments
isEqualToString
:
@"event"
])
{
if
([
arguments
isEqualToString
:
@"event"
])
{
[
_eventSink
setDelegate
:
events
];
[
_eventSink
setDelegate
:
events
];
}
else
if
([
arguments
isEqualToString
:
@"pipEvent"
])
{
[
_pipEventSink
setDelegate
:
events
];
[
_pipEventSink
setDelegate
:
events
];
}
}
}
}
...
@@ -215,6 +226,7 @@ SuperPlayerPlugin* instance;
...
@@ -215,6 +226,7 @@ SuperPlayerPlugin* instance;
if
([
arguments
isKindOfClass
:
NSString
.
class
])
{
if
([
arguments
isKindOfClass
:
NSString
.
class
])
{
if
([
arguments
isEqualToString
:
@"event"
])
{
if
([
arguments
isEqualToString
:
@"event"
])
{
[
_eventSink
setDelegate
:
nil
];
[
_eventSink
setDelegate
:
nil
];
}
else
if
([
arguments
isEqualToString
:
@"pipEvent"
])
{
[
_pipEventSink
setDelegate
:
nil
];
[
_pipEventSink
setDelegate
:
nil
];
}
}
}
}
...
@@ -247,4 +259,39 @@ SuperPlayerPlugin* instance;
...
@@ -247,4 +259,39 @@ SuperPlayerPlugin* instance;
[
_pipEventSink
success
:@{
@"event"
:
@
(
EVENT_PIP_MODE_RESTORE_UI
)}];
[
_pipEventSink
success
:@{
@"event"
:
@
(
EVENT_PIP_MODE_RESTORE_UI
)}];
}
}
#pragma mark - orientation
-
(
void
)
onDeviceOrientationChange
:
(
NSNotification
*
)
notification
{
// IOS 此处不需要判断是否打开自动屏幕旋转/竖排锁定开关,当IOS打开锁定之后,这里默认是收不到回调的
UIDeviceOrientation
orientation
=
[
UIDevice
currentDevice
].
orientation
;
UIInterfaceOrientation
interfaceOrientation
=
(
UIInterfaceOrientation
)
orientation
;
int
tempOrientationCode
=
mCurrentOrientation
;
switch
(
interfaceOrientation
)
{
case
UIInterfaceOrientationPortrait
:
// 电池栏在上
tempOrientationCode
=
ORIENTATION_PORTRAIT_UP
;
break
;
case
UIInterfaceOrientationLandscapeLeft
:
// 电池栏在左
tempOrientationCode
=
ORIENTATION_LANDSCAPE_LEFT
;
break
;
case
UIInterfaceOrientationPortraitUpsideDown
:
// 电池栏在下
tempOrientationCode
=
ORIENTATION_PORTRAIT_DOWN
;
break
;
case
UIInterfaceOrientationLandscapeRight
:
// 电池栏在右
tempOrientationCode
=
ORIENTATION_LANDSCAPE_RIGHT
;
break
;
default
:
break
;
}
if
(
tempOrientationCode
!=
mCurrentOrientation
)
{
mCurrentOrientation
=
tempOrientationCode
;
[
_eventSink
success
:@{
@"event"
:
@
(
EVENT_ORIENTATION_CHANGED
),
EXTRA_NAME_ORIENTATION
:
@
(
tempOrientationCode
)}];
}
}
@end
@end
Flutter/lib/Core/superplayer_plugin.dart
浏览文件 @
caf58ffa
...
@@ -27,7 +27,7 @@ class SuperPlayerPlugin {
...
@@ -27,7 +27,7 @@ class SuperPlayerPlugin {
eventChannel
.
receiveBroadcastStream
(
"event"
).
listen
(
_eventHandler
,
onError:
_errorHandler
);
eventChannel
.
receiveBroadcastStream
(
"event"
).
listen
(
_eventHandler
,
onError:
_errorHandler
);
EventChannel
pipEventChanne
=
EventChannel
(
"cloud.tencent.com/playerPlugin/pipEvent"
);
EventChannel
pipEventChanne
=
EventChannel
(
"cloud.tencent.com/playerPlugin/pipEvent"
);
pipEventChanne
.
receiveBroadcastStream
(
"
e
vent"
).
listen
(
_pipEventHandler
,
onError:
_errorHandler
);
pipEventChanne
.
receiveBroadcastStream
(
"
pipE
vent"
).
listen
(
_pipEventHandler
,
onError:
_errorHandler
);
}
}
_pipEventHandler
(
event
)
{
_pipEventHandler
(
event
)
{
...
...
Flutter/lib/Core/txplayer_define.dart
浏览文件 @
caf58ffa
...
@@ -97,6 +97,12 @@ abstract class TXVodPlayEvent {
...
@@ -97,6 +97,12 @@ abstract class TXVodPlayEvent {
static
const
EVENT_IOS_PIP_MODE_RESTORE_UI
=
5
;
// 重置UI only support iOS
static
const
EVENT_IOS_PIP_MODE_RESTORE_UI
=
5
;
// 重置UI only support iOS
static
const
EVENT_IOS_PIP_MODE_WILL_EXIT
=
6
;
// 将要退出画中画 only support iOS
static
const
EVENT_IOS_PIP_MODE_WILL_EXIT
=
6
;
// 将要退出画中画 only support iOS
static
const
EVENT_ORIENTATION_CHANGED
=
401
;
// 屏幕发生旋转
static
const
EXTRA_NAME_ORIENTATION
=
"orientation"
;
// 屏幕旋转方向
static
const
ORIENTATION_PORTRAIT_UP
=
411
;
// 竖屏,顶部在上
static
const
ORIENTATION_LANDSCAPE_RIGHT
=
412
;
// 横屏,顶部在左,底部在右
static
const
ORIENTATION_PORTRAIT_DOWN
=
413
;
// 竖屏,顶部在下
static
const
ORIENTATION_LANDSCAPE_LEFT
=
414
;
// 横屏,顶部在右,底部在左
static
const
NO_ERROR
=
0
;
static
const
NO_ERROR
=
0
;
static
const
ERROR_PIP_LOWER_VERSION
=
-
101
;
// pip 错误,android版本过低
static
const
ERROR_PIP_LOWER_VERSION
=
-
101
;
// pip 错误,android版本过低
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论