Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
tx_player_fork
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
tx_player_fork
Commits
4326ba38
提交
4326ba38
authored
5月 24, 2023
作者:
kongdywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.fix ios background crash
2.android brightness range error 3.adjust flutter min version
上级
74b5fed6
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
113 行增加
和
48 行删除
+113
-48
build.gradle
Flutter/android/build.gradle
+1
-3
SuperPlayerPlugin.java
.../main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
+22
-2
集成指引.md
Flutter/docs/集成指引.md
+1
-1
demo_txvodplayer.dart
Flutter/example/lib/demo_txvodplayer.dart
+2
-4
pubspec.yaml
Flutter/example/pubspec.yaml
+3
-3
FTXLivePlayer.h
Flutter/ios/Classes/FTXLivePlayer.h
+2
-0
FTXLivePlayer.m
Flutter/ios/Classes/FTXLivePlayer.m
+32
-20
FTXVodPlayer.h
Flutter/ios/Classes/FTXVodPlayer.h
+2
-0
FTXVodPlayer.m
Flutter/ios/Classes/FTXVodPlayer.m
+18
-7
SuperPlayerPlugin.m
Flutter/ios/Classes/SuperPlayerPlugin.m
+14
-1
common_config.dart
Flutter/lib/Core/common/common_config.dart
+7
-0
txvodplayer_controller.dart
Flutter/lib/Core/txvodplayer_controller.dart
+1
-0
super_player.dart
Flutter/lib/super_player.dart
+3
-2
pubspec.yaml
Flutter/pubspec.yaml
+2
-2
pubspec.yaml
Flutter/superplayer_widget/pubspec.yaml
+3
-3
没有找到文件。
Flutter/android/build.gradle
浏览文件 @
4326ba38
group
'com.tencent.vod.flutter'
apply
from:
'config.gradle'
apply
plugin:
'com.android.library'
version
rootProject
.
ext
.
playerVersion
buildscript
{
...
...
@@ -20,9 +21,6 @@ rootProject.allprojects {
}
}
apply
plugin:
'com.android.library'
android
{
compileSdkVersion
rootProject
.
ext
.
compileSdkVersion
...
...
Flutter/android/src/main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
浏览文件 @
4326ba38
...
...
@@ -7,6 +7,7 @@ import android.content.ContentResolver;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.res.Resources
;
import
android.database.ContentObserver
;
import
android.media.AudioManager
;
import
android.net.Uri
;
...
...
@@ -326,14 +327,33 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
float
screenBrightness
=
-
1
;
try
{
ContentResolver
resolver
=
mActivityPluginBinding
.
getActivity
().
getContentResolver
();
int
brightnessInt
=
Settings
.
System
.
getInt
(
resolver
,
Settings
.
System
.
SCREEN_BRIGHTNESS
);
screenBrightness
=
brightnessInt
/
255
F
;
final
int
brightnessInt
=
Settings
.
System
.
getInt
(
resolver
,
Settings
.
System
.
SCREEN_BRIGHTNESS
);
final
float
maxBrightness
=
getBrightnessMax
();
screenBrightness
=
brightnessInt
/
maxBrightness
;
}
catch
(
SettingNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
screenBrightness
;
}
/**
* 获取最大亮度,兼容部分系统亮度最大值不是255的情况,例如MIUI上最大值被改为了上千
*
* @return max
*/
private
float
getBrightnessMax
()
{
try
{
Resources
system
=
Resources
.
getSystem
();
int
resId
=
system
.
getIdentifier
(
"config_screenBrightnessSettingMaximum"
,
"integer"
,
"android"
);
if
(
resId
!=
0
)
{
return
system
.
getInteger
(
resId
);
}
}
catch
(
Exception
e
)
{
Log
.
getStackTraceString
(
e
);
}
return
255
F
;
}
private
void
initAudioManagerIfNeed
()
{
if
(
null
==
mTxAudioManager
)
{
mTxAudioManager
=
new
FTXAudioManager
(
mFlutterPluginBinding
.
getApplicationContext
());
...
...
Flutter/docs/集成指引.md
浏览文件 @
4326ba38
## 环境准备
-
Flutter
2
.0 及以上版本。
-
Flutter
3
.0 及以上版本。
-
Android 端开发:
-
Android Studio 3.5及以上版本。
-
App 要求 Android 4.1及以上版本设备。
...
...
Flutter/example/lib/demo_txvodplayer.dart
浏览文件 @
4326ba38
...
...
@@ -49,9 +49,9 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer>
if
(
event
[
"event"
]
==
TXVodPlayEvent
.
PLAY_EVT_RCV_FIRST_I_FRAME
)
{
EasyLoading
.
dismiss
();
_supportedBitrates
=
(
await
_controller
.
getSupportedBitrates
())!;
_isPlaying
=
true
;
_resizeVideo
(
event
);
}
else
if
(
event
[
"event"
]
==
TXVodPlayEvent
.
PLAY_EVT_PLAY_PROGRESS
)
{
_isPlaying
=
true
;
_currentProgress
=
event
[
TXVodPlayEvent
.
EVT_PLAY_PROGRESS
].
toDouble
();
double
videoDuration
=
event
[
TXVodPlayEvent
.
EVT_PLAY_DURATION
].
toDouble
();
// 总播放时长,转换后的单位 秒
if
(
videoDuration
==
0.0
)
{
...
...
@@ -112,15 +112,13 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer>
print
(
"didChangeAppLifecycleState
$state
"
);
switch
(
state
)
{
case
AppLifecycleState
.
inactive
:
_controller
.
pause
();
break
;
case
AppLifecycleState
.
resumed
:
if
(
_isPlaying
)
{
_controller
.
resume
();
}
break
;
case
AppLifecycleState
.
paused
:
_controller
.
pause
();
break
;
default
:
break
;
}
...
...
Flutter/example/pubspec.yaml
浏览文件 @
4326ba38
...
...
@@ -6,8 +6,8 @@ description: Demonstrates how to use the super_player plugin.
publish_to
:
'
none'
# Remove this line if you wish to publish to pub.dev
environment
:
sdk
:
'
>=2.1
2.0
<3
.0.0'
flutter
:
"
>=
2
.0.0"
sdk
:
'
>=2.1
7.0
<4
.0.0'
flutter
:
"
>=
3
.0.0"
dependencies
:
# 国际化
...
...
@@ -16,7 +16,7 @@ dependencies:
flutter
:
sdk
:
flutter
flutter_easyloading
:
^3.0.
0
flutter_easyloading
:
^3.0.
5
super_player
:
# When depending on this package from a real application you should use:
...
...
Flutter/ios/Classes/FTXLivePlayer.h
浏览文件 @
4326ba38
...
...
@@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
-
(
instancetype
)
initWithRegistrar
:(
id
<
FlutterPluginRegistrar
>
)
registrar
;
-
(
void
)
notifyAppTerminate
:(
UIApplication
*
)
application
;
@end
NS_ASSUME_NONNULL_END
...
...
Flutter/ios/Classes/FTXLivePlayer.m
浏览文件 @
4326ba38
...
...
@@ -30,6 +30,8 @@ static const int uninitialized = -1;
id
<
FlutterPluginRegistrar
>
_registrar
;
id
<
FlutterTextureRegistry
>
_textureRegistry
;
BOOL
_isTerminate
;
BOOL
_isStoped
;
}
-
(
instancetype
)
initWithRegistrar
:
(
id
<
FlutterPluginRegistrar
>
)
registrar
...
...
@@ -38,6 +40,8 @@ static const int uninitialized = -1;
_registrar
=
registrar
;
_lastBuffer
=
nil
;
_latestPixelBuffer
=
nil
;
_isTerminate
=
NO
;
_isStoped
=
NO
;
_textureId
=
-
1
;
_eventSink
=
[
FTXPlayerEventSinkQueue
new
];
_netStatusSink
=
[
FTXPlayerEventSinkQueue
new
];
...
...
@@ -86,6 +90,11 @@ static const int uninitialized = -1;
_netStatusSink
=
nil
;
}
-
(
void
)
notifyAppTerminate
:
(
UIApplication
*
)
application
{
_isTerminate
=
YES
;
_textureRegistry
=
nil
;
}
-
(
void
)
setupPlayerWithBool
:
(
BOOL
)
onlyAudio
{
if
(
!
onlyAudio
)
{
...
...
@@ -149,6 +158,7 @@ static const int uninitialized = -1;
-
(
int
)
startLivePlay
:
(
NSString
*
)
url
type
:
(
TX_Enum_PlayType
)
playType
{
if
(
_txLivePlayer
!=
nil
)
{
_isStoped
=
NO
;
return
[
_txLivePlayer
startLivePlay
:
url
type
:
playType
];
}
return
uninitialized
;
...
...
@@ -157,6 +167,7 @@ static const int uninitialized = -1;
-
(
BOOL
)
stopPlay
{
if
(
_txLivePlayer
!=
nil
)
{
_isStoped
=
YES
;
return
[
_txLivePlayer
stopPlay
];
}
return
NO
;
...
...
@@ -366,30 +377,31 @@ static const int uninitialized = -1;
*/
-
(
BOOL
)
onPlayerPixelBuffer
:
(
CVPixelBufferRef
)
pixelBuffer
{
if
(
_lastBuffer
==
nil
)
{
_lastBuffer
=
CVPixelBufferRetain
(
pixelBuffer
);
CFRetain
(
pixelBuffer
);
}
else
if
(
_lastBuffer
!=
pixelBuffer
)
{
CVPixelBufferRelease
(
_lastBuffer
);
_lastBuffer
=
CVPixelBufferRetain
(
pixelBuffer
);
CFRetain
(
pixelBuffer
);
}
if
(
!
_isTerminate
&&
!
_isStoped
)
{
if
(
_lastBuffer
==
nil
)
{
_lastBuffer
=
CVPixelBufferRetain
(
pixelBuffer
);
CFRetain
(
pixelBuffer
);
}
else
if
(
_lastBuffer
!=
pixelBuffer
)
{
CVPixelBufferRelease
(
_lastBuffer
);
_lastBuffer
=
CVPixelBufferRetain
(
pixelBuffer
);
CFRetain
(
pixelBuffer
);
}
CVPixelBufferRef
newBuffer
=
pixelBuffer
;
CVPixelBufferRef
newBuffer
=
pixelBuffer
;
CVPixelBufferRef
old
=
_latestPixelBuffer
;
while
(
!
OSAtomicCompareAndSwapPtrBarrier
(
old
,
newBuffer
,
(
void
**
)
&
_latestPixelBuffer
))
{
old
=
_latestPixelBuffer
;
}
CVPixelBufferRef
old
=
_latestPixelBuffer
;
while
(
!
OSAtomicCompareAndSwapPtrBarrier
(
old
,
newBuffer
,
(
void
**
)
&
_latestPixelBuffer
))
{
old
=
_latestPixelBuffer
;
}
if
(
old
&&
old
!=
pixelBuffer
)
{
CFRelease
(
old
);
}
if
(
_textureId
>=
0
)
{
[
_textureRegistry
textureFrameAvailable
:
_textureId
];
if
(
old
&&
old
!=
pixelBuffer
)
{
CFRelease
(
old
);
}
if
(
_textureId
>=
0
&&
_textureRegistry
)
{
[
_textureRegistry
textureFrameAvailable
:
_textureId
];
}
}
return
NO
;
}
...
...
Flutter/ios/Classes/FTXVodPlayer.h
浏览文件 @
4326ba38
...
...
@@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
-
(
instancetype
)
initWithRegistrar
:(
id
<
FlutterPluginRegistrar
>
)
registrar
;
-
(
void
)
notifyAppTerminate
:(
UIApplication
*
)
application
;
@end
NS_ASSUME_NONNULL_END
...
...
Flutter/ios/Classes/FTXVodPlayer.m
浏览文件 @
4326ba38
...
...
@@ -20,6 +20,8 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
@property
(
nonatomic
,
strong
)
UIView
*
txPipView
;
@property
(
nonatomic
,
assign
)
BOOL
hasEnteredPipMode
;
@property
(
nonatomic
,
assign
)
BOOL
restoreUI
;
@property
(
atomic
,
assign
)
BOOL
isStoped
;
@property
(
atomic
)
BOOL
isTerminate
;
@end
/**
...
...
@@ -59,6 +61,8 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
isVideoFirstFrameReceived
=
false
;
videoWidth
=
0
;
videoHeight
=
0
;
_isStoped
=
NO
;
_isTerminate
=
NO
;
playerMainqueue
=
dispatch_get_main_queue
();
self
.
hasEnteredPipMode
=
NO
;
self
.
restoreUI
=
NO
;
...
...
@@ -78,12 +82,18 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
}
-
(
void
)
onApplicationTerminateClick
{
_isTerminate
=
YES
;
[
_txVodPlayer
removeVideoWidget
];
_txVodPlayer
=
nil
;
_txVodPlayer
.
videoProcessDelegate
=
nil
;
_textureId
=
-
1
;
}
-
(
void
)
notifyAppTerminate
:
(
UIApplication
*
)
application
{
_isTerminate
=
YES
;
_textureRegistry
=
nil
;
}
-
(
void
)
destory
{
[
self
stopPlay
];
...
...
@@ -108,7 +118,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
if
(
old
)
{
CFRelease
(
old
);
}
if
(
_lastBuffer
)
{
CVPixelBufferRelease
(
_lastBuffer
);
_lastBuffer
=
nil
;
...
...
@@ -164,6 +174,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
-
(
int
)
startVodPlay
:
(
NSString
*
)
url
{
if
(
_txVodPlayer
!=
nil
)
{
_isStoped
=
NO
;
return
[
_txVodPlayer
startVodPlay
:
url
];
}
return
uninitialized
;
...
...
@@ -178,6 +189,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
if
(
sign
.
length
>
0
)
{
p
.
sign
=
sign
;
}
_isStoped
=
NO
;
return
[
_txVodPlayer
startVodPlayWithParams
:
p
];
}
return
uninitialized
;
...
...
@@ -186,6 +198,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
-
(
BOOL
)
stopPlay
{
if
(
_txVodPlayer
!=
nil
)
{
_isStoped
=
YES
;
return
[
_txVodPlayer
stopPlay
];
}
[
self
releaseImageSprite
];
...
...
@@ -441,7 +454,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
*/
-
(
BOOL
)
onPlayerPixelBuffer
:
(
CVPixelBufferRef
)
pixelBuffer
{
if
(
pixelBuffer
)
{
if
(
!
_isTerminate
&&
!
_isStoped
)
{
if
(
_lastBuffer
==
nil
)
{
_lastBuffer
=
CVPixelBufferRetain
(
pixelBuffer
);
CFRetain
(
pixelBuffer
);
...
...
@@ -462,11 +475,9 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
if
(
old
&&
old
!=
pixelBuffer
)
{
CFRelease
(
old
);
}
}
else
{
NSLog
(
@"receive a nil pixel"
);
}
if
(
_textureId
>=
0
&&
nil
!=
_textureRegistry
)
{
[
_textureRegistry
textureFrameAvailable
:
_textureId
];
if
(
_textureId
>=
0
&&
_textureRegistry
)
{
[
_textureRegistry
textureFrameAvailable
:
_textureId
];
}
}
return
NO
;
...
...
Flutter/ios/Classes/SuperPlayerPlugin.m
浏览文件 @
4326ba38
...
...
@@ -13,7 +13,7 @@
#import "FTXVodPlayerDispatcher.h"
#import "FTXLivePlayerDispatcher.h"
@interface
SuperPlayerPlugin
()
<
FlutterStreamHandler
,
FTXVodPlayerDelegate
,
TXFlutterSuperPlayerPluginAPI
,
TXFlutterNativeAPI
,
IPlayersBridge
>
@interface
SuperPlayerPlugin
()
<
FlutterStreamHandler
,
FTXVodPlayerDelegate
,
TXFlutterSuperPlayerPluginAPI
,
TXFlutterNativeAPI
,
IPlayersBridge
,
FlutterPlugin
>
@property
(
nonatomic
,
strong
)
NSObject
<
FlutterPluginRegistrar
>*
registrar
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
players
;
...
...
@@ -39,6 +39,8 @@ SuperPlayerPlugin* instance;
TXFlutterNativeAPISetup
([
registrar
messenger
],
instance
);
TXFlutterVodPlayerApiSetup
([
registrar
messenger
],
[[
FTXVodPlayerDispatcher
alloc
]
initWithBridge
:
instance
]);
TXFlutterLivePlayerApiSetup
([
registrar
messenger
],
[[
FTXLivePlayerDispatcher
alloc
]
initWithBridge
:
instance
]);
[
registrar
addApplicationDelegate
:
self
];
}
-
(
void
)
detachFromEngineForRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
...
...
@@ -127,6 +129,17 @@ SuperPlayerPlugin* instance;
[
_eventSink
success
:[
SuperPlayerPlugin
getParamsWithEvent
:
EVENT_BRIGHTNESS_CHANGED
withParams
:@{}]];
}
#pragma mark - FlutterPlugin
-
(
void
)
applicationWillTerminate
:
(
UIApplication
*
)
application
{
for
(
id
key
in
self
.
players
)
{
id
player
=
self
.
players
[
key
];
if
([
player
respondsToSelector
:
@selector
(
notifyAppTerminate
:)])
{
[
player
notifyAppTerminate
:
application
];
}
}
}
#pragma mark - FlutterStreamHandler
-
(
FlutterError
*
_Nullable
)
onListenWithArguments
:
(
id
_Nullable
)
arguments
eventSink
:
(
FlutterEventSink
)
events
...
...
Flutter/lib/Core/common/common_config.dart
0 → 100644
浏览文件 @
4326ba38
// Copyright (c) 2022 Tencent. All rights reserved.
part of
SuperPlayer
;
abstract
class
FPlayerPckInfo
{
static
const
String
PLAYER_VERSION
=
"11.1.1"
;
}
\ No newline at end of file
Flutter/lib/Core/txvodplayer_controller.dart
浏览文件 @
4326ba38
...
...
@@ -141,6 +141,7 @@ class TXVodPlayerController extends ChangeNotifier implements ValueListenable<TX
void
printVersionInfo
()
async
{
LogUtils
.
d
(
kTag
,
"dart SDK version:
${Platform.version}
"
);
LogUtils
.
d
(
kTag
,
"liteAV SDK version:
${await SuperPlayerPlugin.platformVersion}
"
);
LogUtils
.
d
(
kTag
,
"superPlayer SDK version:
${FPlayerPckInfo.PLAYER_VERSION}
"
);
}
/// 通过url开始播放视频
...
...
Flutter/lib/super_player.dart
浏览文件 @
4326ba38
...
...
@@ -24,4 +24,5 @@ part 'Core/txvoddownload_controller.dart';
part
'Core/txliveplayer_config.dart'
;
part
'Core/tools/common_utils.dart'
;
part
'Core/provider/txplayer_holder.dart'
;
part
'Core/txplayer_messages.dart'
;
\ No newline at end of file
part
'Core/txplayer_messages.dart'
;
part
'Core/common/common_config.dart'
;
\ No newline at end of file
Flutter/pubspec.yaml
浏览文件 @
4326ba38
...
...
@@ -5,8 +5,8 @@ author:
homepage
:
environment
:
sdk
:
'
>=2.1
2.0
<3
.0.0'
flutter
:
"
>=
2
.0.0"
sdk
:
'
>=2.1
7.0
<4
.0.0'
flutter
:
"
>=
3
.0.0"
dependencies
:
flutter
:
...
...
Flutter/superplayer_widget/pubspec.yaml
浏览文件 @
4326ba38
...
...
@@ -3,14 +3,14 @@ description: superplayer,base on vodplayer
version
:
"
11.1.1"
environment
:
sdk
:
'
>=2.1
2.0
<3
.0.0'
flutter
:
"
>=
2
.0.0"
sdk
:
'
>=2.1
7.0
<4
.0.0'
flutter
:
"
>=
3
.0.0"
dependencies
:
flutter
:
sdk
:
flutter
flutter_easyloading
:
^3.0.
0
flutter_easyloading
:
^3.0.
5
super_player
:
# When depending on this package from a real application you should use:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论