wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
197 stars 31 forks source link

Is it possible to change the audio track? #109

Closed Ansh-Rathod closed 4 months ago

Ansh-Rathod commented 4 months ago

Hi! Thank you for the amazing plugin! I'm using it to build the video editor app. I'm wondering if it's possible for me to have a feature to change the audio track from the chosen mkv file using this plugin or not, i haven't found the docs on that yet but I see few references of the audio tracks.

wang-bin commented 4 months ago

If you are using fvp via video_player, then it's no, because video_player has no such api. You have to use fvp backend api.

import 'package:fvp/mdk.dart' as mdk;

...

final player = mdk.Player();
player.media = "video_file";
player.audioTracks = [1]; // the 2nd track. if does not exist(has only 1 audio track but select the 2nd track), then audio is disabled
await ret = player.prepare();
// now video is loaded, available tracks are known, you can also change the track here or later with a valid track number
final audioTracksCount = player.mediaInfo.audio.length;
Ansh-Rathod commented 4 months ago

Hey, Thank you for the quick reply and guiding me! Yes player.activeAudioTracks = [0] did work!