Skip to content

Instantly share code, notes, and snippets.

@OstlerDev
Created June 29, 2015 00:10
Show Gist options
  • Save OstlerDev/898bbc3b2dce5639c823 to your computer and use it in GitHub Desktop.
Save OstlerDev/898bbc3b2dce5639c823 to your computer and use it in GitHub Desktop.
Netflix Play Next
atv.player.loadRelatedPlayback = function(a, callback){ // I have no idea what "a" is, but the callback sends the preplay XML back.
var o = atv.player.asset.getElementByTagName("myMetadata"),
t = o && o.getElementByTagName("relatedPlaybackURL"),
url = t && t.textContent;
handlePostPlay(url, callback);
}
function handlePostPlay(url, callback) {
// Load the Preplay XML
var req = new XMLHttpRequest();
req.open('GET', url, false);
req.send();
// Pull the document and get the XML
var doc=req.responseXML;
// Return the XML to the Apple TV
callback.success(doc);
}
<?xml version="1.0" encoding="UTF-8"?>
<atv>
<body>
<videoPlayer id="AtvVideoAssetView">
<httpLiveStreamingVideoAsset id="assetID">
<mediaURL>Media URL</mediaURL>
<title>Episode Title</title>
<description>Episode Description.</description>
<image>Episode Image</image>
<upNextPresentationTime>2511</upNextPresentationTime>
<upNextPresentationDuration>20</upNextPresentationDuration>
<myMetadata>
<relatedPlaybackURL>link to post play XML</relatedPlaybackURL>
</myMetadata>
<bookmarkTime>0</bookmarkTime>
<subtitleStylesURL>http://webvtt.nflxvideo.net/4/WebVTTStyle.plist</subtitleStylesURL>
</httpLiveStreamingVideoAsset>
</videoPlayer>
</body>
</atv>
<?xml version="1.0" encoding="UTF-8"?>
<atv>
<body>
<relatedPlayback>
<upNextItem id="AtvPostPlayVideoAssetView" onSelect="">
<httpLiveStreamingVideoAsset id="assetID">
<mediaURL>Media URL</mediaURL>
<title>Episode Title</title>
<description>Episode Description.</description>
<image>Episode Image</image>
<upNextPresentationTime>2500</upNextPresentationTime>
<upNextPresentationDuration>20</upNextPresentationDuration>
<bookmarkTime>0</bookmarkTime>
<subtitleStylesURL>http://webvtt.nflxvideo.net/4/WebVTTStyle.plist</subtitleStylesURL>
</httpLiveStreamingVideoAsset>
</upNextItem>
<optionsMenu>
<sections>
<menuSection>
<items>
<oneLineMenuItem id="nextEpisode" onSelect="">
<label>Play Next Episode</label>
</oneLineMenuItem>
<oneLineMenuItem id="moreEpisodes" onSelect="">
<label>More Episodes</label>
</oneLineMenuItem>
</items>
</menuSection>
</sections>
</optionsMenu>
</relatedPlayback>
</body>
</atv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment