Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it support subtitles ? #14

Open
megasto opened this issue Feb 8, 2021 · 4 comments
Open

is it support subtitles ? #14

megasto opened this issue Feb 8, 2021 · 4 comments

Comments

@megasto
Copy link

megasto commented Feb 8, 2021

hi, thank you @Lindsay-Needs-Sleep for handling this plugin
I'm just coming to ask if this plugin support subtitle??, trying a lot of tricks to make it work, but still nothing, the subtitle didn't show
my console log for [this.castMedia] :

"tracks":[
{
"trackId"=1,
"type":"VIDEO",
"trackContentType":null,
"trackContentId":"null",
"subtype":'null',
"name":'null',
"language":'null',
"customData":'null'
}
]

code using for

var videoUrl = 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4';
var thesub = 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt';


const englishSubtitle = new chrome.cast.media.Track(1,chrome.cast.media.TrackType.TEXT);
   englishSubtitle.trackContentId =thesub ;
   englishSubtitle.trackContentType = 'text/vtt';
   englishSubtitle.subtype = chrome.cast.media.TextTrackType.SUBTITLES;
   englishSubtitle.name = 'English';
   englishSubtitle.language = 'en-US';
   englishSubtitle.customData = null;
   var tracks = [englishSubtitle];

        var mediaInfo = new chrome.cast.media.MediaInfo(videoUrl);

         /**/ mediaInfo.tracks = tracks;
        mediaInfo.activeTrackIds = [1];
        
      
        this.isCasting = true;
        this.castSession.loadMedia(new chrome.cast.media.LoadRequest(mediaInfo), (media:any)=> {
            // You should see the video playing now!
            // Got media!
            
             this.castMedia = media;
            alert(JSON.stringify(this.castMedia, null, 2));
         
        }, function (err) {
            // Failed (check that the video works in your browser)
           // alert("Failed : check that the video works in your browser")
            alert(JSON.stringify(err, null, 2));
            this.isCasting = false;
           
        });
        
      
@Lindsay-Needs-Sleep
Copy link

This was a feature I wanted to test, but I didn't have access to any subtitle tracks (and no general knowledge about how subtitles work / how to generate / etc).

We're probably missing a small piece of code that enables them.

Have you tried on android and ios? (there's a tiny chance that one of them already has the subtitle logic.)

If not, I think this shouldn't be too hard to add.

I don't have to time to get the project to build and test right now, but if you are interested in doing it, I can provide some guidance possibly.

The first step would be confirming that your javascript works on a regular desktop chrome browser. (I'm guessing you have done that already.)

@megasto
Copy link
Author

megasto commented Feb 10, 2021

This was a feature I wanted to test, but I didn't have access to any subtitle tracks (and no general knowledge about how subtitles work / how to generate / etc).

We're probably missing a small piece of code that enables them.

at first, I have doubted this issue may be related to CORS but i think it's excluded now :)

Have you tried on android and ios? (there's a tiny chance that one of them already has the subtitle logic.)

I'm currently on android using ionic framework, did you have any other logic can help??

I don't have to time to get the project to build and test right now, but if you are interested in doing it, I can provide some guidance possibly.

The first step would be confirming that your javascript works on a regular desktop chrome browser. (I'm guessing you have done that already.)

I'm really intersting to figure out this issue but i'm not have a large experience for something like that due to my limitation

anaway just let me know what do as possible as i can :)

@pdille
Copy link

pdille commented Jan 2, 2022

@megasto If you are still looking for this feature (or for any other folks that may come along) I implemented this for Android builds in my forked version of this plugin. https://github.com/pdille/cordova-plugin-chromecast

While it could be refactored slightly, it works for my needs and anyone else is welcome to use it.

@ivancduran
Copy link

Thank you @pdille you are my hero,
I'm using your fork and its working fine for me on Android,
Can you implement the same fix for iOS please ?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants