|
|
|
@@ -9,7 +9,7 @@ ALL CONTENT ON WATCH PARTY'S WEBSITE OR IN WATCH PARTY'S CHROME EXTENSION APP, U
|
|
|
|
|
CITED ARE THE SOLE INTELECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE
|
|
|
|
|
COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
|
|
|
|
************************************************************************/
|
|
|
|
|
import { PLAYER_STATUS, getPlayerSource, PLAYER_SOURCE, LocalData } from './Api';
|
|
|
|
|
import { PLAYER_STATUS, getPlayerSource, PLAYER_SOURCE, LocalData} from './Api';
|
|
|
|
|
|
|
|
|
|
const templateListener = (video) => console.log('MISSING VIDEO LISTENER');
|
|
|
|
|
|
|
|
|
@@ -72,7 +72,6 @@ export default class VideoListener {
|
|
|
|
|
switch (this.video.source) {
|
|
|
|
|
case PLAYER_SOURCE.CRUNCHYROLL:
|
|
|
|
|
case PLAYER_SOURCE.FUNIMATION:
|
|
|
|
|
case PLAYER_SOURCE.VRV:
|
|
|
|
|
window.removeEventListener('watchParty', this.crunchyRollListener);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@@ -162,16 +161,6 @@ export default class VideoListener {
|
|
|
|
|
time: serverPlayer.time,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
case PLAYER_SOURCE.VRV:
|
|
|
|
|
window.postMessage(
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
watchPartyDirection: 'TO_SCRIPT',
|
|
|
|
|
type: 'WATCH_PARTY_SEEK',
|
|
|
|
|
status: serverPlayer.status,
|
|
|
|
|
time: serverPlayer.time,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@@ -190,8 +179,7 @@ export default class VideoListener {
|
|
|
|
|
PLAYER_SOURCE.CRUNCHYROLL === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.PEACOCK === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.FUNIMATION === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.ROOSTERTEETH === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.VRV === this.video.source
|
|
|
|
|
PLAYER_SOURCE.ROOSTERTEETH === this.video.source
|
|
|
|
|
) {
|
|
|
|
|
window.postMessage(
|
|
|
|
|
JSON.stringify({
|
|
|
|
@@ -217,8 +205,7 @@ export default class VideoListener {
|
|
|
|
|
PLAYER_SOURCE.CRUNCHYROLL === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.PEACOCK === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.FUNIMATION === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.ROOSTERTEETH === this.video.source ||
|
|
|
|
|
PLAYER_SOURCE.VRV === this.video.source
|
|
|
|
|
PLAYER_SOURCE.ROOSTERTEETH === this.video.source
|
|
|
|
|
) {
|
|
|
|
|
window.postMessage(
|
|
|
|
|
JSON.stringify({
|
|
|
|
@@ -242,7 +229,6 @@ export default class VideoListener {
|
|
|
|
|
switch (this.video.source) {
|
|
|
|
|
case PLAYER_SOURCE.CRUNCHYROLL:
|
|
|
|
|
case PLAYER_SOURCE.FUNIMATION:
|
|
|
|
|
case PLAYER_SOURCE.VRV:
|
|
|
|
|
window.addEventListener('watchParty', this.crunchyRollListener);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@@ -357,12 +343,6 @@ export default class VideoListener {
|
|
|
|
|
return roosterTeethShow === '' && roosterTeethEpisode === ''
|
|
|
|
|
? null
|
|
|
|
|
: roosterTeethShow + '\n' + roosterTeethEpisode;
|
|
|
|
|
case PLAYER_SOURCE.VRV:
|
|
|
|
|
const vrvShowContainer = document.querySelector(nS.show);
|
|
|
|
|
const vrvEpisodeContainer = document.querySelector(nS.episode);
|
|
|
|
|
const vrvShow = vrvShowContainer ? vrvShowContainer.innerText : '';
|
|
|
|
|
const vrvEpisode = vrvEpisodeContainer ? vrvEpisodeContainer.innerText : '';
|
|
|
|
|
return vrvShow === '' && vrvEpisode === '' ? null : vrvShow + ' ' + vrvEpisode;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@@ -403,7 +383,6 @@ export default class VideoListener {
|
|
|
|
|
switch (this.video.source) {
|
|
|
|
|
case PLAYER_SOURCE.CRUNCHYROLL:
|
|
|
|
|
case PLAYER_SOURCE.FUNIMATION:
|
|
|
|
|
case PLAYER_SOURCE.VRV:
|
|
|
|
|
window.postMessage(
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
watchPartyDirection: 'TO_SCRIPT',
|
|
|
|
@@ -771,38 +750,6 @@ export default class VideoListener {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PLAYER_SOURCE.VRV:
|
|
|
|
|
const vrvInject = `var sendToWatchPartyApp=function(pS,pT){var customWatchPartyEvent=new CustomEvent('watchParty',{detail:{watchPartyDirection:'TO_APP',type:'WATCH_PARTY_PLAYER_UPDATE',status:pS,time:pT}});window.dispatchEvent(customWatchPartyEvent)},watchPartyGetTimeAndSend=function(pS){const playerIframe=document.querySelector('${
|
|
|
|
|
this.selectors[PLAYER_SOURCE.VRV]
|
|
|
|
|
}');if(playerIframe){const player=playerIframe.contentWindow.document.querySelector('video');if(player){sendToWatchPartyApp(pS,player.currentTime)}}},watchPartySendPlaying=function(){watchPartyGetTimeAndSend('PLAYING')},watchPartySendPaused=function(){watchPartyGetTimeAndSend('PAUSED')},watchPartyInteraction=function(e){const data=JSON.parse(e.data);const playerIframe=document.querySelector('${
|
|
|
|
|
this.selectors[PLAYER_SOURCE.VRV]
|
|
|
|
|
}');if(playerIframe){const player=playerIframe.contentWindow.document.querySelector('video');if(player){if(data.watchPartyDirection==='TO_SCRIPT'){if(data.type==='WATCH_PARTY_ADD_LISTENERS'){player.addEventListener('playing',watchPartySendPlaying);player.addEventListener('pause',watchPartySendPaused)}else if(data.type==='WATCH_PARTY_SEEK'){const playerNode=player.parentNode;if(playerNode&&playerNode.player){playerNode.player.currentTime(data.time)}}else if(data.type==='WATCH_PARTY_STATUS'){if(data.status==='PAUSED')player.pause();if(data.status==='PLAYING')player.play()}}}}};window.addEventListener("message",watchPartyInteraction);`;
|
|
|
|
|
const vrvInjectScript = document.createElement('script');
|
|
|
|
|
vrvInjectScript.text = vrvInject;
|
|
|
|
|
document.head.appendChild(vrvInjectScript);
|
|
|
|
|
const vrvIframe = document.querySelector(this.selectors[PLAYER_SOURCE.VRV]);
|
|
|
|
|
if (vrvIframe) {
|
|
|
|
|
this.firstTimeSync(vrvIframe);
|
|
|
|
|
} else {
|
|
|
|
|
setInterval(
|
|
|
|
|
this.video.element
|
|
|
|
|
? null
|
|
|
|
|
: () => {
|
|
|
|
|
const vrvif = document.querySelector(this.selectors[PLAYER_SOURCE.VRV]);
|
|
|
|
|
if (vrvif) {
|
|
|
|
|
this.firstTimeSync(vrvif);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
1000
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PLAYER_SOURCE.LOCAL:
|
|
|
|
|
const localVideoElement = document.getElementsByTagName('video')[0];
|
|
|
|
|
if (localVideoElement) {
|
|
|
|
|
this.firstTimeSync(localVideoElement);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|