mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
support user audio & subtitle settings
This commit is contained in:
parent
a2a0afa970
commit
9985d6c429
2 changed files with 91 additions and 65 deletions
|
@ -757,10 +757,9 @@ progress {
|
||||||
z-index: 99998;
|
z-index: 99998;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 270px;
|
width: 270px;
|
||||||
bottom: 44px;
|
bottom: 45px;
|
||||||
left: -290px;
|
left: -290px;
|
||||||
border: 1px solid #666;
|
border: 1px solid #666;
|
||||||
border-bottom: 0;
|
|
||||||
background: #000;
|
background: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@
|
||||||
return audioElement[0];
|
return audioElement[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function playVideo(item, startPosition) {
|
function playVideo(item, startPosition, user) {
|
||||||
|
|
||||||
//stop/kill videoJS
|
//stop/kill videoJS
|
||||||
if (currentMediaElement) self.stop();
|
if (currentMediaElement) self.stop();
|
||||||
|
@ -390,38 +390,6 @@
|
||||||
var screenWidth = Math.max(screen.height, screen.width);
|
var screenWidth = Math.max(screen.height, screen.width);
|
||||||
var screenHeight = Math.min(screen.height, screen.width);
|
var screenHeight = Math.min(screen.height, screen.width);
|
||||||
|
|
||||||
var user = Dashboard.getCurrentUser();
|
|
||||||
var defaults = { languageIndex: null, subtitleIndex: null };
|
|
||||||
|
|
||||||
var userConfig = user.Configuration || {};
|
|
||||||
if (item.MediaStreams && item.MediaStreams.length) {
|
|
||||||
$.each(item.MediaStreams, function (i, stream) {
|
|
||||||
//get default subtitle stream
|
|
||||||
if (stream.Type == "Subtitle") {
|
|
||||||
if (userConfig.UseForcedSubtitlesOnly == true && userConfig.SubtitleLanguagePreference && !defaults.subtitleIndex) {
|
|
||||||
if (stream.Language == userConfig.SubtitleLanguagePreference && stream.IsForced == true) {
|
|
||||||
defaults.subtitleIndex = i;
|
|
||||||
}
|
|
||||||
} else if (userConfig.SubtitleLanguagePreference && !defaults.subtitleIndex) {
|
|
||||||
if (stream.Language == userConfig.SubtitleLanguagePreference) {
|
|
||||||
defaults.subtitleIndex = i;
|
|
||||||
}
|
|
||||||
} else if (userConfig.UseForcedSubtitlesOnly == true && !defaults.subtitleIndex) {
|
|
||||||
if (stream.IsForced == true) {
|
|
||||||
defaults.subtitleIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (stream.Type == "Audio") {
|
|
||||||
//get default language stream
|
|
||||||
if (userConfig.AudioLanguagePreference && !defaults.languageIndex) {
|
|
||||||
if (stream.Language == userConfig.AudioLanguagePreference) {
|
|
||||||
defaults.languageIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var baseParams = {
|
var baseParams = {
|
||||||
audioChannels: 2,
|
audioChannels: 2,
|
||||||
audioBitrate: 128000,
|
audioBitrate: 128000,
|
||||||
|
@ -429,8 +397,8 @@
|
||||||
maxWidth: screenWidth,
|
maxWidth: screenWidth,
|
||||||
maxHeight: screenHeight,
|
maxHeight: screenHeight,
|
||||||
StartTimeTicks: 0,
|
StartTimeTicks: 0,
|
||||||
SubtitleStreamIndex: null,
|
SubtitleStreamIndex: getInitialSubtitleStreamIndex(item.MediaStreams, user),
|
||||||
AudioStreamIndex: null
|
AudioStreamIndex: getInitialAudioStreamIndex(item.MediaStreams, user)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (startPosition) {
|
if (startPosition) {
|
||||||
|
@ -561,6 +529,62 @@
|
||||||
curentDurationTicks = item.RunTimeTicks;
|
curentDurationTicks = item.RunTimeTicks;
|
||||||
|
|
||||||
return videoElement[0];
|
return videoElement[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
function getInitialAudioStreamIndex(mediaStreams, user) {
|
||||||
|
|
||||||
|
if (user.Configuration.AudioLanguagePreference) {
|
||||||
|
|
||||||
|
for (var i = 0, length = mediaStreams.length; i < length; i++) {
|
||||||
|
var mediaStream = mediaStreams[i];
|
||||||
|
|
||||||
|
if (mediaStream.Type == "Audio" && mediaStream.Language == user.Configuration.AudioLanguagePreference) {
|
||||||
|
return mediaStream.Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInitialSubtitleStreamIndex(mediaStreams, user) {
|
||||||
|
|
||||||
|
var i, length, mediaStream;
|
||||||
|
|
||||||
|
// Find the first forced subtitle stream
|
||||||
|
for (i = 0, length = mediaStreams.length; i < length; i++) {
|
||||||
|
mediaStream = mediaStreams[i];
|
||||||
|
|
||||||
|
if (mediaStream.Type == "Subtitle" && mediaStream.IsForced) {
|
||||||
|
return mediaStream.Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// If none then look at user configuration
|
||||||
|
if (user.Configuration.AudioLanguagePreference) {
|
||||||
|
|
||||||
|
for (i = 0, length = mediaStreams.length; i < length; i++) {
|
||||||
|
mediaStream = mediaStreams[i];
|
||||||
|
|
||||||
|
if (mediaStream.Type == "Audio" && mediaStream.Language == user.Configuration.AudioLanguagePreference) {
|
||||||
|
|
||||||
|
if (user.Configuration.UseForcedSubtitlesOnly) {
|
||||||
|
|
||||||
|
if (mediaStream.IsForced) {
|
||||||
|
return mediaStream.Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return mediaStream.Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.canPlay = function (item) {
|
self.canPlay = function (item) {
|
||||||
|
@ -597,18 +621,20 @@
|
||||||
|
|
||||||
self.play = function (items, startPosition) {
|
self.play = function (items, startPosition) {
|
||||||
|
|
||||||
|
Dashboard.getCurrentUser().done(function (user) {
|
||||||
|
|
||||||
var item = items[0];
|
var item = items[0];
|
||||||
|
|
||||||
var videoType = (item.VideoType || "").toLowerCase();
|
var videoType = (item.VideoType || "").toLowerCase();
|
||||||
|
|
||||||
if (videoType == "dvd") {
|
if (videoType == "dvd") {
|
||||||
|
|
||||||
self.playWithWarning(items, startPosition, "dvdstreamconfirmed", "Dvd Folder Streaming");
|
self.playWithWarning(items, startPosition, user, "dvdstreamconfirmed", "Dvd Folder Streaming");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (videoType == "bluray") {
|
else if (videoType == "bluray") {
|
||||||
|
|
||||||
self.playWithWarning(items, startPosition, "bluraystreamconfirmed", "Blu-ray Folder Streaming");
|
self.playWithWarning(items, startPosition, user, "bluraystreamconfirmed", "Blu-ray Folder Streaming");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (videoType == "iso") {
|
else if (videoType == "iso") {
|
||||||
|
@ -617,23 +643,24 @@
|
||||||
|
|
||||||
if (isoType == "dvd") {
|
if (isoType == "dvd") {
|
||||||
|
|
||||||
self.playWithWarning(items, startPosition, "dvdisostreamconfirmed", "Dvd Iso Streaming");
|
self.playWithWarning(items, startPosition, user, "dvdisostreamconfirmed", "Dvd Iso Streaming");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (isoType == "bluray") {
|
else if (isoType == "bluray") {
|
||||||
|
|
||||||
self.playWithWarning(items, startPosition, "blurayisostreamconfirmed", "Blu-ray Iso Streaming");
|
self.playWithWarning(items, startPosition, user, "blurayisostreamconfirmed", "Blu-ray Iso Streaming");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.play(items, startPosition);
|
self.playInternal(items, startPosition, user);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.playWithWarning = function (items, startPosition, localStorageKeyName, header) {
|
self.playWithWarning = function (items, startPosition, user, localStorageKeyName, header) {
|
||||||
|
|
||||||
if (localStorage.getItem(localStorageKeyName) == "1") {
|
if (localStorage.getItem(localStorageKeyName) == "1") {
|
||||||
self.playInternal(items, startPosition);
|
self.playInternal(items, startPosition, user);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,14 +669,14 @@
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
||||||
localStorage.setItem(localStorageKeyName, "1");
|
localStorage.setItem(localStorageKeyName, "1");
|
||||||
self.playInternal(items, startPosition);
|
self.playInternal(items, startPosition, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.playInternal = function (items, startPosition) {
|
self.playInternal = function (items, startPosition, user) {
|
||||||
|
|
||||||
if (self.isPlaying()) {
|
if (self.isPlaying()) {
|
||||||
self.stop();
|
self.stop();
|
||||||
|
@ -661,7 +688,7 @@
|
||||||
|
|
||||||
if (item.MediaType === "Video") {
|
if (item.MediaType === "Video") {
|
||||||
|
|
||||||
mediaElement = playVideo(item, startPosition);
|
mediaElement = playVideo(item, startPosition, user);
|
||||||
} else if (item.MediaType === "Audio") {
|
} else if (item.MediaType === "Audio") {
|
||||||
|
|
||||||
mediaElement = playAudio(item);
|
mediaElement = playAudio(item);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue