Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
tx_player_fork
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
tx_player_fork
Commits
b6a9e14f
提交
b6a9e14f
authored
1月 31, 2023
作者:
kongdywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix brightness performance & add brightness change event
上级
1d584a00
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
210 行增加
和
101 行删除
+210
-101
FTXEvent.java
...droid/src/main/java/com/tencent/vod/flutter/FTXEvent.java
+30
-25
SuperPlayerPlugin.java
.../main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
+114
-54
FTXEvent.h
Flutter/ios/Classes/FTXEvent.h
+3
-1
SuperPlayerPlugin.m
Flutter/ios/Classes/SuperPlayerPlugin.m
+12
-0
txplayer_define.dart
Flutter/lib/Core/txplayer_define.dart
+2
-1
superplayer_more_view.dart
Flutter/superplayer_widget/lib/ui/superplayer_more_view.dart
+41
-14
superplayer_title_view.dart
...ter/superplayer_widget/lib/ui/superplayer_title_view.dart
+8
-6
没有找到文件。
Flutter/android/src/main/java/com/tencent/vod/flutter/FTXEvent.java
浏览文件 @
b6a9e14f
...
@@ -6,10 +6,11 @@ package com.tencent.vod.flutter;
...
@@ -6,10 +6,11 @@ package com.tencent.vod.flutter;
* 通用事件码
* 通用事件码
*/
*/
public
class
FTXEvent
{
public
class
FTXEvent
{
/*
/*
音量变化
音量变化
*/
*/
public
static
final
int
EVENT_VOLUME_CHANGED
=
1
;
public
static
final
int
EVENT_VOLUME_CHANGED
=
1
;
/*
/*
失去音量输出播放焦点
失去音量输出播放焦点
*/
*/
...
@@ -17,7 +18,11 @@ public class FTXEvent {
...
@@ -17,7 +18,11 @@ public class FTXEvent {
/*
/*
获得音量输出焦点
获得音量输出焦点
*/
*/
public
static
final
int
EVENT_AUDIO_FOCUS_PLAY
=
3
;
public
static
final
int
EVENT_AUDIO_FOCUS_PLAY
=
3
;
/*
亮度发生变化
*/
public
static
final
int
EVENT_BRIGHTNESS_CHANGED
=
4
;
// 视频预下载完成
// 视频预下载完成
public
static
final
int
EVENT_PREDOWNLOAD_ON_COMPLETE
=
200
;
public
static
final
int
EVENT_PREDOWNLOAD_ON_COMPLETE
=
200
;
...
@@ -26,55 +31,55 @@ public class FTXEvent {
...
@@ -26,55 +31,55 @@ public class FTXEvent {
public
static
final
int
EVENT_PREDOWNLOAD_ON_ERROR
=
201
;
public
static
final
int
EVENT_PREDOWNLOAD_ON_ERROR
=
201
;
// 视频下载开始
// 视频下载开始
public
static
final
int
EVENT_DOWNLOAD_START
=
301
;
public
static
final
int
EVENT_DOWNLOAD_START
=
301
;
// 视频下载进度
// 视频下载进度
public
static
final
int
EVENT_DOWNLOAD_PROGRESS
=
302
;
public
static
final
int
EVENT_DOWNLOAD_PROGRESS
=
302
;
// 视频下载停止
// 视频下载停止
public
static
final
int
EVENT_DOWNLOAD_STOP
=
303
;
public
static
final
int
EVENT_DOWNLOAD_STOP
=
303
;
// 视频下载完成
// 视频下载完成
public
static
final
int
EVENT_DOWNLOAD_FINISH
=
304
;
public
static
final
int
EVENT_DOWNLOAD_FINISH
=
304
;
// 视频下载错误
// 视频下载错误
public
static
final
int
EVENT_DOWNLOAD_ERROR
=
305
;
public
static
final
int
EVENT_DOWNLOAD_ERROR
=
305
;
public
static
final
int
NO_ERROR
=
0
;
public
static
final
int
NO_ERROR
=
0
;
/**
/**
* pip 事件
* pip 事件
*/
*/
public
static
final
String
PIP_CHANNEL_NAME
=
"cloud.tencent.com/playerPlugin/componentEvent"
;
public
static
final
String
PIP_CHANNEL_NAME
=
"cloud.tencent.com/playerPlugin/componentEvent"
;
// pip广播action
// pip广播action
public
static
final
String
ACTION_PIP_PLAY_CONTROL
=
"vodPlayControl"
;
public
static
final
String
ACTION_PIP_PLAY_CONTROL
=
"vodPlayControl"
;
// pip 操作
// pip 操作
public
static
final
String
EXTRA_NAME_PLAY_OP
=
"vodPlayOp"
;
public
static
final
String
EXTRA_NAME_PLAY_OP
=
"vodPlayOp"
;
// pip需要操作的播放器
// pip需要操作的播放器
public
static
final
String
EXTRA_NAME_PLAYER_ID
=
"vodPlayerId"
;
public
static
final
String
EXTRA_NAME_PLAYER_ID
=
"vodPlayerId"
;
// 进度回退
// 进度回退
public
static
final
int
EXTRA_PIP_PLAY_BACK
=
101
;
public
static
final
int
EXTRA_PIP_PLAY_BACK
=
101
;
// 继续/暂停
// 继续/暂停
public
static
final
int
EXTRA_PIP_PLAY_RESUME_OR_PAUSE
=
102
;
public
static
final
int
EXTRA_PIP_PLAY_RESUME_OR_PAUSE
=
102
;
// 进度前进
// 进度前进
public
static
final
int
EXTRA_PIP_PLAY_FORWARD
=
103
;
public
static
final
int
EXTRA_PIP_PLAY_FORWARD
=
103
;
// pip 错误,android版本过低
// pip 错误,android版本过低
public
static
final
int
ERROR_PIP_LOWER_VERSION
=
-
101
;
public
static
final
int
ERROR_PIP_LOWER_VERSION
=
-
101
;
// pip 错误,画中画权限关闭/设备不支持画中画
// pip 错误,画中画权限关闭/设备不支持画中画
public
static
final
int
ERROR_PIP_DENIED_PERMISSION
=
-
102
;
public
static
final
int
ERROR_PIP_DENIED_PERMISSION
=
-
102
;
// pip 错误,当前界面已销毁
// pip 错误,当前界面已销毁
public
static
final
int
ERROR_PIP_ACTIVITY_DESTROYED
=
-
103
;
public
static
final
int
ERROR_PIP_ACTIVITY_DESTROYED
=
-
103
;
// 来自画中画容器的事件,广播键值
// 来自画中画容器的事件,广播键值
public
static
final
String
EVENT_PIP_ACTION
=
"com.tencent.flutter.pipevent"
;
public
static
final
String
EVENT_PIP_ACTION
=
"com.tencent.flutter.pipevent"
;
// 来自画中画容器的事件,事件键值
// 来自画中画容器的事件,事件键值
public
static
final
String
EVENT_PIP_MODE_NAME
=
"pipEventName"
;
public
static
final
String
EVENT_PIP_MODE_NAME
=
"pipEventName"
;
// 画中画当前播放时间
// 画中画当前播放时间
public
static
final
String
EVENT_PIP_PLAY_TIME
=
"playTime"
;
public
static
final
String
EVENT_PIP_PLAY_TIME
=
"playTime"
;
// 来自画中画容器的事件,已经进入画中画
// 来自画中画容器的事件,已经进入画中画
public
static
final
int
EVENT_PIP_MODE_ALREADY_ENTER
=
1
;
public
static
final
int
EVENT_PIP_MODE_ALREADY_ENTER
=
1
;
// 来自画中画容器的事件,已经退出画中画
// 来自画中画容器的事件,已经退出画中画
public
static
final
int
EVENT_PIP_MODE_ALREADY_EXIT
=
2
;
public
static
final
int
EVENT_PIP_MODE_ALREADY_EXIT
=
2
;
// 来自画中画容器的事件,开始进入画中画
// 来自画中画容器的事件,开始进入画中画
public
static
final
int
EVENT_PIP_MODE_REQUEST_START
=
3
;
public
static
final
int
EVENT_PIP_MODE_REQUEST_START
=
3
;
// 来自画中画容器的事件,画中画UI发生变动,> android 31
// 来自画中画容器的事件,画中画UI发生变动,> android 31
public
static
final
int
EVENT_PIP_MODE_UI_STATE_CHANGED
=
4
;
public
static
final
int
EVENT_PIP_MODE_UI_STATE_CHANGED
=
4
;
// 画中画界面恢复,即点击放大按钮
// 画中画界面恢复,即点击放大按钮
public
static
final
int
EVENT_PIP_MODE_RESTORE_UI
=
5
;
public
static
final
int
EVENT_PIP_MODE_RESTORE_UI
=
5
;
// 启动画中画
// 启动画中画
public
static
final
String
PIP_ACTION_START
=
"com.tencent.flutter.startPip"
;
public
static
final
String
PIP_ACTION_START
=
"com.tencent.flutter.startPip"
;
...
...
Flutter/android/src/main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java
浏览文件 @
b6a9e14f
...
@@ -3,12 +3,18 @@
...
@@ -3,12 +3,18 @@
package
com
.
tencent
.
vod
.
flutter
;
package
com
.
tencent
.
vod
.
flutter
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
android.database.ContentObserver
;
import
android.media.AudioManager
;
import
android.media.AudioManager
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.provider.Settings
;
import
android.provider.Settings
;
import
android.provider.Settings.SettingNotFoundException
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.SparseArray
;
import
android.util.SparseArray
;
...
@@ -28,6 +34,8 @@ import io.flutter.plugin.common.MethodChannel;
...
@@ -28,6 +34,8 @@ import io.flutter.plugin.common.MethodChannel;
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
;
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
;
import
io.flutter.plugin.common.MethodChannel.Result
;
import
io.flutter.plugin.common.MethodChannel.Result
;
import
java.io.File
;
import
java.io.File
;
import
java.math.BigDecimal
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -42,26 +50,25 @@ import java.util.Set;
...
@@ -42,26 +50,25 @@ import java.util.Set;
*/
*/
public
class
SuperPlayerPlugin
implements
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
{
public
class
SuperPlayerPlugin
implements
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
{
static
final
String
TAG
=
"SuperPlayerPlugin"
;
static
final
String
TAG
=
"SuperPlayerPlugin"
;
private
static
final
String
VOLUME_CHANGED_ACTION
=
"android.media.VOLUME_CHANGED_ACTION"
;
private
static
final
String
VOLUME_CHANGED_ACTION
=
"android.media.VOLUME_CHANGED_ACTION"
;
private
static
final
String
EXTRA_VOLUME_STREAM_TYPE
=
"android.media.EXTRA_VOLUME_STREAM_TYPE"
;
private
static
final
String
EXTRA_VOLUME_STREAM_TYPE
=
"android.media.EXTRA_VOLUME_STREAM_TYPE"
;
private
EventChannel
mEventChannel
;
private
EventChannel
mEventChannel
;
private
FTXPlayerEventSink
mEventSink
=
new
FTXPlayerEventSink
();
private
FTXPlayerEventSink
mEventSink
=
new
FTXPlayerEventSink
();
private
VolumeBroadcastReceiver
mVolumeBroadcastReceiver
;
private
VolumeBroadcastReceiver
mVolumeBroadcastReceiver
;
private
MethodChannel
channel
;
private
MethodChannel
channel
;
private
FlutterPluginBinding
mFlutterPluginBinding
;
private
FlutterPluginBinding
mFlutterPluginBinding
;
private
ActivityPluginBinding
mActivityPluginBinding
;
private
ActivityPluginBinding
mActivityPluginBinding
;
private
SparseArray
<
FTXBasePlayer
>
mPlayers
;
private
SparseArray
<
FTXBasePlayer
>
mPlayers
;
private
FTXDownloadManager
mFTXDownloadManager
;
private
FTXDownloadManager
mFTXDownloadManager
;
private
FTXAudioManager
mTxAudioManager
;
private
FTXAudioManager
mTxAudioManager
;
private
FTXPIPManager
mTxPipManager
;
private
FTXPIPManager
mTxPipManager
;
private
OrientationEventListener
mOrientationManager
;
private
OrientationEventListener
mOrientationManager
;
private
int
mCurrentOrientation
=
FTXEvent
.
ORIENTATION_PORTRAIT_UP
;
private
int
mCurrentOrientation
=
FTXEvent
.
ORIENTATION_PORTRAIT_UP
;
private
final
FTXAudioManager
.
AudioFocusChangeListener
audioFocusChangeListener
=
private
final
FTXAudioManager
.
AudioFocusChangeListener
audioFocusChangeListener
=
new
FTXAudioManager
.
AudioFocusChangeListener
()
{
new
FTXAudioManager
.
AudioFocusChangeListener
()
{
...
@@ -76,6 +83,15 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -76,6 +83,15 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
}
}
};
};
private
final
ContentObserver
brightnessObserver
=
new
ContentObserver
(
new
Handler
(
Looper
.
getMainLooper
()))
{
@Override
public
void
onChange
(
boolean
selfChange
,
@NonNull
Collection
<
Uri
>
uris
,
int
flags
)
{
super
.
onChange
(
selfChange
,
uris
,
flags
);
double
systemBrightness
=
getSystemScreenBrightness
();
setBrightness
(
systemBrightness
);
}
};
@Override
@Override
public
void
onAttachedToEngine
(
@NonNull
FlutterPluginBinding
flutterPluginBinding
)
{
public
void
onAttachedToEngine
(
@NonNull
FlutterPluginBinding
flutterPluginBinding
)
{
mFlutterPluginBinding
=
flutterPluginBinding
;
mFlutterPluginBinding
=
flutterPluginBinding
;
...
@@ -150,23 +166,11 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -150,23 +166,11 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
result
.
success
(
null
);
result
.
success
(
null
);
}
else
if
(
call
.
method
.
equals
(
"setBrightness"
))
{
}
else
if
(
call
.
method
.
equals
(
"setBrightness"
))
{
Double
brightness
=
call
.
argument
(
"brightness"
);
Double
brightness
=
call
.
argument
(
"brightness"
);
if
(
null
!=
brightness
)
{
setBrightness
(
brightness
);
Window
window
=
mActivityPluginBinding
.
getActivity
().
getWindow
();
WindowManager
.
LayoutParams
params
=
window
.
getAttributes
();
params
.
screenBrightness
=
Float
.
parseFloat
(
String
.
valueOf
(
brightness
));
if
(
params
.
screenBrightness
>
1.0f
)
{
params
.
screenBrightness
=
1.0f
;
}
if
(
params
.
screenBrightness
!=
-
1
&&
params
.
screenBrightness
<
0
)
{
params
.
screenBrightness
=
0.01f
;
}
window
.
setAttributes
(
params
);
}
result
.
success
(
null
);
result
.
success
(
null
);
}
else
if
(
call
.
method
.
equals
(
"getBrightness"
))
{
}
else
if
(
call
.
method
.
equals
(
"getBrightness"
))
{
Window
window
=
mActivityPluginBinding
.
getActivity
().
getWindow
();
float
screenBrightness
=
getBrightness
();
WindowManager
.
LayoutParams
params
=
window
.
getAttributes
();
result
.
success
(
screenBrightness
);
result
.
success
(
params
.
screenBrightness
);
}
else
if
(
call
.
method
.
equals
(
"getSystemVolume"
))
{
}
else
if
(
call
.
method
.
equals
(
"getSystemVolume"
))
{
result
.
success
(
mTxAudioManager
.
getSystemCurrentVolume
());
result
.
success
(
mTxAudioManager
.
getSystemCurrentVolume
());
}
else
if
(
call
.
method
.
equals
(
"setSystemVolume"
))
{
}
else
if
(
call
.
method
.
equals
(
"setSystemVolume"
))
{
...
@@ -205,39 +209,90 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -205,39 +209,90 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
}
}
if
(
null
==
mOrientationManager
)
{
if
(
null
==
mOrientationManager
)
{
try
{
try
{
mOrientationManager
=
new
OrientationEventListener
(
mFlutterPluginBinding
.
getApplicationContext
())
{
mOrientationManager
=
new
OrientationEventListener
(
mFlutterPluginBinding
.
getApplicationContext
())
{
@Override
@Override
public
void
onOrientationChanged
(
int
orientation
)
{
public
void
onOrientationChanged
(
int
orientation
)
{
if
(
isAutoRotateOn
())
{
if
(
isAutoRotateOn
())
{
int
orientationEvent
=
mCurrentOrientation
;
int
orientationEvent
=
mCurrentOrientation
;
// 每个方向判断当前方向正负30度,共计60度的区间
// 每个方向判断当前方向正负30度,共计60度的区间
if
(((
orientation
>=
0
)
&&
(
orientation
<
30
))
||
(
orientation
>
330
))
{
if
(((
orientation
>=
0
)
&&
(
orientation
<
30
))
||
(
orientation
>
330
))
{
orientationEvent
=
FTXEvent
.
ORIENTATION_PORTRAIT_UP
;
orientationEvent
=
FTXEvent
.
ORIENTATION_PORTRAIT_UP
;
}
else
if
(
orientation
>
240
&&
orientation
<
300
)
{
}
else
if
(
orientation
>
240
&&
orientation
<
300
)
{
orientationEvent
=
FTXEvent
.
ORIENTATION_LANDSCAPE_RIGHT
;
orientationEvent
=
FTXEvent
.
ORIENTATION_LANDSCAPE_RIGHT
;
}
else
if
(
orientation
>
150
&&
orientation
<
210
)
{
}
else
if
(
orientation
>
150
&&
orientation
<
210
)
{
orientationEvent
=
FTXEvent
.
ORIENTATION_PORTRAIT_DOWN
;
orientationEvent
=
FTXEvent
.
ORIENTATION_PORTRAIT_DOWN
;
}
else
if
(
orientation
>
60
&&
orientation
<
110
)
{
}
else
if
(
orientation
>
60
&&
orientation
<
110
)
{
orientationEvent
=
FTXEvent
.
ORIENTATION_LANDSCAPE_LEFT
;
orientationEvent
=
FTXEvent
.
ORIENTATION_LANDSCAPE_LEFT
;
}
}
if
(
orientationEvent
!=
mCurrentOrientation
)
{
if
(
orientationEvent
!=
mCurrentOrientation
)
{
mCurrentOrientation
=
orientationEvent
;
mCurrentOrientation
=
orientationEvent
;
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
FTXEvent
.
EXTRA_NAME_ORIENTATION
,
orientationEvent
);
bundle
.
putInt
(
FTXEvent
.
EXTRA_NAME_ORIENTATION
,
orientationEvent
);
mEventSink
.
success
(
getParams
(
FTXEvent
.
EVENT_ORIENTATION_CHANGED
,
bundle
));
mEventSink
.
success
(
getParams
(
FTXEvent
.
EVENT_ORIENTATION_CHANGED
,
bundle
));
}
}
}
}
}
}
};
};
mOrientationManager
.
enable
();
mOrientationManager
.
enable
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
getStackTraceString
(
e
);
Log
.
getStackTraceString
(
e
);
return
false
;
return
false
;
}
}
}
}
return
true
;
return
true
;
}
}
/**
* 设置当前window亮度
*/
private
void
setBrightness
(
Double
brightness
)
{
if
(
null
!=
brightness
)
{
// 保留两位小数
BigDecimal
bigDecimal
=
new
BigDecimal
(
brightness
);
brightness
=
bigDecimal
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
Window
window
=
mActivityPluginBinding
.
getActivity
().
getWindow
();
WindowManager
.
LayoutParams
params
=
window
.
getAttributes
();
params
.
screenBrightness
=
Float
.
parseFloat
(
String
.
valueOf
(
brightness
));
if
(
params
.
screenBrightness
>
1.0f
)
{
params
.
screenBrightness
=
1.0f
;
}
if
(
params
.
screenBrightness
!=
-
1
&&
params
.
screenBrightness
<
0
)
{
params
.
screenBrightness
=
0.01f
;
}
window
.
setAttributes
(
params
);
// 发送亮度变化通知
mEventSink
.
success
(
getParams
(
FTXEvent
.
EVENT_BRIGHTNESS_CHANGED
,
null
));
}
}
/**
* 获得当前window亮度,如果当前window亮度未赋值,则返回当前系统亮度
*/
private
float
getBrightness
()
{
Window
window
=
mActivityPluginBinding
.
getActivity
().
getWindow
();
WindowManager
.
LayoutParams
params
=
window
.
getAttributes
();
float
screenBrightness
=
params
.
screenBrightness
;
if
(
screenBrightness
<
0
)
{
screenBrightness
=
getSystemScreenBrightness
();
}
// 保留两位小数
BigDecimal
bigDecimal
=
new
BigDecimal
(
screenBrightness
);
bigDecimal
=
bigDecimal
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
return
bigDecimal
.
floatValue
();
}
private
float
getSystemScreenBrightness
()
{
float
screenBrightness
=
-
1
;
try
{
ContentResolver
resolver
=
mActivityPluginBinding
.
getActivity
().
getContentResolver
();
int
brightnessInt
=
Settings
.
System
.
getInt
(
resolver
,
Settings
.
System
.
SCREEN_BRIGHTNESS
);
screenBrightness
=
brightnessInt
/
255
F
;
}
catch
(
SettingNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
screenBrightness
;
}
private
void
initAudioManagerIfNeed
()
{
private
void
initAudioManagerIfNeed
()
{
if
(
null
==
mTxAudioManager
)
{
if
(
null
==
mTxAudioManager
)
{
mTxAudioManager
=
new
FTXAudioManager
(
mFlutterPluginBinding
.
getApplicationContext
());
mTxAudioManager
=
new
FTXAudioManager
(
mFlutterPluginBinding
.
getApplicationContext
());
...
@@ -323,6 +378,10 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -323,6 +378,10 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
IntentFilter
filter
=
new
IntentFilter
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
VOLUME_CHANGED_ACTION
);
filter
.
addAction
(
VOLUME_CHANGED_ACTION
);
mActivityPluginBinding
.
getActivity
().
registerReceiver
(
mVolumeBroadcastReceiver
,
filter
);
mActivityPluginBinding
.
getActivity
().
registerReceiver
(
mVolumeBroadcastReceiver
,
filter
);
// brightness observer
ContentResolver
resolver
=
mActivityPluginBinding
.
getActivity
().
getContentResolver
();
resolver
.
registerContentObserver
(
Settings
.
System
.
getUriFor
(
Settings
.
System
.
SCREEN_BRIGHTNESS
),
true
,
brightnessObserver
);
}
}
/**
/**
...
@@ -332,6 +391,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
...
@@ -332,6 +391,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, MethodCallHandler, Acti
try
{
try
{
mTxAudioManager
.
removeAudioFocusChangedListener
(
audioFocusChangeListener
);
mTxAudioManager
.
removeAudioFocusChangedListener
(
audioFocusChangeListener
);
mActivityPluginBinding
.
getActivity
().
unregisterReceiver
(
mVolumeBroadcastReceiver
);
mActivityPluginBinding
.
getActivity
().
unregisterReceiver
(
mVolumeBroadcastReceiver
);
mActivityPluginBinding
.
getActivity
().
getContentResolver
().
unregisterContentObserver
(
brightnessObserver
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
Flutter/ios/Classes/FTXEvent.h
浏览文件 @
b6a9e14f
...
@@ -2,10 +2,12 @@
...
@@ -2,10 +2,12 @@
#ifndef SUPERPLAYER_FLUTTER_IOS_CLASSES_FTXEVENT_H_
#ifndef SUPERPLAYER_FLUTTER_IOS_CLASSES_FTXEVENT_H_
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_FTXEVENT_H_
#define SUPERPLAYER_FLUTTER_IOS_CLASSES_FTXEVENT_H_
//
音频变化
事件code
// 事件code
#define EVENT_VOLUME_CHANGED 1
#define EVENT_VOLUME_CHANGED 1
#define EVENT_AUDIO_FOCUS_PAUSE 2
#define EVENT_AUDIO_FOCUS_PAUSE 2
#define EVENT_AUDIO_FOCUS_PLAY 3
#define EVENT_AUDIO_FOCUS_PLAY 3
// 音量发生变化
#define EVENT_BRIGHTNESS_CHANGED 4
// 画中画事件code
// 画中画事件code
#define EVENT_PIP_MODE_ALREADY_ENTER 1
#define EVENT_PIP_MODE_ALREADY_ENTER 1
...
...
Flutter/ios/Classes/SuperPlayerPlugin.m
浏览文件 @
b6a9e14f
...
@@ -67,6 +67,10 @@ SuperPlayerPlugin* instance;
...
@@ -67,6 +67,10 @@ SuperPlayerPlugin* instance;
[
_eventChannel
setStreamHandler
:
self
];
[
_eventChannel
setStreamHandler
:
self
];
[
_pipEventChannel
setStreamHandler
:
self
];
[
_pipEventChannel
setStreamHandler
:
self
];
// brightness event
NSNotificationCenter
*
center
=
[
NSNotificationCenter
defaultCenter
];
[
center
addObserver
:
self
selector
:
@selector
(
brightnessDidChange
:
)
name
:
UIScreenBrightnessDidChangeNotification
object
:
[
UIScreen
mainScreen
]];
[
audioManager
registerVolumeChangeListener
:
self
];
[
audioManager
registerVolumeChangeListener
:
self
];
_FTXDownloadManager
=
[[
FTXDownloadManager
alloc
]
initWithRegistrar
:
registrar
];
_FTXDownloadManager
=
[[
FTXDownloadManager
alloc
]
initWithRegistrar
:
registrar
];
// orientation
// orientation
...
@@ -215,6 +219,14 @@ SuperPlayerPlugin* instance;
...
@@ -215,6 +219,14 @@ SuperPlayerPlugin* instance;
[
audioManager
destory
:
self
];
[
audioManager
destory
:
self
];
}
}
/**
亮度变化
*/
-
(
void
)
brightnessDidChange
:
(
NSNotification
*
)
notification
{
[
_eventSink
success
:[
SuperPlayerPlugin
getParamsWithEvent
:
EVENT_BRIGHTNESS_CHANGED
withParams
:@{}]];
}
#pragma mark - FlutterStreamHandler
#pragma mark - FlutterStreamHandler
-
(
FlutterError
*
_Nullable
)
onListenWithArguments
:
(
id
_Nullable
)
arguments
-
(
FlutterError
*
_Nullable
)
onListenWithArguments
:
(
id
_Nullable
)
arguments
eventSink
:
(
FlutterEventSink
)
events
eventSink
:
(
FlutterEventSink
)
events
...
...
Flutter/lib/Core/txplayer_define.dart
浏览文件 @
b6a9e14f
...
@@ -98,10 +98,11 @@ abstract class TXVodPlayEvent {
...
@@ -98,10 +98,11 @@ abstract class TXVodPlayEvent {
static
const
EVT_IMAGESPRIT_IMAGEURL_LIST
=
"EVT_IMAGESPRIT_IMAGEURL_LIST"
;
// 雪碧图图片下载URL
static
const
EVT_IMAGESPRIT_IMAGEURL_LIST
=
"EVT_IMAGESPRIT_IMAGEURL_LIST"
;
// 雪碧图图片下载URL
static
const
EVT_DRM_TYPE
=
"EVT_DRM_TYPE"
;
// 加密类型
static
const
EVT_DRM_TYPE
=
"EVT_DRM_TYPE"
;
// 加密类型
/// superplayer plugin
volume
event
/// superplayer plugin event
static
const
EVENT_VOLUME_CHANGED
=
1
;
// 音量变化
static
const
EVENT_VOLUME_CHANGED
=
1
;
// 音量变化
static
const
EVENT_AUDIO_FOCUS_PAUSE
=
2
;
// 失去音量输出播放焦点 only for android
static
const
EVENT_AUDIO_FOCUS_PAUSE
=
2
;
// 失去音量输出播放焦点 only for android
static
const
EVENT_AUDIO_FOCUS_PLAY
=
3
;
// 获得音量输出焦点 only for android
static
const
EVENT_AUDIO_FOCUS_PLAY
=
3
;
// 获得音量输出焦点 only for android
static
const
EVENT_BRIGHTNESS_CHANGED
=
4
;
// 亮度发生变化
/// pip event
/// pip event
static
const
EVENT_PIP_MODE_ALREADY_ENTER
=
1
;
// 已经进入画中画模式
static
const
EVENT_PIP_MODE_ALREADY_ENTER
=
1
;
// 已经进入画中画模式
static
const
EVENT_PIP_MODE_ALREADY_EXIT
=
2
;
// 已经退出画中画模式
static
const
EVENT_PIP_MODE_ALREADY_EXIT
=
2
;
// 已经退出画中画模式
...
...
Flutter/superplayer_widget/lib/ui/superplayer_more_view.dart
浏览文件 @
b6a9e14f
...
@@ -3,6 +3,7 @@ part of demo_super_player_lib;
...
@@ -3,6 +3,7 @@ part of demo_super_player_lib;
typedef
BoolFunction
=
bool
Function
();
typedef
BoolFunction
=
bool
Function
();
typedef
DoubleFunction
=
double
Function
();
typedef
DoubleFunction
=
double
Function
();
/// 播放器组件更多菜单
/// 播放器组件更多菜单
class
SuperPlayerMoreView
extends
StatefulWidget
{
class
SuperPlayerMoreView
extends
StatefulWidget
{
final
MoreViewController
controller
;
final
MoreViewController
controller
;
...
@@ -21,30 +22,32 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -21,30 +22,32 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
bool
_isVodPlay
=
false
;
bool
_isVodPlay
=
false
;
String
_currentRate
=
""
;
String
_currentRate
=
""
;
Map
<
String
,
double
>
playRateStr
=
{
"1.0x"
:
1.0
,
"1.25x"
:
1.25
,
"1.5x"
:
1.5
,
"2.0x"
:
2.0
};
Map
<
String
,
double
>
playRateStr
=
{
"1.0x"
:
1.0
,
"1.25x"
:
1.25
,
"1.5x"
:
1.5
,
"2.0x"
:
2.0
};
StreamSubscription
?
volume
Subscription
;
StreamSubscription
?
event
Subscription
;
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_isVodPlay
=
widget
.
controller
.
getIsVodPlay
();
_isVodPlay
=
widget
.
controller
.
getIsVodPlay
();
double
playerPlayRate
=
widget
.
controller
.
getPlayRate
();
double
playerPlayRate
=
widget
.
controller
.
getPlayRate
();
for
(
String
rateStr
in
playRateStr
.
keys
)
{
for
(
String
rateStr
in
playRateStr
.
keys
)
{
if
(
playerPlayRate
==
playRateStr
[
rateStr
])
{
if
(
playerPlayRate
==
playRateStr
[
rateStr
])
{
_currentRate
=
rateStr
;
_currentRate
=
rateStr
;
break
;
break
;
}
}
}
}
// if not found in playRateStr,set 1.0
// if not found in playRateStr,set 1.0
if
(
_currentRate
.
isEmpty
)
{
if
(
_currentRate
.
isEmpty
)
{
_currentRate
=
playRateStr
.
keys
.
first
;
_currentRate
=
playRateStr
.
keys
.
first
;
}
}
_isOpenAccelerate
=
widget
.
controller
.
getAccelerateIsOpen
();
_isOpenAccelerate
=
widget
.
controller
.
getAccelerateIsOpen
();
// regist system volume changed event
// regist system volume changed event
volume
Subscription
=
SuperPlayerPlugin
.
instance
.
onEventBroadcast
.
listen
((
event
)
{
event
Subscription
=
SuperPlayerPlugin
.
instance
.
onEventBroadcast
.
listen
((
event
)
{
int
code
=
event
[
"event"
];
int
code
=
event
[
"event"
];
if
(
mounted
)
{
if
(
mounted
)
{
if
(
code
==
TXVodPlayEvent
.
EVENT_VOLUME_CHANGED
)
{
if
(
code
==
TXVodPlayEvent
.
EVENT_VOLUME_CHANGED
)
{
refreshVolume
();
refreshVolume
();
}
else
if
(
code
==
TXVodPlayEvent
.
EVENT_BRIGHTNESS_CHANGED
)
{
refreshBrightness
();
}
}
}
}
});
});
...
@@ -56,6 +59,15 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -56,6 +59,15 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
setState
(()
{});
setState
(()
{});
}
}
void
refreshBrightness
()
async
{
double
brightness
=
await
SuperPlayerPlugin
.
getBrightness
();
if
(
_currentBrightness
!=
brightness
)
{
setState
(()
{
_currentBrightness
=
brightness
;
});
}
}
void
_initData
()
async
{
void
_initData
()
async
{
double
tempBrightness
=
await
SuperPlayerPlugin
.
getBrightness
();
double
tempBrightness
=
await
SuperPlayerPlugin
.
getBrightness
();
if
(
tempBrightness
==
-
1
)
{
if
(
tempBrightness
==
-
1
)
{
...
@@ -129,7 +141,9 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -129,7 +141,9 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
child:
Text
(
child:
Text
(
rateStr
,
rateStr
,
textAlign:
TextAlign
.
center
,
textAlign:
TextAlign
.
center
,
style:
rateStr
==
_currentRate
?
ThemeResource
.
getCheckedLabelTextStyle
()
:
ThemeResource
.
getCommonLabelTextStyle
(),
style:
rateStr
==
_currentRate
?
ThemeResource
.
getCheckedLabelTextStyle
()
:
ThemeResource
.
getCommonLabelTextStyle
(),
),
),
),
),
));
));
...
@@ -154,7 +168,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -154,7 +168,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
textAlign:
TextAlign
.
center
,
textAlign:
TextAlign
.
center
,
style:
ThemeResource
.
getCommonLabelTextStyle
(),
style:
ThemeResource
.
getCommonLabelTextStyle
(),
),
),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_light_min.png"
,
package:
StringResource
.
PKG_NAME
)),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_light_min.png"
,
package:
StringResource
.
PKG_NAME
)),
Expanded
(
Expanded
(
child:
Theme
(
child:
Theme
(
data:
ThemeResource
.
getCommonSliderTheme
(),
data:
ThemeResource
.
getCommonSliderTheme
(),
...
@@ -165,7 +182,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -165,7 +182,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
onChanged:
_onChangeBrightness
,
onChanged:
_onChangeBrightness
,
)),
)),
),
),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_light_max.png"
,
package:
StringResource
.
PKG_NAME
)),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_light_max.png"
,
package:
StringResource
.
PKG_NAME
)),
]),
]),
);
);
}
}
...
@@ -180,7 +200,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -180,7 +200,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
textAlign:
TextAlign
.
center
,
textAlign:
TextAlign
.
center
,
style:
ThemeResource
.
getCommonLabelTextStyle
(),
style:
ThemeResource
.
getCommonLabelTextStyle
(),
),
),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_volume_min.png"
,
package:
StringResource
.
PKG_NAME
)),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_volume_min.png"
,
package:
StringResource
.
PKG_NAME
)),
Expanded
(
Expanded
(
child:
Theme
(
child:
Theme
(
data:
ThemeResource
.
getCommonSliderTheme
(),
data:
ThemeResource
.
getCommonSliderTheme
(),
...
@@ -191,7 +214,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -191,7 +214,10 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
onChanged:
_onChangeVolume
,
onChanged:
_onChangeVolume
,
)),
)),
),
),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_volume_max.png"
,
package:
StringResource
.
PKG_NAME
)),
const
Image
(
width:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_ic_volume_max.png"
,
package:
StringResource
.
PKG_NAME
)),
],
],
),
),
);
);
...
@@ -250,7 +276,7 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -250,7 +276,7 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
void
updatePlayerType
(
SuperPlayerType
playerType
)
{
void
updatePlayerType
(
SuperPlayerType
playerType
)
{
bool
isVodPlay
=
playerType
==
SuperPlayerType
.
VOD
;
bool
isVodPlay
=
playerType
==
SuperPlayerType
.
VOD
;
if
(
isVodPlay
!=
_isVodPlay
)
{
if
(
isVodPlay
!=
_isVodPlay
)
{
setState
(()
{
setState
(()
{
_isVodPlay
=
isVodPlay
;
_isVodPlay
=
isVodPlay
;
});
});
...
@@ -260,7 +286,7 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
...
@@ -260,7 +286,7 @@ class _SuperPlayerMoreViewState extends State<SuperPlayerMoreView> {
@override
@override
void
dispose
()
{
void
dispose
()
{
super
.
dispose
();
super
.
dispose
();
volume
Subscription
?.
cancel
();
event
Subscription
?.
cancel
();
}
}
}
}
...
@@ -271,5 +297,6 @@ class MoreViewController {
...
@@ -271,5 +297,6 @@ class MoreViewController {
Function
(
double
playRate
)
onChangedPlayRate
;
Function
(
double
playRate
)
onChangedPlayRate
;
BoolFunction
getIsVodPlay
;
BoolFunction
getIsVodPlay
;
MoreViewController
(
this
.
getAccelerateIsOpen
,
this
.
getPlayRate
,
this
.
siwtchAccelerate
,
this
.
onChangedPlayRate
,
this
.
getIsVodPlay
);
MoreViewController
(
this
.
getAccelerateIsOpen
,
this
.
getPlayRate
,
this
.
siwtchAccelerate
,
this
.
onChangedPlayRate
,
this
.
getIsVodPlay
);
}
}
Flutter/superplayer_widget/lib/ui/superplayer_title_view.dart
浏览文件 @
b6a9e14f
...
@@ -27,9 +27,11 @@ class _VideoTitleViewState extends State<_VideoTitleView> {
...
@@ -27,9 +27,11 @@ class _VideoTitleViewState extends State<_VideoTitleView> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
(
return
Container
(
padding:
const
EdgeInsets
.
only
(
left:
6
,
right:
6
),
padding:
const
EdgeInsets
.
only
(
left:
10
,
right:
15
),
decoration:
const
BoxDecoration
(
decoration:
const
BoxDecoration
(
image:
DecorationImage
(
image:
AssetImage
(
"images/superplayer_top_shadow.png"
,
package:
StringResource
.
PKG_NAME
),
fit:
BoxFit
.
fill
)),
image:
DecorationImage
(
image:
AssetImage
(
"images/superplayer_top_shadow.png"
,
package:
StringResource
.
PKG_NAME
),
fit:
BoxFit
.
fill
)),
child:
Row
(
child:
Row
(
children:
[
children:
[
InkWell
(
InkWell
(
...
@@ -37,7 +39,7 @@ class _VideoTitleViewState extends State<_VideoTitleView> {
...
@@ -37,7 +39,7 @@ class _VideoTitleViewState extends State<_VideoTitleView> {
child:
const
Image
(
child:
const
Image
(
width:
30
,
width:
30
,
height:
30
,
height:
30
,
image:
AssetImage
(
"images/superplayer_btn_back_play.png"
,
package:
StringResource
.
PKG_NAME
),
image:
AssetImage
(
"images/superplayer_btn_back_play.png"
,
package:
StringResource
.
PKG_NAME
),
),
),
),
),
Text
(
Text
(
...
@@ -50,9 +52,9 @@ class _VideoTitleViewState extends State<_VideoTitleView> {
...
@@ -50,9 +52,9 @@ class _VideoTitleViewState extends State<_VideoTitleView> {
child:
InkWell
(
child:
InkWell
(
onTap:
_onTapMore
,
onTap:
_onTapMore
,
child:
const
Image
(
child:
const
Image
(
width:
3
0
,
width:
4
0
,
height:
3
0
,
height:
4
0
,
image:
AssetImage
(
"images/superplayer_ic_vod_more_normal.png"
,
package:
StringResource
.
PKG_NAME
),
image:
AssetImage
(
"images/superplayer_ic_vod_more_normal.png"
,
package:
StringResource
.
PKG_NAME
),
),
),
))
))
],
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论