feat: 简易后台播放
This commit is contained in:
@ -60,6 +60,12 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
setKey: SettingBoxKey.autoPlayEnable,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '后台播放',
|
||||
subTitle: '进入后台时继续播放',
|
||||
setKey: SettingBoxKey.enableBackgroundPlay,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '自动全屏',
|
||||
subTitle: '视频开始播放时进入全屏',
|
||||
|
@ -353,14 +353,14 @@ class PlPlayerController {
|
||||
var pp = player.platform as NativePlayer;
|
||||
|
||||
// 音轨
|
||||
if (dataSource.audioSource != '' && dataSource.audioSource != null) {
|
||||
await pp.setProperty(
|
||||
'audio-files',
|
||||
UniversalPlatform.isWindows
|
||||
? dataSource.audioSource!.replaceAll(';', '\\;')
|
||||
: dataSource.audioSource!.replaceAll(':', '\\:'),
|
||||
);
|
||||
}
|
||||
// if (dataSource.audioSource != '' && dataSource.audioSource != null) {
|
||||
// await pp.setProperty(
|
||||
// 'audio-files',
|
||||
// UniversalPlatform.isWindows
|
||||
// ? dataSource.audioSource!.replaceAll(';', '\\;')
|
||||
// : dataSource.audioSource!.replaceAll(':', '\\:'),
|
||||
// );
|
||||
// }
|
||||
|
||||
// 字幕
|
||||
if (dataSource.subFiles != '' && dataSource.subFiles != null) {
|
||||
@ -393,21 +393,15 @@ class PlPlayerController {
|
||||
Media(assetUrl, httpHeaders: dataSource.httpHeaders),
|
||||
play: false,
|
||||
);
|
||||
} else if (dataSource.type == DataSourceType.network) {
|
||||
player.open(
|
||||
Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders),
|
||||
play: false,
|
||||
);
|
||||
// 音轨
|
||||
// player.setAudioTrack(
|
||||
// AudioTrack.uri(dataSource.audioSource!),
|
||||
// );
|
||||
} else {
|
||||
player.open(
|
||||
Media(dataSource.file!.path, httpHeaders: dataSource.httpHeaders),
|
||||
play: false,
|
||||
);
|
||||
}
|
||||
player.open(
|
||||
Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders),
|
||||
play: false,
|
||||
);
|
||||
// 音轨
|
||||
player.setAudioTrack(
|
||||
AudioTrack.uri(dataSource.audioSource!),
|
||||
);
|
||||
|
||||
return player;
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
late FullScreenMode mode;
|
||||
late int defaultBtmProgressBehavior;
|
||||
late bool enableQuickDouble;
|
||||
late bool enableBackgroundPlay;
|
||||
|
||||
void onDoubleTapSeekBackward() {
|
||||
setState(() {
|
||||
@ -128,6 +129,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
defaultValue: BtmProgresBehavior.values.first.code);
|
||||
enableQuickDouble =
|
||||
setting.get(SettingBoxKey.enableQuickDouble, defaultValue: true);
|
||||
enableBackgroundPlay =
|
||||
setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: false);
|
||||
|
||||
Future.microtask(() async {
|
||||
try {
|
||||
@ -228,6 +231,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
() => Video(
|
||||
controller: videoController,
|
||||
controls: NoVideoControls,
|
||||
pauseUponEnteringBackgroundMode: !enableBackgroundPlay,
|
||||
subtitleViewConfiguration: SubtitleViewConfiguration(
|
||||
style: subTitleStyle,
|
||||
textAlign: TextAlign.center,
|
||||
|
@ -107,6 +107,7 @@ class SettingBoxKey {
|
||||
// youtube 双击快进快退
|
||||
static const String enableQuickDouble = 'enableQuickDouble';
|
||||
static const String enableShowDanmaku = 'enableShowDanmaku';
|
||||
static const String enableBackgroundPlay = 'enableBackgroundPlay';
|
||||
|
||||
/// 隐私
|
||||
static const String blackMidsList = 'blackMidsList';
|
||||
|
Reference in New Issue
Block a user