Paused, embed and includes

- Fixed issue with paused video playing on changing song for others
- Fixed more embedoptions
- cueVideoById is a neat function that I should have used earlier
- Added smaller jquery.ui files
This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-04 20:56:41 +01:00
parent 57c64d8e29
commit bdf014b4ff
5 changed files with 52 additions and 25 deletions

View File

@@ -295,6 +295,7 @@
outline: none;
border: none;
margin-left: -7.5px;
margin-top: 0;
border-radius: 1000px;
transition: background 0.2s ease, box-shadow 0.2s ease;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -44,8 +44,10 @@ var Player = {
startTime = time - conf.startTime;
song_title = obj.np[0].title;
duration = obj.np[0].duration;
Player.loadVideoById(video_id, duration);
Player.stopVideo();
if(player_ready) {
Player.cueVideoById(video_id, duration);
Player.stopVideo();
}
return;
}
if(embed && obj.np) {
@@ -76,9 +78,7 @@ var Player = {
"mobile_beginning variable: " + mobile_beginning]);
try{
Helper.log(["getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]]);
} catch(e){
}
} catch(e){}
Helper.log(["video_id variable: " + video_id]);
if(!obj.np){
$('#song-title').html("Empty channel. Add some songs!");
@@ -99,7 +99,8 @@ var Player = {
}
//List.importOldList(channel.toLowerCase());
} else if(paused){
} else if(paused || was_stopped){
Player.getTitle(obj.np[0].title, viewers);
//Player.setBGimage(video_id);
if(!Helper.mobilecheck()) {
@@ -128,6 +129,7 @@ var Player = {
startTime = time - conf.startTime;
song_title = obj.np[0].title;
duration = obj.np[0].duration;
Player.cueVideoById(video_id, duration);
//Player.setBGimage(video_id);
} else if(!paused){
//Helper.log("gotten new song");
@@ -187,14 +189,15 @@ var Player = {
} else {
if(compared || chromecastAvailable){
Player.loadVideoById(video_id, duration);
if(paused && !chromecastAvailable){
Player.cueVideoById(video_id, duration);
} else {
Player.loadVideoById(video_id, duration);
Player.seekTo(seekTo);
}
if(!Helper.mobilecheck()) {
Player.notifyUser(video_id, song_title);
}
Player.seekTo(seekTo);
if(paused && !chromecastAvailable){
Player.pauseVideo();
}
}
if(!paused){
if(((!mobile_beginning || chromecastAvailable) && prev_state != 2) && autoplay) {
@@ -215,7 +218,7 @@ var Player = {
}
}
}catch(e) {
if(chromecastAvailable) {
if(chromecastAvailable && !paused) {
Player.loadVideoById(video_id, duration);
Player.seekTo(seekTo);
}
@@ -397,6 +400,18 @@ var Player = {
}
},
cueVideoById: function(id, this_duration, start, end){
var s;
var e;
if(start) s = start;
else s = Player.np.start;
if(end) e = end;
else e = Player.np.end;
Player.player.cueVideoById({'videoId': id, 'startSeconds': s, 'endSeconds': e});
},
stopVideo: function(){
if(chromecastAvailable){
castSession.sendMessage("urn:x-cast:zoff.me", {type: "stopVideo"});
@@ -561,21 +576,25 @@ var Player = {
$(".video-container").removeClass("no-opacity");
$("#controls").css("opacity", "1");
$(".playlist").css("opacity", "1");
Player.loadVideoById(video_id, duration);
if(autoplay) {
Player.loadVideoById(video_id, duration);
} else {
Player.cueVideoById(video_id, duration);
}
if(autoplay && (!Helper.mobilecheck() || chromecastAvailable)) {
Player.playVideo();
//Player.playVideo();
}
if(!durationBegun) {
Player.durationSetter();
}
if(embed){
setTimeout(function(){
Player.player.seekTo(seekTo);
//setTimeout(function(){
//Player.player.seekTo(seekTo);
if(!autoplay){
Player.player.pauseVideo();
Player.player.stopVideo();
Playercontrols.play_pause_show();
}
}, 1000);
//}, 1000);
}else
Player.seekTo(seekTo);
}

View File

@@ -33,6 +33,7 @@
<link rel="icon" id="favicon" type="image/png" sizes="16x16" href="/assets/images/favicon-16x16.png">
<link rel="mask-icon" href="/assets/images/safari-pinned-tab.svg" color="#2d2d2d">
{{/if}}
<link rel="stylesheet" href="/assets/css/jquery-ui.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<link rel="stylesheet" type="text/css" href="/assets/css/{{stylesheet}}" title="Default" />
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
@@ -43,7 +44,6 @@
{{else}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.min.js"></script>
<script type="text/javascript" src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.js"></script>
<script type="text/javascript" src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.ui.position.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript">
if(window.location.hostname != "localhost") {
@@ -55,7 +55,7 @@
ga('create', '{{{ analytics }}}', 'auto');
} else {
function ga() {
console.log(arguments);
}
}
</script>