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

update chromecast

This commit is contained in:
Luke Pulverenti 2014-08-21 11:55:35 -04:00
parent f6995379a2
commit 3f09347bf7
8 changed files with 185 additions and 68 deletions

View file

@ -438,7 +438,7 @@
if (!mute) {
this.session.setReceiverVolumeLevel(vol || 1,
this.session.setReceiverVolumeLevel((vol || 1),
this.mediaCommandSuccessCallback.bind(this),
this.errorHandler);
}
@ -449,18 +449,6 @@
}
};
/**
* Toggle mute CC
*/
CastPlayer.prototype.toggleMute = function () {
if (this.audio == true) {
this.mute();
}
else {
this.unMute();
}
};
/**
* Mute CC
*/
@ -469,15 +457,6 @@
this.setReceiverVolume(true);
};
/**
* Unmute CC
*/
CastPlayer.prototype.unMute = function () {
this.audio = true;
this.setReceiverVolume(false);
};
/**
* media seek function in either Cast or local mode
* @param {Event} e An event object from seek
@ -684,11 +663,19 @@
};
self.unMute = function () {
castPlayer.unMute();
self.setVolume(getCurrentVolume() + 2);
};
self.toggleMute = function () {
castPlayer.toggleMute();
var state = self.lastPlayerData || {};
state = state.PlayState || {};
if (state.IsMuted) {
self.unMute();
} else {
self.mute();
}
};
self.getTargets = function () {
@ -724,7 +711,10 @@
"Mute",
"Unmute",
"ToggleMute",
"SetVolume"]
"SetVolume",
"SetAudioStreamIndex",
"SetSubtitleStreamIndex",
"DisplayContent"]
};
};
@ -732,6 +722,24 @@
castPlayer.seekMedia(position);
};
self.setAudioStreamIndex = function (index) {
castPlayer.sendMessage({
options: {
index: index
},
command: 'SetAudioStreamIndex'
});
};
self.setSubtitleStreamIndex = function (index) {
castPlayer.sendMessage({
options: {
index: index
},
command: 'SetSubtitleStreamIndex'
});
};
self.nextTrack = function () {
castPlayer.sendMessage({
options: {},

View file

@ -2,6 +2,7 @@
var currentItem;
var shape;
var currentItemsQuery;
function getPromise() {
@ -404,6 +405,8 @@
addCurrentItemToQuery(query);
currentItemsQuery = query;
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
var html = '';
@ -422,7 +425,8 @@
html = LibraryBrowser.getListViewHtml({
items: result.Items,
smallIcon: true
smallIcon: true,
playFromHere: true
});
}
@ -462,7 +466,8 @@
html = LibraryBrowser.getListViewHtml({
items: result.Items,
smallIcon: true
smallIcon: true,
playFromHere: true
});
}
@ -509,6 +514,16 @@
LibraryBrowser.showPlayMenu(this, currentItem.Id, currentItem.Type, false, "Audio", userdata.PlaybackPositionTicks);
});
$('.itemsContainer', page).on('playallfromhere', function (e, index) {
LibraryBrowser.playAllFromHere(currentItemsQuery, index);
}).on('queueallfromhere', function (e, index) {
LibraryBrowser.queueAllFromHere(currentItemsQuery, index);
});
}).on('pageshow', "#itemByNameDetailPage", function () {
var page = this;

View file

@ -92,6 +92,35 @@
return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds());
},
playAllFromHere: function (query, index) {
query = $.extend({}, query);
query.StartIndex = index;
query.Limit = 100;
query.Fields = "MediaSources,Chapters";
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
MediaController.play({
items: result.Items
});
});
},
queueAllFromHere: function (query, index) {
query = $.extend({}, query);
query.StartIndex = index;
query.Limit = 100;
query.Fields = "MediaSources,Chapters";
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
MediaController.queue({
items: result.Items
});
});
},
getItemCountsHtml: function (options, item) {
var counts = [];
@ -573,7 +602,7 @@
}
var href = LibraryBrowser.getHref(item, options.context);
html += '<li class="' + cssClass + '"' + dataAttributes + ' data-itemid="' + item.Id + '" data-playlistitemid="' + (item.PlaylistItemId || '') + '" data-href="' + href + '"><a href="' + href + '">';
html += '<li class="' + cssClass + '"' + dataAttributes + ' data-index="' + index + '" data-itemid="' + item.Id + '" data-playlistitemid="' + (item.PlaylistItemId || '') + '" data-href="' + href + '"><a href="' + href + '">';
var imgUrl;
@ -701,13 +730,13 @@
html += '</li>';
index++;
return html;
}).join('');
outerHtml += '</ul>';
index++;
return outerHtml;
},
@ -773,6 +802,11 @@
}
}
if (options.playFromHere) {
itemCommands.push('playfromhere');
itemCommands.push('queuefromhere');
}
return itemCommands;
},

View file

@ -133,6 +133,12 @@
return html;
}
function closeContextMenu() {
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
}
function onTrailerButtonClick() {
var id = this.getAttribute('data-itemid');
@ -141,8 +147,7 @@
MediaController.play({ items: trailers });
});
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
return false;
}
@ -151,8 +156,7 @@
var card = $(this).parents('.card')[0];
// Used by the tab menu
$('.tapHoldMenu').popup('close');
closeContextMenu();
showContextMenu(card, {
showPlayOptions: false
@ -165,36 +169,20 @@
var id = this.getAttribute('data-itemid');
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
PlaylistManager.showPanel([id]);
return false;
}
function onRemoveFromPlaylistButtonClick() {
var playlistItemId = this.getAttribute('data-playlistitemid');
var page = $(this).parents('.page');
$('.itemsContainer', page).trigger('removefromplaylist', [playlistItemId]);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onShuffleButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.shuffle(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
return false;
}
@ -205,8 +193,7 @@
MediaController.instantMix(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
return false;
}
@ -217,8 +204,7 @@
MediaController.queue(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
return false;
}
@ -229,8 +215,52 @@
MediaController.play(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
return false;
}
function onPlayAllFromHereButtonClick() {
var index = this.getAttribute('data-index');
var page = $(this).parents('.page');
var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer');
closeContextMenu();
itemsContainer.trigger('playallfromhere', [index]);
return false;
}
function onQueueAllFromHereButtonClick() {
var index = this.getAttribute('data-index');
var page = $(this).parents('.page');
var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer');
closeContextMenu();
itemsContainer.trigger('queueallfromhere', [index]);
return false;
}
function onRemoveFromPlaylistButtonClick() {
var playlistItemId = this.getAttribute('data-playlistitemid');
var page = $(this).parents('.page');
var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer');
itemsContainer.trigger('removefromplaylist', [playlistItemId]);
closeContextMenu();
return false;
}
@ -244,8 +274,7 @@
startPositionTicks: parseInt(this.getAttribute('data-ticks'))
});
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
closeContextMenu();
return false;
}
@ -260,7 +289,7 @@
function showContextMenu(card, options) {
$('.tapHoldMenu').popup("close").remove();
closeContextMenu();
var displayContextItem = card;
@ -277,6 +306,7 @@
var playAccess = card.getAttribute('data-playaccess');
var locationType = card.getAttribute('data-locationtype');
var isPlaceHolder = card.getAttribute('data-placeholder') == 'true';
var index = card.getAttribute('data-index');
$(card).addClass('hasContextMenu');
@ -297,8 +327,13 @@
}
if (options.showPlayOptions !== false) {
if (MediaController.canPlayByAttributes(itemType, mediaType, playAccess, locationType, isPlaceHolder)) {
html += '<li data-icon="play"><a href="#" class="btnPlay" data-itemid="' + itemId + '">' + Globalize.translate('ButtonPlay') + '</a></li>';
if (commands.indexOf('playfromhere') != -1) {
html += '<li data-icon="play"><a href="#" class="btnPlayAllFromHere" data-index="' + index + '">' + Globalize.translate('ButtonPlayAllFromHere') + '</a></li>';
}
}
if (playbackPositionTicks && mediaType != "Audio") {
@ -312,6 +347,10 @@
if (MediaController.canQueueMediaType(mediaType, itemType)) {
html += '<li data-icon="plus"><a href="#" class="btnQueue" data-itemid="' + itemId + '">' + Globalize.translate('ButtonQueue') + '</a></li>';
if (commands.indexOf('queuefromhere') != -1) {
html += '<li data-icon="plus"><a href="#" class="btnQueueAllFromHere" data-index="' + index + '">' + Globalize.translate('ButtonQueueAllFromHere') + '</a></li>';
}
}
if (commands.indexOf('instantmix') != -1) {
@ -350,6 +389,8 @@
$('.btnPlayTrailer', elem).on('click', onTrailerButtonClick);
$('.btnAddToPlaylist', elem).on('click', onAddToPlaylistButtonClick);
$('.btnRemoveFromPlaylist', elem).on('click', onRemoveFromPlaylistButtonClick);
$('.btnPlayAllFromHere', elem).on('click', onPlayAllFromHereButtonClick);
$('.btnQueueAllFromHere', elem).on('click', onQueueAllFromHereButtonClick);
});
}

View file

@ -9,10 +9,10 @@
MediaController.getCurrentPlayer().displayContent({
itemName: item.Name,
itemId: item.Id,
itemType: item.Type,
context: info.context
ItemName: item.Name,
ItemId: item.Id,
ItemType: item.Type,
Context: info.context
});
}

View file

@ -435,6 +435,7 @@
self.playlist = items;
currentPlaylistIndex = 0;
return;
}
ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/' + firstItem.Id + '/Intros')).done(function (intros) {

View file

@ -75,7 +75,8 @@
showIndex: false,
title: item.Name,
showRemoveFromPlaylist: true,
smallIcon: true
smallIcon: true,
playFromHere: true
});
}
@ -181,6 +182,24 @@
removeFromPlaylist(page, [playlistItemId]);
}).on('playallfromhere', function (e, index) {
LibraryBrowser.playAllFromHere({
Recursive: true,
ParentId: query.ParentId
}, index);
}).on('queueallfromhere', function (e, index) {
LibraryBrowser.queueAllFromHere({
Recursive: true,
ParentId: query.ParentId
}, index);
});
}).on('pagebeforeshow', "#playlistEditorPage", function () {

View file

@ -1274,14 +1274,13 @@ $(document).on('pagebeforeshow', ".page", function () {
var page = $(this);
var userId = Dashboard.getCurrentUserId();
if (userId) {
if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) {
Dashboard.getCurrentUser().done(function (user) {
if (!user.Configuration.IsAdministrator && page.hasClass('type-interior') && !page.hasClass('publicUserPage')) {
window.location.replace("index.html");
return;
}
Dashboard.ensureToolsMenu(page, user);