Several fixes

- User playlists should now list correctly (fixed a race condition)
  - Livestream types can autoplay (no longer stuck at currentTime = -3)
  - Playlist items with NaN duration do not break user playlist saving
  - ffmpeg support can handle live media (e.g. icecast)
  - Invalid volume is sanitized and an error message is added
  - JWPlayer displays correctly for both HTML5 and Flash
  - JWPlayer volume synchronization is fixed
  - <audio> and <video> tags are scaled correctly with .embed-responsive-item
This commit is contained in:
calzoneman 2014-12-02 22:21:52 -06:00
parent b09346392e
commit b587da6701
7 changed files with 33 additions and 14 deletions

View file

@ -418,9 +418,6 @@ Callbacks = {
/* REGION Rank Stuff */
rank: function(r) {
if (r >= 1) {
socket.emit("listPlaylists");
}
if(r >= 255)
SUPERADMIN = true;
CLIENT.rank = r;
@ -840,7 +837,7 @@ Callbacks = {
}
/* Failsafe */
if (isNaN(VOLUME)) {
if (isNaN(VOLUME) || VOLUME > 1 || VOLUME < 0) {
VOLUME = 1;
}
@ -849,8 +846,14 @@ Callbacks = {
if (PLAYER && typeof PLAYER.getVolume === "function") {
PLAYER.getVolume(function (v) {
if (typeof v === "number") {
VOLUME = v;
setOpt("volume", VOLUME);
if (v < 0 || v > 1) {
alert("Something went wrong with retrieving the volume. " +
"Please tell calzoneman the following: " +
JSON.stringify({ v: v, t: PLAYER.type, i: PLAYER.videoId }));
} else {
VOLUME = v;
setOpt("volume", VOLUME);
}
}
});
}

View file

@ -706,11 +706,19 @@ var JWPlayer = function (data) {
jwplayer().onReady(function() {
$("#ytapiplayer").addClass("embed-responsive-item");
$("#ytapiplayer").parent().css("position", "absolute");
if ($("#ytapiplayer")[0].tagName === "OBJECT") {
$("#ytapiplayer").parent().css("position", "absolute");
}
handleVideoResize();
});
jwplayer().onPlay(function() {
/* Somehow JWPlayer manages to have THE SAME PROBLEM AS SOUNDCLOUD.
* It seems to be impossible to set the volume before the video has
* started playing. How this is so damn difficult to get right I will
* never understand.
*/
self.setVolume(VOLUME);
self.paused = false;
if(CLIENT.leader)
sendVideoUpdate();
@ -723,8 +731,6 @@ var JWPlayer = function (data) {
jwplayer().onComplete(function() {
socket.emit("playNext");
});
self.setVolume(VOLUME);
};
self.load = function (data) {
@ -898,15 +904,18 @@ function FilePlayer(data) {
video = $("<video/>")
}
video
.addClass("embed-responsive-item")
.attr("src", self.videoURL)
.attr("controls", "controls")
.attr("id", "#ytapiplayer")
.attr("width", VWIDTH)
.attr("height", VHEIGHT)
.attr("autoplay", true)
.html("Your browser does not support HTML5 <code>&lt;video&gt;</code> tags :(");
video.error(function (err) {
setTimeout(function () {
console.log("<video> tag failed, falling back to Flash");
console.log(err);
PLAYER = new JWPlayer(data);
PLAYER.type = "jw";
}, 100);

View file

@ -2569,6 +2569,9 @@ function fallbackRaw(data) {
$("video").each(function () {
killVideoUntilItIsDead($(this));
});
$("audio").each(function () {
killVideoUntilItIsDead($(this));
});
data.type = "fl";
data.url = data.direct.sd.url;
PLAYER.player = undefined;