display video backdrops on detail page

This commit is contained in:
Luke Pulverenti 2013-04-28 13:21:56 -04:00
parent 461ed8c2b2
commit 7c43c7858a
5 changed files with 103 additions and 92 deletions

View File

@ -1733,6 +1733,35 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
}); });
}; };
self.getVideoBackdrops = function (userId, itemId) {
if (!userId) {
throw new Error("null userId");
}
if (!itemId) {
throw new Error("null itemId");
}
var url = self.getUrl("Users/" + userId + "/Items/" + itemId + "/VideoBackdrops");
return self.ajax({
type: "GET",
url: url,
dataType: "json"
});
};
self.getSearchHints = function (options) {
var url = self.getUrl("Search/Hints", options);
return self.ajax({
type: "GET",
url: url,
dataType: "json"
});
};
/** /**
* Gets special features for an item * Gets special features for an item
*/ */

View File

@ -170,6 +170,12 @@
<div id="scenesContent"></div> <div id="scenesContent"></div>
</div> </div>
</div> </div>
<div>
<div data-role="collapsible" id="videoBackdropsCollapsible" style="display: none;" data-mini="true" data-collapsed="false" data-corners="false">
<h3>Video Backdrops</h3>
<div id="videoBackdropsContent"></div>
</div>
</div>
</div> </div>
<div data-role="popup" id="playMenu" data-corners="false" data-theme="c"> <div data-role="popup" id="playMenu" data-corners="false" data-theme="c">

View File

@ -221,10 +221,15 @@
} }
$('#themeSongsCollapsible', page).hide(); $('#themeSongsCollapsible', page).hide();
$('#videoBackdropsCollapsible', page).hide();
ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) { ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
renderThemeSongs(page, item, result); renderThemeSongs(page, item, result);
}); });
ApiClient.getVideoBackdrops(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
renderVideoBackdrops(page, item, result);
});
} }
function renderDetails(page, item, context) { function renderDetails(page, item, context) {
@ -310,6 +315,16 @@
} }
} }
function renderVideoBackdrops(page, item, result) {
if (result.Items.length) {
$('#videoBackdropsCollapsible', page).show();
$('#videoBackdropsContent', page).html(getVideosHtml(result.Items)).trigger('create');
}
}
function renderScenes(page, item) { function renderScenes(page, item) {
var html = ''; var html = '';
@ -446,23 +461,22 @@
$('#mediaInfoContent', page).html(html).trigger('create'); $('#mediaInfoContent', page).html(html).trigger('create');
} }
function renderSpecials(page, item) { function getVideosHtml(items) {
var html = ''; var html = '';
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), item.Id).done(function (specials) { for (var i = 0, length = items.length; i < length; i++) {
for (var i = 0, length = specials.length; i < length; i++) { var item = items[i];
var special = specials[i];
html += '<div class="posterViewItem posterViewItemWithDualText">'; html += '<div class="posterViewItem posterViewItemWithDualText">';
html += '<a href="#play-Special-' + i + '" onclick="ItemDetailPage.playSpecial(' + i + ');">'; html += '<a href="#" onclick="ItemDetailPage.playById(\'' + item.Id + '\');">';
var imageTags = special.ImageTags || {}; var imageTags = item.ImageTags || {};
if (imageTags.Primary) { if (imageTags.Primary) {
var imgUrl = ApiClient.getImageUrl(special.Id, { var imgUrl = ApiClient.getImageUrl(item.Id, {
maxwidth: 500, maxwidth: 500,
tag: imageTags.Primary, tag: imageTags.Primary,
type: "primary" type: "primary"
@ -473,11 +487,11 @@
html += '<img src="css/images/items/detail/video.png"/>'; html += '<img src="css/images/items/detail/video.png"/>';
} }
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + special.Name + '</div>'; html += '<div class="posterViewItemText posterViewItemPrimaryText">' + item.Name + '</div>';
html += '<div class="posterViewItemText">'; html += '<div class="posterViewItemText">';
if (special.RunTimeTicks != "") { if (item.RunTimeTicks != "") {
html += ticks_to_human(special.RunTimeTicks); html += ticks_to_human(item.RunTimeTicks);
} }
else { else {
html += "&nbsp;"; html += "&nbsp;";
@ -489,55 +503,23 @@
html += '</div>'; html += '</div>';
} }
$('#specialsContent', page).html(html); return html;
}
function renderSpecials(page, item) {
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), item.Id).done(function (specials) {
$('#specialsContent', page).html(getVideosHtml(specials));
}); });
} }
function renderTrailers(page, item) { function renderTrailers(page, item) {
var html = '';
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), item.Id).done(function (trailers) { ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), item.Id).done(function (trailers) {
for (var i = 0, length = trailers.length; i < length; i++) { $('#trailersContent', page).html(getVideosHtml(trailers));
var trailer = trailers[i];
html += '<div class="posterViewItem posterViewItemWithDualText">';
html += '<a href="#play-Trailer-' + i + '" onclick="ItemDetailPage.playTrailer(' + i + ');">';
var imageTags = trailer.ImageTags || {};
if (imageTags.Primary) {
var imgUrl = ApiClient.getImageUrl(trailer.Id, {
maxwidth: 500,
tag: imageTags.Primary,
type: "primary"
});
html += '<img src="' + imgUrl + '" />';
} else {
html += '<img src="css/images/items/detail/video.png"/>';
}
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + trailer.Name + '</div>';
html += '<div class="posterViewItemText">';
if (trailer.RunTimeTicks != "") {
html += ticks_to_human(trailer.RunTimeTicks);
}
else {
html += "&nbsp;";
}
html += '</div>';
html += '</a>';
html += '</div>';
}
$('#trailersContent', page).html(html);
}); });
} }
@ -633,15 +615,9 @@
self.play = play; self.play = play;
self.playTrailer = function (index) { self.playById = function (id) {
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), currentItem.Id).done(function (trailers) { ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
MediaPlayer.play([trailers[index]]); MediaPlayer.play([item]);
});
};
self.playSpecial = function (index) {
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), currentItem.Id).done(function (specials) {
MediaPlayer.play([specials[index]]);
}); });
}; };
} }

View File

@ -64,7 +64,7 @@
var currentTimeout = searchHintTimeout; var currentTimeout = searchHintTimeout;
$.getJSON(ApiClient.getUrl("Search/Hints", { userId: Dashboard.getCurrentUserId(), searchTerm: searchTerm, limit: 10 })).done(function (result) { ApiClient.getSearchHints(ApiClient.getUrl({ userId: Dashboard.getCurrentUserId(), searchTerm: searchTerm, limit: 10 })).done(function (result) {
if (currentTimeout != searchHintTimeout) { if (currentTimeout != searchHintTimeout) {
return; return;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.86" targetFramework="net45" /> <package id="MediaBrowser.ApiClient.Javascript" version="3.0.87" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
</packages> </packages>