From d095678478e1fcdee30f09c1610310a761b130ad Mon Sep 17 00:00:00 2001 From: devfake Date: Sun, 5 Jul 2015 22:16:25 +0200 Subject: [PATCH] fix music player --- assets/js/temp.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/assets/js/temp.js b/assets/js/temp.js index fe2c2df..45060ef 100644 --- a/assets/js/temp.js +++ b/assets/js/temp.js @@ -4,23 +4,25 @@ $(".video-self").tubeplayer({ height: 0.001, initialVideo: "UE9fPWy1_o4", autoPlay: true, + onPlayerPlaying: function(id){ + if(localStorage.getItem('volume') == 'off') { + $('.music-icon').removeClass('active'); + $(".video-self").tubeplayer('mute'); + } + + if(localStorage.getItem('volumeValue') != null) { + $('.video-self').tubeplayer('volume', localStorage.getItem('volumeValue')); + $('.volume').val(localStorage.getItem('volumeValue')); + } else { + $('.volume').val('75'); + $('.video-self').tubeplayer('volume', 75); + } + }, onPlayerEnded: function(){ $(".video-self").tubeplayer('play'); } }); -if(localStorage.getItem('volume') == 'off') { - $('.music-icon').removeClass('active'); -} - -if(localStorage.getItem('volumeValue') != null) { - $('.video-self').tubeplayer('volume', localStorage.getItem('volumeValue')); - $('.volume').val(localStorage.getItem('volumeValue')); -} else { - $('.volume').val('75'); - $('.video-self').tubeplayer('volume', 75); -} - // Set volume. $('.volume').on('blur', function() { var val = $(this).val();