From 1efcca6be9f7c666a9a61688e35ab316e421fa99 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 7 Jan 2014 19:24:03 -0600 Subject: [PATCH] Add option to use JWPlayer for h.264 --- www/assets/js/callbacks.js | 6 +++++- www/assets/js/data.js | 12 +++++++++++- www/assets/js/player.js | 7 ++++++- www/assets/js/util.js | 4 ++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 0daab287..73129127 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -1033,7 +1033,11 @@ Callbacks = { } if (data.type === "vi" && data.direct && data.direct.sd) { - data.type = "rv"; + if (USEROPTS.no_h264) { + data.type = "jw"; + } else { + data.type = "rv"; + } data.url = data.direct.sd.url; } diff --git a/www/assets/js/data.js b/www/assets/js/data.js index ce88422c..c35eebb3 100644 --- a/www/assets/js/data.js +++ b/www/assets/js/data.js @@ -97,6 +97,15 @@ function getOrDefault(k, def) { return v; } +function default_noh264() { + var ua = navigator.userAgent + ""; + if (ua.match(/Firefox\/29.0|Chrome|Chromium/)) { + return false; + } else { + return true; + } +} + var USEROPTS = { theme : getOrDefault("theme", "default"), css : getOrDefault("css", ""), @@ -120,7 +129,8 @@ var USEROPTS = { sort_afk : getOrDefault("sort_afk", false), default_quality : getOrDefault("default_quality", "#quality_auto"), boop : getOrDefault("boop", false), - secure_connection : getOrDefault("secure_connection", false) + secure_connection : getOrDefault("secure_connection", false), + no_h264 : getOrDefault("no_h264", default_noh264()) }; var VOLUME = getOrDefault("volume", 1); diff --git a/www/assets/js/player.js b/www/assets/js/player.js index 37f6ade1..514cb24d 100644 --- a/www/assets/js/player.js +++ b/www/assets/js/player.js @@ -731,12 +731,17 @@ var RTMPPlayer = function (data) { var JWPlayer = function (data) { var self = this; self.videoId = data.id; + if (data.url) { + self.videoURL = data.url; + } else { + self.videoURL = data.id; + } self.videoLength = data.seconds; self.init = function () { removeOld(); jwplayer("ytapiplayer").setup({ - file: self.videoId, + file: self.videoURL, width: VWIDTH, height: VHEIGHT, autostart: true diff --git a/www/assets/js/util.js b/www/assets/js/util.js index d91b83e8..82fba21f 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -662,6 +662,9 @@ function showOptionsMenu() { "issues on some systems"); addOption(playback, "", pl_wmodewarn); + var pl_noh264 = addCheckbox(playback, "h.264", "Use JWPlayer for h.264 playback"); + pl_noh264.prop("checked", USEROPTS.no_h264); + var pl_hide = addCheckbox(playback, "Hide Video", "Remove the video player"); pl_hide.prop("checked", USEROPTS.hidevid); @@ -731,6 +734,7 @@ function showOptionsMenu() { USEROPTS.hidevid = pl_hide.prop("checked"); USEROPTS.qbtn_hide = pl_hidebtn.prop("checked"); USEROPTS.qbtn_idontlikechange = pl_oldbtn.prop("checked"); + USEROPTS.no_h264 = pl_noh264.prop("checked"); USEROPTS.show_timestamps = chat_time.prop("checked"); USEROPTS.sort_rank = chat_sort_rank.prop("checked"); USEROPTS.sort_afk = chat_sort_afk.prop("checked");