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

How to display a side loaded text track by default when using chromecast? #3370

Closed
sonicd300 opened this issue Apr 26, 2021 · 2 comments
Closed
Labels
platform: Cast Issues affecting Cast devices priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: bug Something isn't working correctly

Comments

@sonicd300
Copy link

Have you read the Tutorials?
yes

Have you read the FAQ and checked for duplicate open issues?
yes

What version of Shaka Player are you using?
3.0.10

Please ask your question
I have side loaded text tracks which load/render properly during playback in a browser, but these aren't showing up by default when casting, instead it's turning the caption selector to its off state, if i manually select a track then gets displayed.

The text tracks are being loaded after the player had fired the loaded event, using addTextTrackAsync and awaiting that promise (side note: sometimes even if it's awaited it doesn't return the track), then selected and its visibility set to true.

Is there anything in particular that needs to happen to display side loaded text tracks by default when casting?

@sonicd300 sonicd300 added the type: question A question from the community label Apr 26, 2021
@joeyparrish joeyparrish added type: bug Something isn't working correctly priority: P2 Smaller impact or easy workaround and removed type: question A question from the community labels Oct 6, 2021
@shaka-bot shaka-bot added this to the v3.3 milestone Oct 6, 2021
@joeyparrish
Copy link
Member

That makes sense. The way the current Cast API works, it transmits the manifest URL to the device, where playback then starts and seeks to the same position. The way addTextTrackAsync works is by inserting a synthetic track to the parsed manifest. This is not transmitted to the Cast device when you start casting.

It's reasonable for you to expect this to work, though. We should find a way to fix this. I'm going to reclassify this as a bug.

As for a fix, here's one suggestion: We could potentially track metadata about side-loaded tracks in the player, separately from the manifest, and transmit this to the Cast device when we start casting. I don't have any other ideas off-hand.

For now, though, you can work around this in the receiver by calling addTextTrackAsync again on the cast side. For example:

// Sender side code.

// If using our UI, this gets you the CastProxy object.
// If you're not using our UI, you created this object yourself.
const castProxy = video.ui.getControls().getCastProxy();

// Set "app data" for the asset.  This can be anything you can serialize over JSON.
// In this example, I'm sending most of the params of addTextTrackAsync.
// You can choose what you send, though.  Always use VTT?
// Hard-code the MIME type in your receiver if you like instead of sending it.
castProxy.setAppData({
  sideLoadedText: {
    uri: 'foo',
    language: 'es',
    kind: 'subtitle',
    mimeType: 'text/vtt',
  },
});
// Receiver-side code.
// Use the app data callback to get the data from the sender app.
const receiver = new shaka.cast.CastReceiver(
    video, player, (appData) => {
      if (appData.sideLoadedText) {
        // Use the app data to side-load the text track on the receiver side.
        player.addTextTrackAsync(
            appData.sideLoadedText.uri,
            appData.sideLoadedText.language,
            appData.sideLoadedText.kind,
            appData.sideLoadedText.mimeType);
      }
    });

@avelad avelad modified the milestones: v3.3, v4.1 May 4, 2022
@avelad avelad added the platform: Cast Issues affecting Cast devices label May 17, 2022
@avelad avelad modified the milestones: v4.1, v4.2 Jun 3, 2022
@avelad avelad modified the milestones: v4.2, v4.3 Aug 17, 2022
@avelad avelad modified the milestones: v4.3, v4.4 Nov 11, 2022
@avelad avelad modified the milestones: v4.4, v4.5 Aug 31, 2023
@avelad avelad modified the milestones: v4.5, v4.6 Oct 5, 2023
@avelad avelad modified the milestones: v4.6, v5.0 Nov 16, 2023
@avelad avelad modified the milestones: v4.7, v5.0 Dec 4, 2023
@avelad
Copy link
Member

avelad commented Dec 4, 2023

Since we want to do #4214 I'm going to close this issue.

@avelad avelad closed this as completed Dec 4, 2023
@avelad avelad removed this from the v5.0 milestone Dec 4, 2023
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Feb 2, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: Cast Issues affecting Cast devices priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants