Skip to content

Commit

Permalink
feat: audio track (#72)
Browse files Browse the repository at this point in the history
* feat: audio track

* fix: audio track not work
  • Loading branch information
MiaoMint authored Sep 24, 2023
1 parent e5387cf commit 4e3cbd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/models/extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ class ExtensionBangumiWatch {
required this.url,
this.subtitles,
this.headers,
this.audioTrack,
});
final ExtensionWatchBangumiType type;
final String url;
final List<ExtensionBangumiWatchSubtitle>? subtitles;
late Map<String, String>? headers;
late String? audioTrack;

factory ExtensionBangumiWatch.fromJson(Map<String, dynamic> json) =>
_$ExtensionBangumiWatchFromJson(json);
Expand Down
2 changes: 2 additions & 0 deletions lib/models/extension.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/pages/watch/video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ class VideoPlayerController extends GetxController {
selectedSubtitle.value = -1;
final playUrl = playList[index.value].url;
final watchData = await runtime.watch(playUrl) as ExtensionBangumiWatch;

if (watchData.type == ExtensionWatchBangumiType.torrent) {
if (Get.find<MainController>().btServerisRunning.value == false) {
await BTServerUtils.startServer();
}

sendMessage(
Message(
Text('video.torrent-downloading'.i18n),
Expand Down Expand Up @@ -225,6 +225,9 @@ class VideoPlayerController extends GetxController {
playTorrentFile(torrentMediaFileList.first);
} else {
await player.open(Media(watchData.url, httpHeaders: watchData.headers));
if (watchData.audioTrack != null) {
await player.setAudioTrack(AudioTrack.uri(watchData.audioTrack!));
}
}
subtitles.addAll(watchData.subtitles ?? []);
} catch (e) {
Expand Down

0 comments on commit 4e3cbd8

Please sign in to comment.