Skip to content

Commit 24c3104

Browse files
committed
Buffer Seek Bug Fixed
Youtube client will now autoplay when seeking with the host after a buffer. Before when the host used an event listener to load a part of a video that was not loaded, it would pause on the other sockets.
1 parent 116640c commit 24c3104

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

index.html

+9-7
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,11 @@ <h2> Join a Room! </h2>
112112
</div>
113113

114114

115-
<br/>
116-
NOTE: MOBILE IS CURRENTLY BROKEN, EVENT HANDLERS IN BETA
115+
<br/> NOTE: MOBILE IS CURRENTLY BROKEN, EVENT HANDLERS IN BETA
117116
<br/>
118117
<h2><span id="hostlabel" class="label label-default"> Current Host: Kyle </span></h2>
119118

120-
<!----------------------------------- PLAYER AREA ----------------------------------->
119+
<!----------------------------------- PLAYER AREA ----------------------------------->
121120

122121
<div id='playerArea'>
123122
<iframe class="video" id="player" allowfullscreen="0" rel="0" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1" frameborder="1" style="border: solid 4px #37474F"></iframe>
@@ -129,7 +128,7 @@ <h2><span id="hostlabel" class="label label-default"> Current Host: Kyle </span>
129128
<iframe class="video" id="player-vimeo" src="https://player.vimeo.com/video/76979871" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
130129
</div>
131130

132-
<!----------------------------------- PLAYER AREA ----------------------------------->
131+
<!----------------------------------- PLAYER AREA ----------------------------------->
133132

134133
<div>
135134
<button onclick="playVideo(roomnum)" style="margin-top:.5rem" class="btn btn-primary"><i class="fa fa-play"></i> Play / <i class="fa fa-pause"></i> Pause</button>
@@ -172,6 +171,7 @@ <h3>Online Users</h3>
172171
<!-- /.row -->
173172

174173
<div id="messageArea" class="row">
174+
<br/>
175175
<h2 style="color:gray">Chat</h2>
176176
<div class="col-md-8">
177177
<div class="chat" id="chat"></div>
@@ -240,14 +240,16 @@ <h2 class="card-title">Card Three</h2>
240240

241241
<hr style="height:120pt; visibility:hidden;" />
242242
<section id="about" class="bg-light">
243+
<br/>
244+
<br/>
243245
<div class="container">
244246
<div class="row">
245247
<div class="col-lg-8 mx-auto">
246248
<h2>About Vynchronize</h2>
247249
<p class="lead">Vynchronize is a video synchronization platform created for viewing parties with friends!</p>
248-
<p> To use Vynchronize just enter your name and a shared room number with friends. Then all you have to do is enter in a video id which you can get from a specific youtube video link then click on change video. The video will change
249-
for everyone connected to your room. You can use the play and sync buttons to control video playback. Play simply plays/pauses the video for everyone. The sync button syncs everyone in the room to your current position
250-
in the video. Normal controls on the youtube player still work, but they only affect you! If you want to pause the video only for yourself, then just pause on the player instead of hitting the play button!</p>
250+
<p> To use Vynchronize just enter your name and a shared room number with friends. Then all you have to do is select your video client (YouTube by default), enter a video ID, and click "Change Video". All video playback should
251+
be synchronized to everyone in the room! </p>
252+
<p> There is one host per room that can control the video client directly with the native player controls. Everyone else can still use them but it will only affect them until they hit sync!</p>
251253
<p> Have fun watching videos with friends!</p>
252254
</div>
253255
</div>

js/events.js

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function seekOther(roomnum, currTime) {
7878
room: roomnum,
7979
time: currTime
8080
});
81+
// socket.emit('getData');
8182
}
8283

8384

@@ -92,6 +93,8 @@ socket.on('justSeek', function(data) {
9293
var clientTime = player.getCurrentTime();
9394
if (clientTime < currTime - .1 || clientTime > currTime + .1) {
9495
player.seekTo(currTime);
96+
// Forces video to play right after seek
97+
player.playVideo()
9598
}
9699
break;
97100
case 1:

js/yt.js

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function onPlayerStateChange(event) {
7272
var currTime = player.getCurrentTime();
7373
if (host) {
7474
seekOther(roomnum, currTime)
75+
// syncVideo(roomnum)
7576
}
7677
break;
7778
}

server.js

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ io.sockets.on('connection', function(socket) {
6666
io.sockets.in("room-" + roomnum).emit('justSeek', {
6767
time: currTime
6868
});
69+
70+
// Sync up
71+
// host = io.sockets.adapter.rooms['room-' + roomnum].host
72+
// console.log("let me sync "+host)
73+
// socket.broadcast.to(host).emit('getData');
6974
});
7075

7176
// Sync video

0 commit comments

Comments
 (0)