Compare commits

...

5 Commits

Author SHA1 Message Date
b689db16b5 Merge branch 'main' into feature-media_kit 2024-03-30 17:13:09 +08:00
76784ee664 mod: seekTo 2024-03-19 23:33:32 +08:00
2dbef3fee2 mod: media_kit引入 2024-03-19 23:23:14 +08:00
3a66c8c03d Merge branch 'main' into feature-media_kit 2024-03-19 23:15:06 +08:00
6f62837495 mod: media_kit依赖 2024-02-02 23:12:04 +08:00
3 changed files with 43 additions and 28 deletions

View File

@ -393,7 +393,13 @@ class PlPlayerController {
}
// 配置Player 音轨、字幕等等
_videoPlayerController = await _createVideoController(
dataSource, _looping, enableHA, width, height);
dataSource,
_looping,
enableHA,
width,
height,
seekTo,
);
// 获取视频时长 00:00
_duration.value = duration ?? _videoPlayerController!.state.duration;
updateDurationSecond();
@ -404,7 +410,7 @@ class PlPlayerController {
if (!_listenersInitialized) {
startListeners();
}
await _initializePlayer(seekTo: seekTo, duration: _duration.value);
await _initializePlayer(duration: _duration.value);
bool autoEnterFullcreen =
setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
if (autoEnterFullcreen && _isFirstTime) {
@ -424,6 +430,7 @@ class PlPlayerController {
bool enableHA,
double? width,
double? height,
Duration? seekTo,
) async {
// 每次配置时先移除监听
removeListeners();
@ -506,7 +513,11 @@ class PlPlayerController {
);
}
player.open(
Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders),
Media(
dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders,
start: seekTo ?? Duration.zero,
),
play: false,
);
// 音轨
@ -519,7 +530,6 @@ class PlPlayerController {
// 开始播放
Future _initializePlayer({
Duration seekTo = Duration.zero,
Duration? duration,
}) async {
// 设置倍速
@ -537,11 +547,6 @@ class PlPlayerController {
// await setLooping(_looping);
// }
// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
// 自动播放
if (_autoPlay) {
await play(duration: duration);
@ -661,21 +666,14 @@ class PlPlayerController {
await _videoPlayerController?.stream.buffer.first;
}
await _videoPlayerController?.seek(position);
// if (playerStatus.stopped) {
// play();
// }
} else {
print('seek duration else');
_timerForSeek?.cancel();
_timerForSeek =
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
//_timerForSeek = null;
if (duration.value.inSeconds != 0) {
await _videoPlayerController!.stream.buffer.first;
await _videoPlayerController?.seek(position);
// if (playerStatus.status.value == PlayerStatus.paused) {
// play();
// }
t.cancel();
_timerForSeek = null;
}

View File

@ -865,10 +865,11 @@ packages:
media_kit:
dependency: "direct main"
description:
name: media_kit
sha256: "3289062540e3b8b9746e5c50d95bd78a9289826b7227e253dff806d002b9e67a"
url: "https://pub.flutter-io.cn"
source: hosted
path: media_kit
ref: HEAD
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.1.10+1"
media_kit_libs_android_video:
dependency: transitive
@ -905,10 +906,11 @@ packages:
media_kit_libs_video:
dependency: "direct main"
description:
name: media_kit_libs_video
sha256: "3688e0c31482074578652bf038ce6301a5d21e1eda6b54fc3117ffeb4bdba067"
url: "https://pub.flutter-io.cn"
source: hosted
path: "libs/universal/media_kit_libs_video"
ref: HEAD
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.0.4"
media_kit_libs_windows_video:
dependency: transitive
@ -929,10 +931,11 @@ packages:
media_kit_video:
dependency: "direct main"
description:
name: media_kit_video
sha256: c048d11a19e379aebbe810647636e3fc6d18374637e2ae12def4ff8a4b99a882
url: "https://pub.flutter-io.cn"
source: hosted
path: media_kit_video
ref: HEAD
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.2.4"
meta:
dependency: transitive

View File

@ -163,6 +163,20 @@ dev_dependencies:
hive_generator: ^2.0.0
build_runner: ^2.4.8
dependency_overrides:
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
path: libs/universal/media_kit_libs_video
flutter_launcher_icons:
android: true
ios: true