mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
added mute/unmute functionality
This commit is contained in:
@@ -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;
|
||||
|
||||
2
static/dist/embed.min.js
vendored
2
static/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
6
static/dist/main.min.js
vendored
6
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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:
|
||||
|
||||
@@ -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>");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user