2020-05-04 12:44:12 +02:00
|
|
|
define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings', 'connectionManager', 'loading', 'focusManager', 'dom', 'apphost', 'emby-select', 'listViewStyle', 'paper-icon-button-light', 'css!./../formdialog', 'material-icons', 'emby-button', 'flexStyles'], function (dialogHelper, require, layoutManager, globalize, userSettings, connectionManager, loading, focusManager, dom, appHost) {
|
|
|
|
'use strict';
|
2019-08-19 12:35:57 +03:00
|
|
|
|
|
|
|
function setMediaInfo(user, page, item) {
|
|
|
|
var html = item.MediaSources.map(function (version) {
|
|
|
|
return getMediaSourceHtml(user, item, version);
|
|
|
|
}).join('<div style="border-top:1px solid #444;margin: 1em 0;"></div>');
|
|
|
|
if (item.MediaSources.length > 1) {
|
2020-05-04 12:44:12 +02:00
|
|
|
html = '<br/>' + html;
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
var mediaInfoContent = page.querySelector('#mediaInfoContent');
|
2019-08-19 12:35:57 +03:00
|
|
|
mediaInfoContent.innerHTML = html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMediaSourceHtml(user, item, version) {
|
2020-05-04 12:44:12 +02:00
|
|
|
var html = '';
|
2019-08-19 12:35:57 +03:00
|
|
|
if (version.Name) {
|
2020-05-04 12:44:12 +02:00
|
|
|
html += '<div><h2 class="mediaInfoStreamType">' + version.Name + '</h2></div>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (version.Container) {
|
2020-05-04 12:44:12 +02:00
|
|
|
html += createAttribute(globalize.translate('MediaInfoContainer'), version.Container) + '<br/>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (version.Formats && version.Formats.length) {
|
2020-05-04 12:44:12 +02:00
|
|
|
html += createAttribute(globalize.translate('MediaInfoFormat'), version.Formats.join(',')) + '<br/>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (version.Path && user && user.Policy.IsAdministrator) {
|
2020-05-04 12:44:12 +02:00
|
|
|
html += createAttribute(globalize.translate('MediaInfoPath'), version.Path) + '<br/>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2019-09-04 21:53:31 +03:00
|
|
|
if (version.Size) {
|
2020-05-04 12:44:12 +02:00
|
|
|
var size = (version.Size / (1024 * 1024)).toFixed(0) + ' MB';
|
|
|
|
html += createAttribute(globalize.translate('MediaInfoSize'), size) + '<br/>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
for (var i = 0, length = version.MediaStreams.length; i < length; i++) {
|
|
|
|
var stream = version.MediaStreams[i];
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.Type === 'Data') {
|
2019-08-19 12:35:57 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
html += '<div class="mediaInfoStream">';
|
2020-05-04 12:44:12 +02:00
|
|
|
var displayType = globalize.translate('MediaInfoStreamType' + stream.Type);
|
|
|
|
html += '<h2 class="mediaInfoStreamType">' + displayType + '</h2>';
|
2019-08-19 12:35:57 +03:00
|
|
|
var attributes = [];
|
|
|
|
if (stream.DisplayTitle) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute('Title', stream.DisplayTitle));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.Language && stream.Type !== 'Video') {
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoLanguage'), stream.Language));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.Codec) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoCodec'), stream.Codec.toUpperCase()));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.CodecTag) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoCodecTag'), stream.CodecTag));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.IsAVC != null) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute('AVC', (stream.IsAVC ? 'Yes' : 'No')));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.Profile) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoProfile'), stream.Profile));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.Level) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoLevel'), stream.Level));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.Width || stream.Height) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoResolution'), stream.Width + 'x' + stream.Height));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.AspectRatio && stream.Codec !== 'mjpeg') {
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoAspectRatio'), stream.AspectRatio));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.Type === 'Video') {
|
2019-08-19 12:35:57 +03:00
|
|
|
if (stream.IsAnamorphic != null) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoAnamorphic'), (stream.IsAnamorphic ? 'Yes' : 'No')));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoInterlaced'), (stream.IsInterlaced ? 'Yes' : 'No')));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.AverageFrameRate || stream.RealFrameRate) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoFramerate'), (stream.AverageFrameRate || stream.RealFrameRate)));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.ChannelLayout) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoLayout'), stream.ChannelLayout));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.Channels) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoChannels'), stream.Channels + ' ch'));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.BitRate && stream.Codec !== 'mjpeg') {
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoBitrate'), (parseInt(stream.BitRate / 1000)) + ' kbps'));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.SampleRate) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoSampleRate'), stream.SampleRate + ' Hz'));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.BitDepth) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoBitDepth'), stream.BitDepth + ' bit'));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.PixelFormat) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoPixelFormat'), stream.PixelFormat));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.RefFrames) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoRefFrames'), stream.RefFrames));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
if (stream.NalLengthSize) {
|
2020-05-04 12:44:12 +02:00
|
|
|
attributes.push(createAttribute('NAL', stream.NalLengthSize));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.Type !== 'Video') {
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoDefault'), (stream.IsDefault ? 'Yes' : 'No')));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.Type === 'Subtitle') {
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoForced'), (stream.IsForced ? 'Yes' : 'No')));
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoExternal'), (stream.IsExternal ? 'Yes' : 'No')));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
if (stream.Type === 'Video' && version.Timestamp) {
|
|
|
|
attributes.push(createAttribute(globalize.translate('MediaInfoTimestamp'), version.Timestamp));
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2020-05-04 12:44:12 +02:00
|
|
|
html += attributes.join('<br/>');
|
|
|
|
html += '</div>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createAttribute(label, value) {
|
2020-05-04 12:44:12 +02:00
|
|
|
return '<span class="mediaInfoLabel">' + label + '</span><span class="mediaInfoAttribute">' + value + '</span>';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showMediaInfoMore(itemId, serverId, template) {
|
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
|
|
|
var dialogOptions = {
|
2020-05-04 12:44:12 +02:00
|
|
|
size: 'small',
|
2019-08-19 12:35:57 +03:00
|
|
|
removeOnClose: true,
|
|
|
|
scrollY: false
|
|
|
|
};
|
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
dialogOptions.size = 'fullscreen';
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
var dlg = dialogHelper.createDialog(dialogOptions);
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.classList.add('formDialog');
|
|
|
|
var html = '';
|
|
|
|
html += globalize.translateDocument(template, 'core');
|
2019-08-19 12:35:57 +03:00
|
|
|
dlg.innerHTML = html;
|
|
|
|
if (layoutManager.tv) {
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.formDialogContent');
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
|
|
|
dialogHelper.open(dlg);
|
2020-05-04 12:44:12 +02:00
|
|
|
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
|
2019-08-19 12:35:57 +03:00
|
|
|
dialogHelper.close(dlg);
|
|
|
|
});
|
|
|
|
apiClient.getCurrentUser().then(function (user) {
|
|
|
|
setMediaInfo(user, dlg, item);
|
|
|
|
});
|
|
|
|
loading.hide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function showMediaInfo(itemId, serverId) {
|
|
|
|
loading.show();
|
|
|
|
return new Promise(function (resolve, reject) {
|
2020-05-04 12:44:12 +02:00
|
|
|
require(['text!./itemMediaInfo.template.html'], function (template) {
|
2019-08-19 12:35:57 +03:00
|
|
|
showMediaInfoMore(itemId, serverId, template).then(resolve, reject);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
show: showMediaInfo
|
|
|
|
};
|
|
|
|
});
|