added play buttons to song table

This commit is contained in:
Luke Pulverenti 2013-04-30 13:21:21 -04:00
parent 3dc52fabbc
commit 7d55230e20
5 changed files with 111 additions and 50 deletions

View File

@ -1,6 +1,6 @@
.detailTableContainer { .detailTableContainer {
width: 100%; width: 100%;
max-width: 1200px; max-width: 1100px;
text-align: center; text-align: center;
margin: 0 auto; margin: 0 auto;
} }

View File

@ -472,7 +472,7 @@
var item = items[i]; var item = items[i];
html += '<a class="posterItem backdropPosterItem" href="#" onclick="ItemDetailPage.playById(\'' + item.Id + '\');">'; html += '<a class="posterItem backdropPosterItem" href="#" onclick="MediaPlayer.playById(\'' + item.Id + '\');">';
var imageTags = item.ImageTags || {}; var imageTags = item.ImageTags || {};
@ -618,12 +618,6 @@
var self = this; var self = this;
self.play = play; self.play = play;
self.playById = function (id) {
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
MediaPlayer.play([item]);
});
};
} }
window.ItemDetailPage = new itemDetailPage(); window.ItemDetailPage = new itemDetailPage();

View File

@ -1,4 +1,4 @@
var LibraryBrowser = (function (window, $) { var LibraryBrowser = (function (window, document, $) {
var defaultBackground = "#999;"; var defaultBackground = "#999;";
@ -213,6 +213,7 @@
html += '<tr>'; html += '<tr>';
html += '<th></th>';
html += '<th></th>'; html += '<th></th>';
html += '<th>Track</th>'; html += '<th>Track</th>';
@ -236,6 +237,8 @@
html += '<tr>'; html += '<tr>';
html += '<td><button data-icon="play" data-mini="true" data-iconpos="notext" onclick="LibraryBrowser.showPlayMenu(this, \'' + item.Id + '\', \'Audio\');">Options</button></td>';
var num = item.IndexNumber; var num = item.IndexNumber;
if (num && item.ParentIndexNumber) { if (num && item.ParentIndexNumber) {
@ -281,6 +284,50 @@
return html; return html;
}, },
showPlayMenu: function (positionTo, itemId, mediaType, resumePositionTicks) {
var isPlaying = MediaPlayer.isPlaying();
if (!isPlaying && !resumePositionTicks) {
MediaPlayer.playById(itemId);
return;
}
$('.playFlyout').popup("close").remove();
var html = '<div data-role="popup" class="playFlyout" style="max-width:300px;" data-corners="false" data-theme="c" data-history="false">';
html += '<ul data-role="listview" style="min-width: 150px;" data-theme="c">';
html += '<li data-role="list-divider" data-theme="a">Play Menu</li>';
html += '<li><a href="#" onclick="MediaPlayer.playById(\'' + itemId + '\');LibraryBrowser.closePlayMenu();">Play</a></li>';
if (resumePositionTicks) {
html += '<li><a href="#" onclick="MediaPlayer.playById(\'' + itemId + '\', resumePositionTicks);LibraryBrowser.closePlayMenu();">Play</a></li>';
}
if (isPlaying && MediaPlayer.canQueue(mediaType)) {
html += '<li><a href="#" onclick="MediaPlayer.playNext(\'' + itemId + '\');LibraryBrowser.closePlayMenu();">Play Next</a></li>';
html += '<li><a href="#" onclick="MediaPlayer.playLast(\'' + itemId + '\');LibraryBrowser.closePlayMenu();">Play Last</a></li>';
}
html += '</ul>';
html += '</div>';
$($.mobile.activePage).append(html);
$('.playFlyout').popup({ positionTo: positionTo || "window" }).trigger('create').popup("open").on("popupafterclose", function () {
$(this).off("popupafterclose").remove();
}).parents(".ui-popup-container").css("margin-left", 100);
},
closePlayMenu: function () {
$('.playFlyout').popup("close").remove();
},
getHref: function (item, itemByNameContext) { getHref: function (item, itemByNameContext) {
if (item.url) { if (item.url) {
@ -1472,4 +1519,4 @@
}; };
})(window, jQuery); })(window, document, jQuery);

View File

@ -1,4 +1,4 @@
(function (document, clearTimeout, screen, localStorage, _V_, $, setInterval) { (function (document, clearTimeout, screen, localStorage, _V_, $, setInterval, window) {
function mediaPlayer() { function mediaPlayer() {
var self = this; var self = this;
@ -8,8 +8,7 @@
var currentMediaElement; var currentMediaElement;
var currentProgressInterval; var currentProgressInterval;
function playAudio(items, params) { function playAudio(item, params) {
var item = items[0];
var volume = localStorage.getItem("volume") || 0.5; var volume = localStorage.getItem("volume") || 0.5;
@ -84,12 +83,11 @@
}, 30000); }, 30000);
} }
function playVideo(items, startPosition) { function playVideo(item, startPosition) {
//stop/kill videoJS //stop/kill videoJS
if (currentMediaElement) self.stop(); if (currentMediaElement) self.stop();
var item = items[0];
// Account for screen rotation. Use the larger dimension as the width. // Account for screen rotation. Use the larger dimension as the width.
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);
@ -282,10 +280,10 @@
if (item.MediaType === "Video") { if (item.MediaType === "Video") {
mediaElement = playVideo(items, startPosition); mediaElement = playVideo(item, startPosition);
} else if (item.MediaType === "Audio") { } else if (item.MediaType === "Audio") {
mediaElement = playAudio(items); mediaElement = playAudio(item);
} }
if (!mediaElement) { if (!mediaElement) {
@ -357,6 +355,28 @@
$('#mediaInfo', nowPlayingBar).html(html); $('#mediaInfo', nowPlayingBar).html(html);
}; };
self.playById = function (id, startPositionTicks) {
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
self.play([item], startPositionTicks);
});
};
self.canQueue = function (mediaType) {
return mediaType == "Audio";
};
self.playLast = function(itemId) {
};
self.playNext = function (itemId) {
};
self.stop = function () { self.stop = function () {
var elem = currentMediaElement; var elem = currentMediaElement;
@ -411,7 +431,7 @@
if (currentProgressInterval) { if (currentProgressInterval) {
clearTimeout(currentProgressInterval); clearTimeout(currentProgressInterval);
} }
} };
self.stopAudio = function () { self.stopAudio = function () {
var itemString = $(".itemAudio source").attr('src').match(new RegExp("Audio/[0-9a-z\-]+", "g")); var itemString = $(".itemAudio source").attr('src').match(new RegExp("Audio/[0-9a-z\-]+", "g"));
@ -427,7 +447,7 @@
if (currentProgressInterval) { if (currentProgressInterval) {
clearTimeout(currentProgressInterval); clearTimeout(currentProgressInterval);
} }
} };
self.isPlaying = function () { self.isPlaying = function () {
return currentMediaElement; return currentMediaElement;
@ -436,4 +456,4 @@
window.MediaPlayer = new mediaPlayer(); window.MediaPlayer = new mediaPlayer();
})(document, clearTimeout, screen, localStorage, _V_, $, setInterval); })(document, clearTimeout, screen, localStorage, _V_, $, setInterval, window);

View File

@ -8,7 +8,7 @@
IncludeItemTypes: "Audio", IncludeItemTypes: "Audio",
Recursive: true, Recursive: true,
Fields: "ItemCounts,DateCreated,UserData,AudioInfo,ParentId", Fields: "ItemCounts,DateCreated,UserData,AudioInfo,ParentId",
Limit: 300, Limit: 200,
StartIndex: 0 StartIndex: 0
}; };