1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

consolidate datetime methods

This commit is contained in:
Luke Pulverenti 2016-05-05 23:09:36 -04:00
parent 8225003fd5
commit 7b625ade86
9 changed files with 231 additions and 278 deletions

View file

@ -1,4 +1,4 @@
define(['browser', 'jQuery', 'paper-fab', 'paper-tabs', 'paper-slider', 'paper-icon-button'], function (browser, $) {
define(['browser', 'datetime', 'jQuery', 'paper-fab', 'paper-tabs', 'paper-slider', 'paper-icon-button'], function (browser, datetime, $) {
function showSlideshowMenu(context) {
require(['scripts/slideshow'], function () {
@ -343,11 +343,11 @@
if (playState.PositionTicks == null) {
context.querySelector('.positionTime').innerHTML = '--:--';
} else {
context.querySelector('.positionTime').innerHTML = Dashboard.getDisplayTime(playState.PositionTicks);
context.querySelector('.positionTime').innerHTML = datetime.getDisplayRunningTime(playState.PositionTicks);
}
if (item && item.RunTimeTicks != null) {
context.querySelector('.runtime').innerHTML = Dashboard.getDisplayTime(item.RunTimeTicks);
context.querySelector('.runtime').innerHTML = datetime.getDisplayRunningTime(item.RunTimeTicks);
} else {
context.querySelector('.runtime').innerHTML = '--:--';
}
@ -733,7 +733,7 @@
ticks /= 100;
ticks *= value;
this.pinValue = Dashboard.getDisplayTime(ticks);
this.pinValue = datetime.getDisplayRunningTime(ticks);
};
context.addEventListener('click', onContextClick);

View file

@ -411,7 +411,7 @@
if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
html += ' - '+session.TranscodingInfo.Framerate + ' fps';
html += ' - ' + session.TranscodingInfo.Framerate + ' fps';
}
}
else if (session.PlayState.PlayMethod == 'DirectStream') {
@ -465,7 +465,7 @@
var html = '';
if (session.PlayState.PositionTicks) {
html += Dashboard.getDisplayTime(session.PlayState.PositionTicks);
html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks);
} else {
html += '--:--:--';
}
@ -475,7 +475,7 @@
var nowPlayingItem = session.NowPlayingItem;
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
html += Dashboard.getDisplayTime(nowPlayingItem.RunTimeTicks);
html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
} else {
html += '--:--:--';
}

View file

@ -1,4 +1,4 @@
define(['appSettings', 'jQuery', 'paper-slider', 'paper-button'], function (appSettings, $) {
define(['appSettings', 'datetime', 'jQuery', 'paper-slider', 'paper-button'], function (appSettings, datetime, $) {
function getDeviceProfile(serverAddress, deviceId, item, startPositionTicks, maxBitrate, mediaSourceId, audioStreamIndex, subtitleStreamIndex) {
@ -322,7 +322,7 @@
var time = item.RunTimeTicks * (Number(pct) * .01);
var tooltext = Dashboard.getDisplayTime(time);
var tooltext = datetime.getDisplayRunningTime(time);
$('.sliderValue', elem).html(tooltext);

View file

@ -1,4 +1,4 @@
define(['layoutManager', 'jQuery', 'scrollStyles'], function (layoutManager, $) {
define(['layoutManager', 'datetime', 'jQuery', 'scrollStyles'], function (layoutManager, datetime, $) {
var currentItem;
@ -1402,7 +1402,7 @@
html += '<div class="cardFooter">';
html += '<div class="cardText">' + chapterName + '</div>';
html += '<div class="cardText">';
html += Dashboard.getDisplayTime(chapter.StartPositionTicks);
html += datetime.getDisplayRunningTime(chapter.StartPositionTicks);
html += '</div>';
//cardFooter
@ -1639,7 +1639,7 @@
html += '<div class="cardText">' + item.Name + '</div>';
html += '<div class="cardText">';
if (item.RunTimeTicks != "") {
html += Dashboard.getDisplayTime(item.RunTimeTicks);
html += datetime.getDisplayRunningTime(item.RunTimeTicks);
}
else {
html += "&nbsp;";

View file

@ -3525,7 +3525,7 @@
if (item.Type == "Audio") {
miscInfo.push(Dashboard.getDisplayTime(item.RunTimeTicks));
miscInfo.push(datetime.getDisplayRunningTime(item.RunTimeTicks));
} else {
minutes = item.RunTimeTicks / 600000000;
@ -3538,7 +3538,7 @@
if (item.CumulativeRunTimeTicks && item.Type != "Series" && item.Type != "Season") {
miscInfo.push(Dashboard.getDisplayTime(item.CumulativeRunTimeTicks));
miscInfo.push(datetime.getDisplayRunningTime(item.CumulativeRunTimeTicks));
}
if (item.OfficialRating && item.Type !== "Season" && item.Type !== "Episode") {

View file

@ -1,4 +1,4 @@
define(['appSettings', 'jQuery', 'scrollStyles'], function (appSettings, $) {
define(['appSettings', 'datetime', 'jQuery', 'scrollStyles'], function (appSettings, datetime, $) {
function createVideoPlayer(self) {
@ -495,7 +495,7 @@
if (c.Name) {
chapterHtml += '<div class="cardText">' + c.Name + '</div>';
}
chapterHtml += '<div class="cardText">' + Dashboard.getDisplayTime(c.StartPositionTicks) + '</div>';
chapterHtml += '<div class="cardText">' + datetime.getDisplayRunningTime(c.StartPositionTicks) + '</div>';
chapterHtml += '</div>';
chapterHtml += '</div>';
@ -789,7 +789,7 @@
ticks /= 100;
ticks *= value;
this.pinValue = Dashboard.getDisplayTime(ticks);
this.pinValue = datetime.getDisplayRunningTime(ticks);
};
volumeSlider = $('.videoVolumeSlider', parent).on('change', function () {

View file

@ -1,4 +1,4 @@
define(['appSettings', 'userSettings', 'appStorage'], function (appSettings, userSettings, appStorage) {
define(['appSettings', 'userSettings', 'appStorage', 'datetime'], function (appSettings, userSettings, appStorage, datetime) {
function mediaPlayer() {
@ -44,216 +44,6 @@ define(['appSettings', 'userSettings', 'appStorage'], function (appSettings, use
return targets;
};
function updateDeviceProfileForAndroid(profile) {
// Just here as an easy escape out, if ever needed
var enableVlcVideo = true;
var enableVlcAudio = window.VlcAudio;
if (enableVlcVideo) {
profile.DirectPlayProfiles.push({
Container: "m4v,3gp,ts,mpegts,mov,xvid,vob,mkv,wmv,asf,ogm,ogv,m2v,avi,mpg,mpeg,mp4,webm",
Type: 'Video',
AudioCodec: 'aac,aac_latm,mp3,ac3,wma,dca,pcm,PCM_S16LE,PCM_S24LE,opus,flac'
});
profile.CodecProfiles = profile.CodecProfiles.filter(function (i) {
return i.Type == 'Audio';
});
profile.SubtitleProfiles = [];
profile.SubtitleProfiles.push({
Format: 'srt',
Method: 'External'
});
profile.SubtitleProfiles.push({
Format: 'srt',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'subrip',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'ass',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'ssa',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'pgs',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'pgssub',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'dvdsub',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'vtt',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'sub',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'idx',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'smi',
Method: 'Embed'
});
// These don't play very well
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'dca',
Conditions: [
{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: 6
}
]
});
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac,mp3',
Conditions: [
{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: '6'
}
]
});
profile.CodecProfiles.push({
Type: 'Video',
Codec: 'h264',
Conditions: [
{
Condition: 'EqualsAny',
Property: 'VideoProfile',
Value: 'high|main|baseline|constrained baseline'
},
{
Condition: 'LessThanEqual',
Property: 'VideoLevel',
Value: '41'
}]
});
profile.TranscodingProfiles.filter(function (p) {
return p.Type == 'Video' && p.CopyTimestamps == true;
}).forEach(function (p) {
// Vlc doesn't seem to handle this well
p.CopyTimestamps = false;
});
profile.TranscodingProfiles.filter(function (p) {
return p.Type == 'Video' && p.VideoCodec == 'h264';
}).forEach(function (p) {
p.AudioCodec += ',ac3';
});
}
if (enableVlcAudio) {
profile.DirectPlayProfiles.push({
Container: "aac,mp3,mpa,wav,wma,mp2,ogg,oga,webma,ape,opus",
Type: 'Audio'
});
profile.CodecProfiles = profile.CodecProfiles.filter(function (i) {
return i.Type != 'Audio';
});
profile.CodecProfiles.push({
Type: 'Audio',
Conditions: [{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: '2'
}]
});
}
}
function updateDeviceProfileForIOS(profile) {
}
self.getDeviceProfile = function (maxHeight) {
return new Promise(function (resolve, reject) {
require(['browserdeviceprofile', 'qualityoptions'], function (profileBuilder, qualityoptions) {
var supportsCustomSeeking = false;
if (!browserInfo.mobile) {
supportsCustomSeeking = true;
} else if (AppInfo.isNativeApp && browserInfo.safari) {
if (navigator.userAgent.toLowerCase().indexOf('ipad') == -1) {
// Need to disable it in order to support picture in picture
supportsCustomSeeking = true;
}
} else if (AppInfo.isNativeApp) {
supportsCustomSeeking = true;
}
var profile = profileBuilder({
supportsCustomSeeking: supportsCustomSeeking
});
if (!(AppInfo.isNativeApp && browserInfo.android)) {
profile.SubtitleProfiles.push({
Format: 'ass',
Method: 'External'
});
profile.SubtitleProfiles.push({
Format: 'ssa',
Method: 'External'
});
}
var bitrateSetting = appSettings.maxStreamingBitrate();
if (!maxHeight) {
maxHeight = qualityoptions.getVideoQualityOptions(bitrateSetting).filter(function (q) {
return q.selected;
})[0].maxHeight;
}
if (AppInfo.isNativeApp && browserInfo.android) {
updateDeviceProfileForAndroid(profile);
}
else if (AppInfo.isNativeApp && browserInfo.safari) {
updateDeviceProfileForIOS(profile);
}
profile.MaxStreamingBitrate = bitrateSetting;
resolve(profile);
});
});
};
var supportsTextTracks;
self.supportsTextTracks = function () {
@ -378,7 +168,7 @@ define(['appSettings', 'userSettings', 'appStorage'], function (appSettings, use
var playSessionId = getParameterByName('PlaySessionId', currentSrc);
var liveStreamId = getParameterByName('LiveStreamId', currentSrc);
self.getDeviceProfile().then(function (deviceProfile) {
Dashboard.getDeviceProfile().then(function (deviceProfile) {
var audioStreamIndex = params.AudioStreamIndex == null ? (getParameterByName('AudioStreamIndex', currentSrc) || null) : params.AudioStreamIndex;
if (typeof (audioStreamIndex) == 'string') {
@ -481,12 +271,12 @@ define(['appSettings', 'userSettings', 'appStorage'], function (appSettings, use
// Convert to ticks
ticks = Math.floor(ticks);
var timeText = Dashboard.getDisplayTime(ticks);
var timeText = datetime.getDisplayRunningTime(ticks);
var mediaRenderer = self.currentMediaRenderer;
if (self.currentDurationTicks) {
timeText += " / " + Dashboard.getDisplayTime(self.currentDurationTicks);
timeText += " / " + datetime.getDisplayRunningTime(self.currentDurationTicks);
if (positionSlider) {
@ -864,7 +654,7 @@ define(['appSettings', 'userSettings', 'appStorage'], function (appSettings, use
}
var onBitrateDetected = function () {
self.getDeviceProfile().then(function (deviceProfile) {
Dashboard.getDeviceProfile().then(function (deviceProfile) {
playOnDeviceProfileCreated(deviceProfile, item, startPosition, callback);
});
};

View file

@ -1,4 +1,4 @@
define(['jQuery'], function ($) {
define(['datetime', 'jQuery'], function (datetime, $) {
var currentPlayer;
@ -247,7 +247,7 @@
ticks /= 100;
ticks *= value;
this.pinValue = Dashboard.getDisplayTime(ticks);
this.pinValue = datetime.getDisplayRunningTime(ticks);
};
}, 300);
}
@ -375,11 +375,11 @@
}
}
var timeText = Dashboard.getDisplayTime(playState.PositionTicks);
var timeText = datetime.getDisplayRunningTime(playState.PositionTicks);
if (nowPlayingItem.RunTimeTicks) {
timeText += " / " + Dashboard.getDisplayTime(nowPlayingItem.RunTimeTicks);
timeText += " / " + datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
}

View file

@ -1101,44 +1101,6 @@ var Dashboard = {
}
},
getDisplayTime: function (ticks) {
var ticksPerHour = 36000000000;
var ticksPerMinute = 600000000;
var ticksPerSecond = 10000000;
var parts = [];
var hours = ticks / ticksPerHour;
hours = Math.floor(hours);
if (hours) {
parts.push(hours);
}
ticks -= (hours * ticksPerHour);
var minutes = ticks / ticksPerMinute;
minutes = Math.floor(minutes);
ticks -= (minutes * ticksPerMinute);
if (minutes < 10 && hours) {
minutes = '0' + minutes;
}
parts.push(minutes);
var seconds = ticks / ticksPerSecond;
seconds = Math.floor(seconds);
if (seconds < 10) {
seconds = '0' + seconds;
}
parts.push(seconds);
return parts.join(':');
},
getSupportedRemoteCommands: function () {
// Full list
@ -1249,6 +1211,209 @@ var Dashboard = {
exit: function () {
Dashboard.logout();
},
getDeviceProfile: function (maxHeight) {
return new Promise(function (resolve, reject) {
function updateDeviceProfileForAndroid(profile) {
// Just here as an easy escape out, if ever needed
var enableVlcVideo = true;
var enableVlcAudio = window.VlcAudio;
if (enableVlcVideo) {
profile.DirectPlayProfiles.push({
Container: "m4v,3gp,ts,mpegts,mov,xvid,vob,mkv,wmv,asf,ogm,ogv,m2v,avi,mpg,mpeg,mp4,webm",
Type: 'Video',
AudioCodec: 'aac,aac_latm,mp3,ac3,wma,dca,pcm,PCM_S16LE,PCM_S24LE,opus,flac'
});
profile.CodecProfiles = profile.CodecProfiles.filter(function (i) {
return i.Type == 'Audio';
});
profile.SubtitleProfiles = [];
profile.SubtitleProfiles.push({
Format: 'srt',
Method: 'External'
});
profile.SubtitleProfiles.push({
Format: 'srt',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'subrip',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'ass',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'ssa',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'pgs',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'pgssub',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'dvdsub',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'vtt',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'sub',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'idx',
Method: 'Embed'
});
profile.SubtitleProfiles.push({
Format: 'smi',
Method: 'Embed'
});
// These don't play very well
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'dca',
Conditions: [
{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: 6
}
]
});
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac,mp3',
Conditions: [
{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: '6'
}
]
});
profile.CodecProfiles.push({
Type: 'Video',
Codec: 'h264',
Conditions: [
{
Condition: 'EqualsAny',
Property: 'VideoProfile',
Value: 'high|main|baseline|constrained baseline'
},
{
Condition: 'LessThanEqual',
Property: 'VideoLevel',
Value: '41'
}]
});
profile.TranscodingProfiles.filter(function (p) {
return p.Type == 'Video' && p.CopyTimestamps == true;
}).forEach(function (p) {
// Vlc doesn't seem to handle this well
p.CopyTimestamps = false;
});
profile.TranscodingProfiles.filter(function (p) {
return p.Type == 'Video' && p.VideoCodec == 'h264';
}).forEach(function (p) {
p.AudioCodec += ',ac3';
});
}
if (enableVlcAudio) {
profile.DirectPlayProfiles.push({
Container: "aac,mp3,mpa,wav,wma,mp2,ogg,oga,webma,ape,opus",
Type: 'Audio'
});
profile.CodecProfiles = profile.CodecProfiles.filter(function (i) {
return i.Type != 'Audio';
});
profile.CodecProfiles.push({
Type: 'Audio',
Conditions: [{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: '2'
}]
});
}
}
require(['browserdeviceprofile', 'qualityoptions', 'appSettings'], function (profileBuilder, qualityoptions, appSettings) {
var supportsCustomSeeking = false;
if (!browserInfo.mobile) {
supportsCustomSeeking = true;
} else if (AppInfo.isNativeApp && browserInfo.safari) {
if (navigator.userAgent.toLowerCase().indexOf('ipad') == -1) {
// Need to disable it in order to support picture in picture
supportsCustomSeeking = true;
}
} else if (AppInfo.isNativeApp) {
supportsCustomSeeking = true;
}
var profile = profileBuilder({
supportsCustomSeeking: supportsCustomSeeking
});
if (!(AppInfo.isNativeApp && browserInfo.android)) {
profile.SubtitleProfiles.push({
Format: 'ass',
Method: 'External'
});
profile.SubtitleProfiles.push({
Format: 'ssa',
Method: 'External'
});
}
var bitrateSetting = appSettings.maxStreamingBitrate();
if (!maxHeight) {
maxHeight = qualityoptions.getVideoQualityOptions(bitrateSetting).filter(function (q) {
return q.selected;
})[0].maxHeight;
}
if (AppInfo.isNativeApp && browserInfo.android) {
updateDeviceProfileForAndroid(profile);
}
profile.MaxStreamingBitrate = bitrateSetting;
resolve(profile);
});
});
}
};
@ -1377,9 +1542,7 @@ var AppInfo = {};
function getSyncProfile() {
return getRequirePromise(['scripts/mediaplayer']).then(function () {
return MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width));
});
return Dashboard.getDeviceProfile(Math.max(screen.height, screen.width));
}
function onApiClientCreated(e, newApiClient) {