-
+
+
);
-export default Loading;
\ No newline at end of file
+export default Loading;
diff --git a/src/VideoListener.js b/src/VideoListener.js
new file mode 100644
index 0000000..df343b9
--- /dev/null
+++ b/src/VideoListener.js
@@ -0,0 +1,133 @@
+import { PLAYER_STATUS, getPlayerSource, PLAYER_SOURCE } from './Api';
+
+const templateListener = (video) => console.log(video);
+
+export default class VideoListener {
+ constructor(listener = templateListener) {
+ this.video = {
+ status: PLAYER_STATUS.NOT_PLAYING,
+ time: 0,
+ url: '',
+ source: '',
+ element: null,
+ };
+ this.listener = listener;
+ this.updateStatus = this.updateStatus.bind(this);
+ this.firstTimeSync = this.firstTimeSync.bind(this);
+ this.doUpdate = this.doUpdate.bind(this);
+ this.start = this.start.bind(this);
+ }
+ updateStatus(newStatus) {
+ this.video = Object.assign({}, this.video, newStatus);
+ this.listener(this.video);
+ }
+ doUpdate(serverPlayer) {
+ if (this.video.element) this.video.element.currentTime = serverPlayer.time;
+ switch (serverPlayer.status) {
+ case PLAYER_STATUS.PAUSED:
+ if (this.video.element) this.video.element.pause();
+ break;
+ case PLAYER_STATUS.NOT_PLAYING:
+ if (this.video.element) this.video.element.pause();
+ break;
+ case PLAYER_STATUS.PLAYING:
+ if (this.video.element) this.video.element.play();
+ break;
+ default:
+ break;
+ }
+ }
+ firstTimeSync(videoElement) {
+ this.updateStatus({
+ element: videoElement,
+ });
+ if (videoElement.paused) {
+ this.updateStatus({
+ time: videoElement.currentTime,
+ status: PLAYER_STATUS.PAUSED,
+ });
+ }
+ if (videoElement.currentTime > 0 && !videoElement.paused) {
+ this.updateStatus({
+ time: videoElement.currentTime,
+ status: PLAYER_STATUS.PLAYING,
+ });
+ }
+ videoElement.onplaying = (ev) => {
+ this.updateStatus({ status: PLAYER_STATUS.PLAYING, time: ev.timeStamp });
+ if (this.video.url === '') this.updateStatus({ url: window.location.href });
+ };
+ videoElement.onpause = (ev) =>
+ this.updateStatus({ status: PLAYER_STATUS.PAUSED, time: ev.timeStamp });
+ videoElement.onended = (ev) => {
+ this.updateStatus({ status: PLAYER_STATUS.NOT_PLAYING, url: '', time: 0 });
+ };
+ }
+ start() {
+ this.updateStatus({ source: getPlayerSource(), url: window.location.href });
+ switch (this.video.source) {
+ case PLAYER_SOURCE.NETFLIX:
+ if (document.getElementsByClassName('AkiraPlayer')[0]) {
+ const videoElement = document
+ .getElementsByClassName('AkiraPlayer')[0]
+ .getElementsByTagName('video')[0];
+ if (videoElement) {
+ this.firstTimeSync(videoElement);
+ }
+ } else {
+ document.body.addEventListener('DOMNodeInserted', (ev) => {
+ if (ev.target.tagName === 'VIDEO') {
+ document.body.removeEventListener('DOMNodeInserted');
+ this.start();
+ }
+ });
+ }
+ break;
+ case PLAYER_SOURCE.HULU:
+ const videoElement = document.getElementsByClassName('video-player')[0];
+ if (videoElement) {
+ this.firstTimeSync(videoElement);
+ } else {
+ document.body.addEventListener('DOMNodeInserted', (ev) => {
+ if (ev.target.tagName === 'VIDEO') {
+ document.body.removeEventListener('DOMNodeInserted');
+ this.start();
+ }
+ });
+ }
+ break;
+ case PLAYER_SOURCE.AMAZON:
+ if (document.getElementsByClassName('webPlayerSDKContainer')[0]) {
+ const videoElement = document
+ .getElementsByClassName('webPlayerSDKContainer')[0]
+ .getElementsByTagName('video')[0];
+ if (videoElement) {
+ this.firstTimeSync(videoElement);
+ }
+ } else {
+ document.body.addEventListener('DOMNodeInserted', (ev) => {
+ if (ev.target.tagName === 'VIDEO') {
+ document.body.removeEventListener('DOMNodeInserted');
+ this.start();
+ }
+ });
+ }
+ break;
+ case PLAYER_SOURCE.LOCAL:
+ const localVideoElement = document.getElementsByTagName('video')[0];
+ if (localVideoElement) {
+ this.firstTimeSync(localVideoElement);
+ } else {
+ document.body.addEventListener('DOMNodeInserted', (ev) => {
+ if (ev.target.tagName === 'VIDEO') {
+ document.body.removeEventListener('DOMNodeInserted');
+ this.start();
+ }
+ });
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/src/data_model.js b/src/data_model.js
deleted file mode 100644
index bfdf704..0000000
--- a/src/data_model.js
+++ /dev/null
@@ -1,38 +0,0 @@
-const DATA_MODEL = {
- users: {
- '
': {
- uid: '',
- rooms: [''],
- },
- '': {
- uid: '',
- rooms: [''],
- },
- },
- rooms: {
- '': {
- player: {
- source: 'hulu|netlix|amazon',
- state: 'playing|paused',
- time: '',
- },
- users: ['', ''],
- messages: {
- '': {
- uid: '',
- name: 'Jane Doe',
- text: 'Hello!!!!',
- time: '',
- },
- '': {
- uid: '',
- name: 'Long John',
- text: 'oh hi mark',
- time: '',
- },
- },
- },
- },
-};
-
-export default DATA_MODEL;
diff --git a/src/index.css b/src/index.css
index 4d6b0e3..91338f1 100644
--- a/src/index.css
+++ b/src/index.css
@@ -10,6 +10,9 @@ body.visible .watch-party-fab {
right: calc(35% - 4rem) !important;
top: 1.5rem;
}
+body.visible .party-notification-container {
+ display: block !important;
+}
body.netflix.visible .AkiraPlayer, /* NETFLIX */
body.hulu.visible .Player__container.addFocus,/* HULU */
@@ -26,11 +29,41 @@ body.amazon-prime #party-routes-wrapper {
width: 35% !important;
height: 100% !important;
}
-/* NETFLIX HEADER FIX */
-body.netflix .pinning-header-container {
- right: 35% !important;
-}
+@keyframes backgroundpulse {
+ 0% {
+ background-color: black;
+ color: red;
+ }
+ 50% {
+ background-color: red;
+ color: black;
+ }
+ 100% {
+ background-color: black;
+ color: red;
+ }
+}
+#party-loading {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ z-index: 9999;
+ background-color: rgba(0, 0, 0, 0.8);
+ display: flex;
+ top: 0;
+ left: 0;
+ align-items: center;
+ justify-content: center;
+}
+#party-loading.inactive {
+ flex-direction: column;
+ text-align: center;
+ animation-duration: 4s;
+ animation-timing-function: linear;
+ animation-iteration-count: infinite;
+ animation-name: backgroundpulse;
+}
#party-routes-wrapper {
margin: 0;
position: fixed;
@@ -48,6 +81,17 @@ body.netflix .pinning-header-container {
#party-routes-wrapper.visible {
right: 0;
}
+.party-notification-container {
+ display: none !important;
+ bottom: 0.8rem !important;
+ right: 1rem !important;
+ width: calc(35% - 2rem) !important;
+}
+.party-notification-container .MuiPaper-root {
+ border-radius: 26px !important;
+ color: white;
+ background-color: black;
+}
.watch-party-fab {
z-index: 9999;
position: fixed !important;
diff --git a/src/index.js b/src/index.js
index 82ce100..91f4992 100644
--- a/src/index.js
+++ b/src/index.js
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
import firebase from 'firebase/app';
import App from './App';
import './index.css';
+import { PLAYER_SOURCE, getPlayerSource } from './Api';
const firebaseConfig = {
apiKey: 'AIzaSyCJLuYpzXLDRmu2ttzFuSGmYcpFxqToWFU',
@@ -21,15 +22,32 @@ const PartyWrapper = document.createElement('div');
PartyWrapper.id = 'party_wrapper';
document.body.appendChild(PartyWrapper);
-const HREF = window.location.href;
+switch (getPlayerSource()) {
+ case PLAYER_SOURCE.NETFLIX:
+ document.body.classList.add('netflix');
+ break;
+ case PLAYER_SOURCE.HULU:
+ document.body.classList.add('hulu');
+ break;
+ case PLAYER_SOURCE.AMAZON:
+ document.body.classList.add('amazon-prime');
+ break;
+ default:
+ break;
+}
-// https://www.netflix. -- netflix
-// https://www.hulu. -- hulu
-// https://www.amazon. -- amazon prime
-
-if (HREF.startsWith('https://www.amazon')) document.body.classList.add('amazon-prime');
-if (HREF.startsWith('https://www.hulu')) document.body.classList.add('hulu');
-if (HREF.startsWith('https://www.netflix')) document.body.classList.add('netflix');
+// document.body.addEventListener('DOMNodeInserted', (ev) =>
+// console.log('DOC CHANGE', ev.target.tagName === 'VIDEO')
+// );
+const VideoPlayer = document.createElement('video');
+VideoPlayer.autoplay = true;
+VideoPlayer.muted = true;
+VideoPlayer.controls = true;
+VideoPlayer.style.width = '300px';
+VideoPlayer.src =
+ 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
+VideoPlayer.addEventListener('change', (e) => console.log(e));
+document.body.appendChild(VideoPlayer);
ReactDOM.render(
diff --git a/src/netflix.css b/src/netflix.css
deleted file mode 100644
index 723073e..0000000
--- a/src/netflix.css
+++ /dev/null
@@ -1,108 +0,0 @@
-body.netflix {
- display: flex;
- height: 100vh;
- overflow: hidden;
- background-color: black;
-}
-body.netflix #appMountPoint {
- z-index: 999;
- overflow-y: auto;
- max-height: 100vh;
- resize: horizontal;
- width: 1802px;
- margin: 0px;
- max-width: 100%;
- flex-grow: 3;
- flex-basis: 3;
-}
-.netflix-sans-font-loaded,
-.netflix-sans-font-loaded > div,
-.netflix-sans-font-loaded > div > div,
-.nf-kb-nav-wrapper,
-.sizing-wrapper {
- height: 100%;
-}
-#appMountPoint .netflix-sans-font-loaded > div > div > .nf-kb-nav-wrapper .sizing-wrapper {
- position: relative !important;
-}
-#party_wrapper.netflix {
- position: relative;
- z-index: 999;
- flex-shrink: 3;
- flex-basis: 1;
- background-color: #1e2126;
- width: 25%;
- overflow: hidden;
- display: flex;
-}
-#party_wrapper.netflix .content__wrapper {
- flex: 1;
- display: flex;
- padding: 20px;
- flex-direction: column;
-}
-#party_wrapper.netflix .party_chat_container {
- max-height: max-content;
- overflow-y: auto;
- padding-bottom: 1rem;
- flex: 1;
- padding-right: 1rem;
-}
-#party_wrapper.netflix h3 {
- color: white;
-}
-#party_wrapper.netflix h4 {
- display: flex;
- align-items: center;
- font-weight: 200;
- color: white;
-}
-#party_wrapper.netflix h4 button {
- margin-right: 15px;
-}
-#party_wrapper.netflix h4 span > svg {
- width: 15px;
- height: 15px;
-}
-.party_chat_input {
- position: relative;
- display: flex;
-}
-.party_chat_input #chat_input {
- resize: none;
- max-height: 100px;
- border-radius: 13px;
-}
-.party_chat_input ::-webkit-scrollbar {
- display: none;
-}
-.party_chat_input #chat_send {
- align-self: flex-end;
- margin-left: 5px;
- margin-bottom: 5px;
- color: white;
-}
-.party_chat_input #chat_send svg {
- height: 1.8rem;
- width: 1.8rem;
-}
-#loading_container {
- position: absolute;
- top: 0;
- left: 0;
- z-index: 1000;
- background-color: rgba(80, 80, 80, 0.9);
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
-}
-#loading_container svg {
- color: wheat;
- width: 40px;
- height: 40px;
-}
-.ant-popover-inner-content {
- padding: 0;
-}