Created
March 2, 2020 21:11
-
-
Save mseeley/1d2b06c8f35b11c5e6d65c39c929cbff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Parsec standalone</title> | |
</head> | |
<body> | |
<video id="video"></video> | |
</body> | |
<script src="./parsec-2.0-b2011ff.js"></script> | |
<script> | |
const url = "https://76-88-163-157.a8cea4aa093342a1b1a5760b57bb940f.plex.direct:54545/game/:/transcode/start?path=%2Flibrary%2Fmetadata%2F4498014&X-Plex-Product=Plex%20Web&X-Plex-Version=4.27.0&X-Plex-Client-Identifier=mojr5xtlnbdmfwjexx0xdqje&X-Plex-Platform=Chrome&X-Plex-Platform-Version=80.0&X-Plex-Sync-Version=2&X-Plex-Features=external-media%2Cindirect-media&X-Plex-Model=standalone&X-Plex-Device=OSX&X-Plex-Device-Name=Chrome&X-Plex-Device-Screen-Resolution=861x862%2C1920x1200&X-Plex-Token=TOKEN&X-Plex-Language=en&Accept-Language=en'" | |
const onError = (...args) => { | |
console.error(...args) | |
}; | |
const xhr = new window.XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.addEventListener('abort', onError); | |
xhr.addEventListener('error', onError); | |
xhr.addEventListener('timeout', onError); | |
xhr.addEventListener('load', (event) => { | |
const responseText = event.target.responseText; | |
// Endpoint returned XML regardless of `Content-Type`. | |
const peerIDMatches = responseText.match(/peerID="([^"]+)"/); | |
const sessionIDMatches = responseText.match(/sessionID="([^"]+)"/); | |
const identifiers = { | |
peerID: peerIDMatches?.[1], | |
sessionID: sessionIDMatches?.[1], | |
}; | |
console.log('[Game] Video ready, creating client'); | |
const Parsec = window.__PARSEC_EXPORT; | |
const client = new Parsec(document.getElementById('video'), (event) => { | |
console.log('[Game] Client event:', event); | |
}); | |
console.log('[Game] Connecting client:', identifiers); | |
client.connect(identifiers.sessionID, identifiers.peerID); | |
}); | |
console.log('[Game] Fetching identifiers from:', url); | |
xhr.send(); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment