Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
tx_player_fork
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
tx_player_fork
Commits
22b9c597
提交
22b9c597
authored
10月 12, 2022
作者:
kongdywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add orientation independent api
上级
9ad499d0
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
100 行增加
和
46 行删除
+100
-46
README.md
Flutter/README.md
+1
-1
SuperPlayerPlugin.java
.../main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
+55
-32
API文档.md
Flutter/docs/API文档.md
+26
-0
demo_superplayer.dart
Flutter/example/lib/demo_superplayer.dart
+3
-13
SuperPlayerPlugin.m
Flutter/ios/Classes/SuperPlayerPlugin.m
+3
-0
superplayer_plugin.dart
Flutter/lib/Core/superplayer_plugin.dart
+12
-0
没有找到文件。
Flutter/README.md
浏览文件 @
22b9c597
...
...
@@ -39,7 +39,7 @@
-
[
点播播放
](
https://github.com/LiteAVSDK/Player_Flutter/blob/main/Flutter/docs/%E7%82%B9%E6%92%AD%E6%92%AD%E6%94%BE.md
)
:
`TXVodPlayerController`
对Android和iOS两个平台的点播播放器SDK进行接口封装, 你可以通过集成
`TXVodPlayerController`
进行点播播放业务开发。详细使用例子可以参考
`DemoTXVodPlayer`
。
-
[
直播播放
](
https://github.com/LiteAVSDK/Player_Flutter/blob/main/Flutter/docs/%E7%9B%B4%E6%92%AD%E6%92%AD%E6%94%BE.md
)
:
`TXLivePlayerController`
对Android和iOS两个平台的直播播放器SDK进行接口封装, 你可以通过集成
`TXLivePlayerController`
进行直播播放业务开发。详细使用例子可以参考
`DemoTXLivePlayer`
。
-
[
播放器API文档
](
./docs/API
文档.md):包含播放器配置、点播播放和直播播放等API使用说明。
-
[
播放器API文档
](
./docs/API文档.md
)
:包含播放器配置、点播播放和直播播放等API使用说明。
为了减少接入成本, 在example里提供了播放器组件(带UI的播放器),基于播放器组件简单的几行代码就可以搭建视频播放业务。您可以根据自己项目的需求, 把播放组件的相关代码应用到项目中去,根据需求进行调整UI和交互细节。
...
...
Flutter/android/src/main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
浏览文件 @
22b9c597
...
...
@@ -9,6 +9,7 @@ import android.media.AudioManager;
import
android.os.Bundle
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.SparseArray
;
import
android.view.OrientationEventListener
;
import
android.view.Window
;
...
...
@@ -95,32 +96,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
mEventSink
.
setEventSinkProxy
(
null
);
}
});
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
();
mFTXDownloadManager
=
new
FTXDownloadManager
(
flutterPluginBinding
);
}
@Override
...
...
@@ -214,11 +190,53 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
String
envConfig
=
call
.
argument
(
"envConfig"
);
int
setResult
=
TXLiveBase
.
setGlobalEnv
(
envConfig
);
result
.
success
(
setResult
);
}
else
if
(
call
.
method
.
equals
(
"startVideoOrientationService"
))
{
boolean
setResult
=
startVideoOrientationService
();
result
.
success
(
setResult
);
}
else
{
result
.
notImplemented
();
}
}
private
boolean
startVideoOrientationService
()
{
if
(
null
==
mFlutterPluginBinding
)
{
return
false
;
}
if
(
null
==
mOrientationManager
)
{
try
{
mOrientationManager
=
new
OrientationEventListener
(
mFlutterPluginBinding
.
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
();
}
catch
(
Exception
e
)
{
Log
.
getStackTraceString
(
e
);
return
false
;
}
}
return
true
;
}
private
void
initAudioManagerIfNeed
()
{
if
(
null
==
mTxAudioManager
)
{
mTxAudioManager
=
new
FTXAudioManager
(
mFlutterPluginBinding
.
getApplicationContext
());
...
...
@@ -238,6 +256,9 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
channel
.
setMethodCallHandler
(
null
);
mFTXDownloadManager
.
destroy
();
mFlutterPluginBinding
=
null
;
if
(
null
!=
mOrientationManager
)
{
mOrientationManager
.
disable
();
}
}
@Override
...
...
@@ -261,9 +282,6 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
if
(
null
!=
mTxPipManager
)
{
mTxPipManager
.
releaseReceiver
();
}
if
(
null
!=
mOrientationManager
)
{
mOrientationManager
.
disable
();
}
unregisterReceiver
();
}
...
...
@@ -282,9 +300,14 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
*/
protected
boolean
isAutoRotateOn
()
{
//获取系统是否允许自动旋转屏幕
return
(
android
.
provider
.
Settings
.
System
.
getInt
(
mFlutterPluginBinding
.
getApplicationContext
().
getContentResolver
(),
Settings
.
System
.
ACCELEROMETER_ROTATION
,
0
)
==
1
);
try
{
return
(
android
.
provider
.
Settings
.
System
.
getInt
(
mFlutterPluginBinding
.
getApplicationContext
().
getContentResolver
(),
Settings
.
System
.
ACCELEROMETER_ROTATION
,
0
)
==
1
);
}
catch
(
Exception
e
)
{
Log
.
getStackTraceString
(
e
);
return
false
;
}
}
/**
...
...
Flutter/docs/API
文档.md
→
Flutter/docs/API文档.md
浏览文件 @
22b9c597
...
...
@@ -415,6 +415,32 @@ static Future<int> setGlobalEnv(String envConfig) async;
| ------ | ------ | ------------------ |
| result | int | 1 设置成功, 2 设置失败 |
### startVideoOrientationService
**说明**
开始监听设备旋转方向,开启之后,如果设备自动旋转打开,播放器会自动根据当前设备方向来旋转视频方向。
该接口目前只适用安卓端,IOS端会自动开启该能力。
**注意**
在调用该接口前,请务必向用户告知隐私风险。
**接口**
```
dart
static
Future
<
bool
>
startVideoOrientationService
()
async
```
**参数说明**
无
**返回值说明**
| 参数名 | 类型 | 描述 |
| ------ | ------ | ------------------ |
| result | bool | true 开启成功,false 开启失败,如开启过早,还未等到上下文初始化、获取sensor失败等原因 |
## TXVodPlayerController类
...
...
Flutter/example/lib/demo_superplayer.dart
浏览文件 @
22b9c597
...
...
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import
'package:flutter_easyloading/flutter_easyloading.dart'
;
import
'package:super_player/super_player.dart'
;
import
'package:super_player_example/ui/demo_inputdialog.dart'
;
import
'superplayer/demo_superplayer_lib.dart'
;
/// flutter superplayer demo
...
...
@@ -29,22 +30,11 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
fontSize:
16
,
color:
Colors
.
grey
);
void
aa
()
async
{
// List<TXVodDownloadMedialnfo> downloadInfoList = await TXVodDownloadController.instance.getDownloadList();
// bool result = await TXVodDownloadController.instance.deleteDownloadMediaInfo(medialnfo);
}
@override
void
initState
()
{
super
.
initState
();
TXVodDownloadMedialnfo
medialnfo
=
TXVodDownloadMedialnfo
();
medialnfo
.
url
=
"http://1500005830.vod2.myqcloud.com/43843ec0vodtranscq1500005830/00eb06a88602268011437356984/video_10_0.m3u8"
;
TXVodDownloadController
.
instance
.
startDonwload
(
medialnfo
);
// 监听设备旋转
SuperPlayerPlugin
.
startVideoOrientationService
();
_controller
=
SuperPlayerController
(
context
);
FTXVodPlayConfig
config
=
FTXVodPlayConfig
();
// 如果不配置preferredResolution,则在播放多码率视频的时候优先播放720 * 1280分辨率的码率
...
...
Flutter/ios/Classes/SuperPlayerPlugin.m
浏览文件 @
22b9c597
...
...
@@ -192,6 +192,9 @@ SuperPlayerPlugin* instance;
NSString
*
envConfig
=
call
.
arguments
[
@"envConfig"
];
int
setResult
=
[
TXLiveBase
setGlobalEnv
:[
envConfig
UTF8String
]];
result
(
@
(
setResult
));
}
else
if
([
@"startVideoOrientationService"
isEqualToString
:
call
.
method
])
{
// only for android
result
(
nil
);
}
else
{
result
(
FlutterMethodNotImplemented
);
}
...
...
Flutter/lib/Core/superplayer_plugin.dart
浏览文件 @
22b9c597
...
...
@@ -166,4 +166,16 @@ class SuperPlayerPlugin {
static
Future
<
int
>
setGlobalEnv
(
String
envConfig
)
async
{
return
await
_channel
.
invokeMethod
(
"setGlobalEnv"
,
{
"envConfig"
:
envConfig
});
}
///
/// 开始监听设备旋转方向,开启之后,如果设备自动旋转打开,播放器会自动根据当前设备方向来旋转视频方向。
/// <h1>该接口目前只适用安卓端,IOS端会自动开启该能力</h1>
/// 在调用该接口前,请务必向用户告知隐私风险。
/// 如有需要,请确认是否有获取旋转sensor的权限。
/// @return true : 开启成功
/// false : 开启失败,如开启过早,还未等到上下文初始化、获取sensor失败等原因
static
Future
<
bool
>
startVideoOrientationService
()
async
{
return
await
_channel
.
invokeMethod
(
"startVideoOrientationService"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论