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 个修改的文件
包含
129 行增加
和
6 行删除
+129
-6
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
+0
-0
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
差异被折叠。
点击展开。
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
];
[
_pipEventChannel
setStreamHandler
:
self
];
[
audioManager
registerVolumeChangeListener
:
self
selector
:
@selector
(
systemVolumeDidChangeNoti
:
)
name
:
@"AVSystemController_SystemVolumeDidChangeNotification"
object
:
nil
];
[
audioManager
registerVolumeChangeListener
:
self
selector
:
@selector
(
systemVolumeDidChangeNoti
:
)
name
:
@"AVSystemController_SystemVolumeDidChangeNotification"
object
:
nil
];
// pip
[
_pipEventChannel
setStreamHandler
:
self
];
// download
_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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论