added mute/unmute functionality

This commit is contained in:
Kasper Rynning-Tønnesen
2016-11-18 21:26:16 +01:00
parent 4eaedfe621
commit 0ccf943934
7 changed files with 28 additions and 21 deletions

View File

@@ -36,6 +36,12 @@ customMessageBus.onMessage = function(event) {
case "playVideo":
player.playVideo();
break;
case "mute":
player.mute();
break;
case "unMute":
player.unMute();
break;
case "seekTo":
player.seekTo(json_parsed.seekTo);
break;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -231,11 +231,16 @@ function init(){
$("#embed-area").val(embed_code(embed_autoplay, embed_width, embed_height));
$("#search").attr("placeholder", "Find song on YouTube...");
window['__onGCastApiAvailable'] = function(isAvailable) {
if (isAvailable) {
initializeCastApi();
}
};
if(chromecastAvailable){
hide_native(1);
} else {
window['__onGCastApiAvailable'] = function(isAvailable) {
if (isAvailable) {
initializeCastApi();
}
};
}
}
initializeCastApi = function() {
@@ -254,9 +259,6 @@ initializeCastApi = function() {
castSession.sendMessage("urn:x-cast:zoff.no", {type: "loadVideo", videoId: video_id, seekTo: Player.player.getCurrentTime()})
castSession.sendMessage("urn:x-cast:zoff.no", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
hide_native(1);
$(".castButton").toggleClass("hide");
$(".castButton-active").toggleClass("hide");
break;
case cast.framework.SessionState.SESSION_RESUMED:
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
@@ -265,13 +267,9 @@ initializeCastApi = function() {
castSession.sendMessage("urn:x-cast:zoff.no", {type: "loadVideo", videoId: video_id, seekTo: Player.player.getCurrentTime()})
castSession.sendMessage("urn:x-cast:zoff.no", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
hide_native(1);
$(".castButton").toggleClass("hide");
$(".castButton-active").toggleClass("hide");
break;
case cast.framework.SessionState.SESSION_ENDED:
chromecastAvailable = false;
$(".castButton").toggleClass("hide");
$(".castButton-active").toggleClass("hide");
hide_native(0);
// Update locally as necessary
break;
@@ -280,6 +278,8 @@ initializeCastApi = function() {
};
function hide_native(way){
$(".castButton").toggleClass("hide");
$(".castButton-active").toggleClass("hide");
if(way == 1){
$("#playpause").toggleClass("hide");
$("#duration").toggleClass("hide");
@@ -289,7 +289,7 @@ function hide_native(way){
Player.player.stopVideo();
Player.stopInterval = true;
//$("#player").toggleClass("hide");
$("#player_overlay").toggleClass("hide");
$("#player_overlay").removeClass("hide");
//$("#player_overlay").css("display", "block");
$("#player_overlay").css("height", "100%");
$("#player_overlay_text").toggleClass("hide");
@@ -304,7 +304,7 @@ function hide_native(way){
Player.stopInterval = false;
Player.durationSetter();
//$("#player").toggleClass("hide");
$("#player_overlay").toggleClass("hide");
$("#player_overlay").addClass("hide");
$("#player_overlay").css("height", "100%");
$("#player_overlay_text").toggleClass("hide");
$("#player_overlay_controls").css("display", "none");
@@ -313,7 +313,6 @@ function hide_native(way){
}
function chromecastListener(evt, data){
console.log(data);
var json_parsed = JSON.parse(data);
switch(json_parsed.type){
case -1:

View File

@@ -256,7 +256,7 @@ var Nochan = {
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
$("main").html($($(e)[63]).html());
} else {
var main = $($($($($(e)[65]).html())[0]).html());
var main = $($($($($(e)[63]).html())[0]).html());
$("#main-row").append($(main[2]).wrap("<div>").parent().html());
$("#video-container").append($($($(main[0]).html())[4]).wrap("<div>").parent().html());
$("#main-row").append("<div id='playbar'></div>");

View File

@@ -123,7 +123,7 @@ var Player = {
beginning = false;
mobile_beginning = false;
}
if(!embed && window.location.pathname != "/" && chromecastAvailable) Helper.addClass("#player_overlay", "hide");
if(!embed && window.location.pathname != "/" && !chromecastAvailable) Helper.addClass("#player_overlay", "hide");
if(window.location.pathname != "/"){
if(document.getElementById("play").className.split(" ").length == 1)
$("#play").toggleClass("hide");

View File

@@ -104,10 +104,12 @@ var Playercontrols = {
{
if(!Player.player.isMuted())
{
if(chromecastAvailable) castSession.sendMessage("urn:x-cast:zoff.no", {type: "mute"});
Playercontrols.choose_button(0, true);
Player.player.mute();
}else
{
if(chromecastAvailable)castSession.sendMessage("urn:x-cast:zoff.no", {type: "unMute"});
Player.player.unMute();
Playercontrols.choose_button(Player.player.getVolume(), false);
}