solid-software / flutter_vlc_player

📺 Flutter VLC powered video player.
524 stars 253 forks source link

How to change .srt subtitles name? #180

Open alurei97 opened 3 years ago

alurei97 commented 3 years ago

Hello, I'm using the basic example from the repo and I'm trying to add .srt subtitles.

In single_tab.dart I have the following code to add the files (I don't know if this is the correct place to do that but it works):

        _controller = VlcPlayerController.network(
          initVideo.path,
          hwAcc: HwAcc.FULL,
          onInit: () async {
            await _controller.addSubtitleFromNetwork('<url>/english.srt');
            await _controller.addSubtitleFromNetwork('<url>/spanish.srt');

            await _controller.startRendererScanning();
          },
          onRendererHandler: (type, id, name) {
            print('onRendererHandler $type $id $name');
          },
          options: VlcPlayerOptions(
            advanced: VlcAdvancedOptions([
              VlcAdvancedOptions.networkCaching(2000),
            ]),
            rtp: VlcRtpOptions([
              VlcRtpOptions.rtpOverRtsp(true),
            ]),
          ),
        );

When the subtitle dialog is created in vlc_player_with_controls.dart, the list is:

Track 1
Track 2

But I want it to be like:

English
Spanish

I know that if subs are embedded in the movie file, the name is shown correctly because there is a example with embedded subs, but I don't know how to change the imported ones name. Any ideas?

alr2413 commented 3 years ago

might help https://forum.videolan.org/viewtopic.php?t=98342

I think, you need to write your own patch for that. You can create a list of subtitles with the url & desired name, and then add them to the vlc. i guess vlc keeps the order of added subtitles.

alurei97 commented 3 years ago

I'm working on it, I can post the code here when I finish it.

alr2413 commented 3 years ago

cool :)