From 4f084bad1c25c43511def430a3a21c7d2e6eb7d2 Mon Sep 17 00:00:00 2001 From: Tyler W <19383474+leftl@users.noreply.github.com> Date: Wed, 11 Sep 2019 20:40:21 +0000 Subject: [PATCH] Add media file size to Playback Data (#439) * Add media file size to Playback Data * change file units to base-2 and fix output will also remove any trailing zeros from decimal. * Fix file size unit * add i18n files and strings to dialog, fix conflict --- src/components/playerstats/playerstats.js | 54 +++++++++++++++-------- src/strings/en-us.json | 13 ++++++ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/components/playerstats/playerstats.js b/src/components/playerstats/playerstats.js index d395d609c4..5e097f2fe2 100644 --- a/src/components/playerstats/playerstats.js +++ b/src/components/playerstats/playerstats.js @@ -132,7 +132,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth if (videoCodec) { sessionStats.push({ - label: 'Video codec:', + label: globalize.translate("LabelVideoCodec"), value: session.TranscodingInfo.IsVideoDirect ? (videoCodec.toUpperCase() + ' (direct)') : videoCodec.toUpperCase() }); } @@ -140,7 +140,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth if (audioCodec) { sessionStats.push({ - label: 'Audio codec:', + label: globalize.translate("LabelAudioCodec"), value: session.TranscodingInfo.IsAudioDirect ? (audioCodec.toUpperCase() + ' (direct)') : audioCodec.toUpperCase() }); } @@ -157,28 +157,28 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth if (totalBitrate) { sessionStats.push({ - label: 'Bitrate:', + label: globalize.translate("LabelBitrate"), value: getDisplayBitrate(totalBitrate) }); } if (session.TranscodingInfo.CompletionPercentage) { sessionStats.push({ - label: 'Transcoding progress:', + label: globalize.translate("LabelTranscodingProgress"), value: session.TranscodingInfo.CompletionPercentage.toFixed(1) + '%' }); } if (session.TranscodingInfo.Framerate) { sessionStats.push({ - label: 'Transcoding framerate:', + label: globalize.translate("LabelTranscodingFramerate"), value: session.TranscodingInfo.Framerate + ' fps' }); } if (session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length) { sessionStats.push({ - label: 'Reason for transcoding:', + label: globalize.translate("LabelReasonForTranscoding"), value: session.TranscodingInfo.TranscodeReasons.map(translateReason).join('
') }); } @@ -196,24 +196,42 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth } } + function getReadableSize(size) { + if (size >= 1073741824) { + return parseFloat((size / 1073741824).toFixed(1)) + ' GiB'; + } else if (size >= 1048576) { + return parseFloat((size / 1048576).toFixed(1)) + ' MiB'; + } else { + return Math.floor(size / 1024) + ' KiB'; + } + } + function getMediaSourceStats(session, player, displayPlayMethod) { var sessionStats = []; var mediaSource = playbackManager.currentMediaSource(player) || {}; var totalBitrate = mediaSource.Bitrate; + var mediaFileSize = mediaSource.Size; if (mediaSource.Container) { sessionStats.push({ - label: 'Container:', + label: globalize.translate("LabelProfileContainer"), value: mediaSource.Container }); } + if (mediaFileSize) { + sessionStats.push({ + label: globalize.translate("LabelSize"), + value: getReadableSize(mediaFileSize) + }); + } + if (totalBitrate) { sessionStats.push({ - label: 'Bitrate:', + label: globalize.translate("LabelBitrate"), value: getDisplayBitrate(totalBitrate) }); } @@ -249,14 +267,14 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth if (videoInfos.length) { sessionStats.push({ - label: 'Video codec:', + label: globalize.translate("LabelVideoCodec"), value: videoInfos.join(' ') }); } if (videoStream.BitRate) { sessionStats.push({ - label: 'Video bitrate:', + label: globalize.translate("LabelVideoBitrate"), value: getDisplayBitrate(videoStream.BitRate) }); } @@ -273,35 +291,35 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth if (audioInfos.length) { sessionStats.push({ - label: 'Audio codec:', + label: globalize.translate("LabelAudioCodec"), value: audioInfos.join(' ') }); } if (audioStream.BitRate) { sessionStats.push({ - label: 'Audio bitrate:', + label: globalize.translate("LabelAudioBitrate"), value: getDisplayBitrate(audioStream.BitRate) }); } if (audioChannels) { sessionStats.push({ - label: 'Audio channels:', + label: globalize.translate("LabelAudioChannels"), value: audioChannels }); } if (audioStream.SampleRate) { sessionStats.push({ - label: 'Audio sample rate:', + label: globalize.translate("LabelAudioSampleRate"), value: audioStream.SampleRate + ' Hz' }); } if (audioStream.BitDepth) { sessionStats.push({ - label: 'Audio bit depth:', + label: globalize.translate("LabelAudioBitDepth"), value: audioStream.BitDepth }); } @@ -328,12 +346,12 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth }; baseCategory.stats.unshift({ - label: 'Play method:', + label: globalize.translate("LabelPlayMethod"), value: displayPlayMethod }); baseCategory.stats.unshift({ - label: 'Player:', + label: globalize.translate("LabelPlayer"), value: player.name }); @@ -463,4 +481,4 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'playMeth }; return PlayerStats; -}); \ No newline at end of file +}); diff --git a/src/strings/en-us.json b/src/strings/en-us.json index aa648bd56d..e44311ff8f 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -551,13 +551,19 @@ "LabelArtists": "Artists:", "LabelArtistsHelp": "Separate multiple using ;", "LabelAudio": "Audio:", + "LabelAudioBitDepth": "Audio bit depth:", + "LabelAudioBitrate": "Audio bitrate:", + "LabelAudioChannels": "Audio channels:", + "LabelAudioCodec": "Audio codec:", "LabelAudioLanguagePreference": "Preferred audio language:", + "LabelAudioSampleRate": "Audio sample rate:", "LabelAuthProvider": "Authentication Provider:", "LabelAutomaticallyRefreshInternetMetadataEvery": "Automatically refresh metadata from the internet:", "LabelBindToLocalNetworkAddress": "Bind to local network address:", "LabelBindToLocalNetworkAddressHelp": "Optional. Override the local IP address to bind the http server to. If left empty, the server will bind to all availabile addresses. Changing this value requires restarting Jellyfin Server.", "LabelBirthDate": "Birth date:", "LabelBirthYear": "Birth year:", + "LabelBitrate": "Bitrate:", "LabelBlastMessageInterval": "Alive message interval (seconds)", "LabelBlastMessageIntervalHelp": "Determines the duration in seconds between server alive messages.", "LabelBlockContentWithTags": "Block items with tags:", @@ -755,7 +761,9 @@ "LabelPersonRoleHelp": "Example: Ice cream truck driver", "LabelPlaceOfBirth": "Place of birth:", "LabelPlayDefaultAudioTrack": "Play default audio track regardless of language", + "LabelPlayer": "Player:", "LabelPlaylist": "Playlist:", + "LabelPlayMethod": "Play method:", "LabelPostProcessor": "Post-processing application:", "LabelPostProcessorArguments": "Post-processor command line arguments:", "LabelPostProcessorArgumentsHelp": "Use {path} as the path to the recording file.", @@ -804,6 +812,7 @@ "LabelServerName": "Server name:", "LabelServerPort": "Port:", "LabelSimultaneousConnectionLimit": "Simultaneous stream limit:", + "LabelSize": "Size:", "LabelSkin": "Skin:", "LabelSkipBackLength": "Skip back length:", "LabelSkipForwardLength": "Skip forward length:", @@ -845,6 +854,8 @@ "LabelTranscodePath": "Transcode path:", "LabelTranscodingTempPathHelp": "This folder contains working files used by the transcoder. Specify a custom path, or leave empty to use the default within the server's data folder.", "LabelTranscodes": "Transcodes:", + "LabelTranscodingFramerate": "Transcoding framerate:", + "LabelTranscodingProgress": "Transcoding progress:", "LabelTranscodingThreadCount": "Transcoding thread count:", "LabelTranscodingThreadCountHelp": "Select the maximum number of threads to use when transcoding. Reducing the thread count will lower cpu usage but may not convert fast enough for a smooth playback experience.", "LabelTranscodingVideoCodec": "Video codec:", @@ -872,6 +883,8 @@ "DashboardOperatingSystem": "Operating System: {0}", "DashboardArchitecture": "Architecture: {0}", "LabelVideo": "Video:", + "LabelVideoBitrate": "Video bitrate:", + "LabelVideoCodec": "Video codec:", "LabelWeb": "Web: ", "LabelXDlnaCap": "X-Dlna cap:", "LabelXDlnaCapHelp": "Determines the content of the X_DLNACAP element in the urn:schemas-dlna-org:device-1-0 namespace.",