Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Add adapter.getPlayerCurrentCaptionLanguage for Netflix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Steele committed Sep 12, 2018
1 parent a3e3680 commit b64dd47
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions public/content-scripts/netflix/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ class NetflixAdapter extends Adapter {
return undefined;
}

getPlayerCurrentCaptionLanguage() {
let videoPlayer, currentSessionId, currentTextTrack;
try {
videoPlayer = window.netflix.appContext.state.playerApp.getAPI().videoPlayer;
currentSessionId = videoPlayer.getAllPlayerSessionIds()[0]; // TODO - Can there be multiple? What does it mean?
currentTextTrack = videoPlayer.getCurrentTextTrackBySessionId(currentSessionId);
} catch (e) {
console.log(`Couldn't get the video player from the Netflix API`);
}
if (videoPlayer && currentSessionId && currentTextTrack) {
return currentTextTrack.bcp47;
// TODO - Compatible with ISO?
}
}

onPopupOpened() {
/**
Expand Down

0 comments on commit b64dd47

Please sign in to comment.