Skip to content

Commit 4e3cbd8

Browse files
authored
feat: audio track (#72)
* feat: audio track * fix: audio track not work
1 parent e5387cf commit 4e3cbd8

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/models/extension.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ class ExtensionBangumiWatch {
153153
required this.url,
154154
this.subtitles,
155155
this.headers,
156+
this.audioTrack,
156157
});
157158
final ExtensionWatchBangumiType type;
158159
final String url;
159160
final List<ExtensionBangumiWatchSubtitle>? subtitles;
160161
late Map<String, String>? headers;
162+
late String? audioTrack;
161163

162164
factory ExtensionBangumiWatch.fromJson(Map<String, dynamic> json) =>
163165
_$ExtensionBangumiWatchFromJson(json);

lib/models/extension.g.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/pages/watch/video_controller.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ class VideoPlayerController extends GetxController {
187187
selectedSubtitle.value = -1;
188188
final playUrl = playList[index.value].url;
189189
final watchData = await runtime.watch(playUrl) as ExtensionBangumiWatch;
190+
190191
if (watchData.type == ExtensionWatchBangumiType.torrent) {
191192
if (Get.find<MainController>().btServerisRunning.value == false) {
192193
await BTServerUtils.startServer();
193194
}
194-
195195
sendMessage(
196196
Message(
197197
Text('video.torrent-downloading'.i18n),
@@ -225,6 +225,9 @@ class VideoPlayerController extends GetxController {
225225
playTorrentFile(torrentMediaFileList.first);
226226
} else {
227227
await player.open(Media(watchData.url, httpHeaders: watchData.headers));
228+
if (watchData.audioTrack != null) {
229+
await player.setAudioTrack(AudioTrack.uri(watchData.audioTrack!));
230+
}
228231
}
229232
subtitles.addAll(watchData.subtitles ?? []);
230233
} catch (e) {

0 commit comments

Comments
 (0)