Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.29k stars 531 forks source link

Default video subtitle #5683

Closed thumaman closed 1 month ago

thumaman commented 2 months ago

Hi, i was wondering what is the purpose of setting a subtitle value to default and what it should do.

I am dealing with devices with disabled input so i would like to play a certain subtitle at the start of the video without having to select it manually.

I tried setting an english subtitles to default value, hoping that it would display them at the start but no luck. Here is a snippet of my code where is set the default value to true if the subtitle is english:

            // add subtitles to the video

            foreach (var subtitle in subtitleFiles)
            {
                //print subtitle
                Console.WriteLine(subtitle);
                var subtitlePath = subtitle;
                var file = subtitlePath.Split('/').Last();
                var lang = file.Split('.').Skip(1).First();
                var label = lang.ToUpper();
                bool def = lang == "en";
                newVideoSource.Tracks.Add(new VideoTrack(subtitlePath)
                    {
                        Kind = "subtitles",
                        Label = file,
                        Source = subtitlePath,
                        Language = lang,
                        Default = def
                    });

Am I missing something, or what could be the issue?

Thank you for your help.

stsrki commented 2 months ago

The purpose of default is to define the track that will show immediately when the video starts. See here https://www.vidstack.io/docs/player/core-concepts/loading#text-track-default

thumaman commented 2 months ago

I found the issue on my part, but still when i change the video and set a different subtitle to default they are not displayed (so the default option only works on the first video). I have to look into it.

thumaman commented 2 months ago

I also noticed that .srt subtitles do not work, is there an issue on my end? I tried several different files but no luck.

stsrki commented 2 months ago

It should work. https://www.vidstack.io/docs/player/core-concepts/loading#text-track-formats

Did you define a track type?

thumaman commented 1 month ago

My mistake, i though it would work without defining a type, like it does for .vtt files. It works now that I defined: Type = "srt",