mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
fixes #189 - Dashboard remember volume not working
This commit is contained in:
parent
7e3e103989
commit
f9c330fb36
1 changed files with 34 additions and 31 deletions
|
@ -11,7 +11,7 @@
|
||||||
function playAudio(items, params) {
|
function playAudio(items, params) {
|
||||||
var item = items[0];
|
var item = items[0];
|
||||||
|
|
||||||
var volume = localStorage.getItem("volume") || 0.5;
|
var volume = localStorage.getItem("volume") || 0.5;
|
||||||
|
|
||||||
var baseParams = {
|
var baseParams = {
|
||||||
audioChannels: 2,
|
audioChannels: 2,
|
||||||
|
@ -52,15 +52,18 @@
|
||||||
|
|
||||||
$('#mediaElement', nowPlayingBar).html(html);
|
$('#mediaElement', nowPlayingBar).html(html);
|
||||||
|
|
||||||
$(".itemAudio").volume = volume;
|
$(".itemAudio").each(function () {
|
||||||
|
this.volume = volume;
|
||||||
|
});
|
||||||
|
|
||||||
$(".itemAudio").on("ended",function(){
|
$(".itemAudio").on("ended", function () {
|
||||||
Playlist.playNext();
|
Playlist.playNext();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".itemAudio").on("volumechange", function () {
|
$(".itemAudio").on("volumechange", function () {
|
||||||
localStorage.setItem("volume", (this).volume);
|
|
||||||
});
|
localStorage.setItem("volume", this.volume);
|
||||||
|
});
|
||||||
|
|
||||||
return $('audio', nowPlayingBar)[0];
|
return $('audio', nowPlayingBar)[0];
|
||||||
}
|
}
|
||||||
|
@ -157,14 +160,14 @@
|
||||||
videoCodec: 'theora',
|
videoCodec: 'theora',
|
||||||
audioCodec: 'Vorbis'
|
audioCodec: 'Vorbis'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// HLS must be at the top for safari
|
// HLS must be at the top for safari
|
||||||
// Webm must be ahead of mp4 due to the issue of mp4 playing too fast in chrome
|
// Webm must be ahead of mp4 due to the issue of mp4 playing too fast in chrome
|
||||||
|
|
||||||
var mkvVideoUrl = ApiClient.getUrl('Videos/' + item.Id + '/stream.mkv', $.extend({}, baseParams, {
|
var mkvVideoUrl = ApiClient.getUrl('Videos/' + item.Id + '/stream.mkv', $.extend({}, baseParams, {
|
||||||
videoCodec: 'h264',
|
videoCodec: 'h264',
|
||||||
audioCodec: 'aac'
|
audioCodec: 'aac'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
(this).src([
|
(this).src([
|
||||||
{ type: "application/x-mpegURL", src: hlsVideoUrl },
|
{ type: "application/x-mpegURL", src: hlsVideoUrl },
|
||||||
|
@ -187,16 +190,16 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
(this).addEvent("volumechange", function () {
|
(this).addEvent("volumechange", function () {
|
||||||
localStorage.setItem("volume", (this).volume());
|
localStorage.setItem("volume", this.volume());
|
||||||
});
|
});
|
||||||
|
|
||||||
(this).addEvent("play", updateProgress);
|
(this).addEvent("play", updateProgress);
|
||||||
|
|
||||||
(this).addEvent("ended", function () {
|
(this).addEvent("ended", function () {
|
||||||
MediaPlayer.stopVideo();
|
MediaPlayer.stopVideo();
|
||||||
|
|
||||||
Playlist.playNext();
|
Playlist.playNext();
|
||||||
});
|
});
|
||||||
|
|
||||||
ApiClient.reportPlaybackStart(Dashboard.getCurrentUserId(), item.Id);
|
ApiClient.reportPlaybackStart(Dashboard.getCurrentUserId(), item.Id);
|
||||||
});
|
});
|
||||||
|
@ -324,7 +327,7 @@
|
||||||
seriesName = item.SeriesName || item.Album || item.ProductionYear;
|
seriesName = item.SeriesName || item.Album || item.ProductionYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "<div><a href='itemdetails.html?id="+item.Id+"'><img class='nowPlayingBarImage ' alt='' title='' src='" + url + "' style='height:36px;display:inline-block;' /></a></div>";
|
html += "<div><a href='itemdetails.html?id=" + item.Id + "'><img class='nowPlayingBarImage ' alt='' title='' src='" + url + "' style='height:36px;display:inline-block;' /></a></div>";
|
||||||
if (item.Type == "Movie")
|
if (item.Type == "Movie")
|
||||||
html += '<div>' + name + '<br/>' + seriesName + '</div>';
|
html += '<div>' + name + '<br/>' + seriesName + '</div>';
|
||||||
else
|
else
|
||||||
|
@ -369,23 +372,23 @@
|
||||||
currentMediaElement = null;
|
currentMediaElement = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.stopVideo = function () {
|
self.stopVideo = function () {
|
||||||
var player = _V_("videoWindow");
|
var player = _V_("videoWindow");
|
||||||
|
|
||||||
var startTimeTicks = player.tag.src.match(new RegExp("StartTimeTicks=[0-9]+", "g"));
|
var startTimeTicks = player.tag.src.match(new RegExp("StartTimeTicks=[0-9]+", "g"));
|
||||||
var startTime = startTimeTicks[0].replace("StartTimeTicks=", "");
|
var startTime = startTimeTicks[0].replace("StartTimeTicks=", "");
|
||||||
|
|
||||||
var itemString = player.tag.src.match(new RegExp("Videos/[0-9a-z\-]+", "g"));
|
var itemString = player.tag.src.match(new RegExp("Videos/[0-9a-z\-]+", "g"));
|
||||||
var itemId = itemString[0].replace("Videos/", "");
|
var itemId = itemString[0].replace("Videos/", "");
|
||||||
|
|
||||||
var positionTicks = parseInt(startTime) + Math.floor(10000000 * player.currentTime());
|
var positionTicks = parseInt(startTime) + Math.floor(10000000 * player.currentTime());
|
||||||
|
|
||||||
ApiClient.reportPlaybackStopped(Dashboard.getCurrentUserId(), itemId, positionTicks);
|
ApiClient.reportPlaybackStopped(Dashboard.getCurrentUserId(), itemId, positionTicks);
|
||||||
|
|
||||||
if (currentProgressInterval) {
|
if (currentProgressInterval) {
|
||||||
clearTimeout(currentProgressInterval);
|
clearTimeout(currentProgressInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.isPlaying = function () {
|
self.isPlaying = function () {
|
||||||
return currentMediaElement;
|
return currentMediaElement;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue