Song information over Webserver
This commit is contained in:
1 parent
197f003211
commit
fb0308b8d8
8 files changed
+172
-26
No files matched your search
@@ -43,7 +43,6 @@ namespace ClientServerLib
|
||||
set { CServer.getProfileList = value; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region photo
|
||||
@@ -69,13 +68,28 @@ namespace ClientServerLib
|
||||
|
||||
#region songs
|
||||
|
||||
private static GetCurrentSongDelegate getCurrentSong;
|
||||
public static GetCurrentSongDelegate GetCurrentSong
|
||||
private static GetSongDelegate getSong;
|
||||
public static GetSongDelegate GetSong
|
||||
{
|
||||
internal get { return CServer.getCurrentSong; }
|
||||
set { CServer.getCurrentSong = value; }
|
||||
internal get { return CServer.getSong; }
|
||||
set { CServer.getSong = value; }
|
||||
}
|
||||
|
||||
private static GetAllSongsDelegate getAllSongs;
|
||||
public static GetAllSongsDelegate GetAllSongs
|
||||
{
|
||||
get { return CServer.getAllSongs; }
|
||||
set { CServer.getAllSongs = value; }
|
||||
}
|
||||
|
||||
private static GetCurrentSongIdDelegate getCurrentSongId;
|
||||
public static GetCurrentSongIdDelegate GetCurrentSongId
|
||||
{
|
||||
get { return CServer.getCurrentSongId; }
|
||||
set { CServer.getCurrentSongId = value; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public CServer(int port)
|
||||
|
||||
@@ -90,8 +90,20 @@ namespace ClientServerLib
|
||||
[OperationContract]
|
||||
[WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "/getCurrentSong")]
|
||||
SongInfo getCurrentSong();
|
||||
UriTemplate = "/getSong?songId={songId}")]
|
||||
SongInfo getSong(int songId);
|
||||
|
||||
[OperationContract]
|
||||
[WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "/getCurrentSongId")]
|
||||
int getCurrentSongId();
|
||||
|
||||
[OperationContract]
|
||||
[WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "/getAllSongs")]
|
||||
SongInfo[] getAllSongs();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -249,11 +261,22 @@ namespace ClientServerLib
|
||||
|
||||
#region songs
|
||||
|
||||
public SongInfo getCurrentSong()
|
||||
public SongInfo getSong(int songId)
|
||||
{
|
||||
return CServer.GetCurrentSong();
|
||||
return CServer.GetSong(songId);
|
||||
}
|
||||
|
||||
public int getCurrentSongId()
|
||||
{
|
||||
return CServer.GetCurrentSongId();
|
||||
}
|
||||
|
||||
public SongInfo[] getAllSongs()
|
||||
{
|
||||
return CServer.GetAllSongs();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
|
||||
namespace ClientServerLib
|
||||
{
|
||||
public delegate bool SendKeyEventDelegate(string key);
|
||||
|
||||
|
||||
|
||||
#region profile
|
||||
|
||||
@@ -93,7 +93,11 @@ namespace ClientServerLib
|
||||
|
||||
#region songs
|
||||
|
||||
public delegate SongInfo GetCurrentSongDelegate();
|
||||
public delegate SongInfo GetSongDelegate(int songId);
|
||||
|
||||
public delegate SongInfo[] GetAllSongsDelegate();
|
||||
|
||||
public delegate int GetCurrentSongIdDelegate();
|
||||
|
||||
[DataContract]
|
||||
public struct SongInfo
|
||||
@@ -112,6 +116,8 @@ namespace ClientServerLib
|
||||
public string Year { get; set; }
|
||||
[DataMember]
|
||||
public bool IsDuet { get; set; }
|
||||
[DataMember]
|
||||
public int SongId { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -60,7 +60,9 @@ namespace Vocaluxe.Base.Server
|
||||
CServer.GetProfileList = getProfileList;
|
||||
CServer.SendPhoto = sendPhoto;
|
||||
CServer.GetSiteFile = getSiteFile;
|
||||
CServer.GetCurrentSong = getCurrentSong;
|
||||
CServer.GetSong = getSong;
|
||||
CServer.GetAllSongs = getAllSongs;
|
||||
CServer.GetCurrentSongId = getCurrentSongId;
|
||||
|
||||
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
|
||||
Controller.Init();
|
||||
@@ -328,10 +330,32 @@ namespace Vocaluxe.Base.Server
|
||||
|
||||
#region songs
|
||||
|
||||
private static SongInfo getCurrentSong()
|
||||
private static SongInfo getSong(int songId)
|
||||
{
|
||||
CSong song = CSongs.GetSong(songId);
|
||||
return getSongInfo(song, true);
|
||||
}
|
||||
|
||||
private static SongInfo[] getAllSongs()
|
||||
{
|
||||
var songs = CSongs.Songs;
|
||||
return (from s in songs
|
||||
select getSongInfo(s, false)).ToArray<SongInfo>();
|
||||
}
|
||||
|
||||
private static int getCurrentSongId()
|
||||
{
|
||||
CSong song = CGame.GetSong();
|
||||
if (song == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return song.ID;
|
||||
}
|
||||
|
||||
private static SongInfo getSongInfo(CSong song, bool includeCover)
|
||||
{
|
||||
SongInfo result = new SongInfo();
|
||||
CSong song = CGame.GetSong();
|
||||
if (song != null)
|
||||
{
|
||||
result.Title = song.Title;
|
||||
@@ -340,8 +364,12 @@ namespace Vocaluxe.Base.Server
|
||||
result.Language = song.Language.FirstOrDefault();
|
||||
result.Year = song.Year;
|
||||
result.IsDuet = song.IsDuet;
|
||||
Image cover = Image.FromFile(song.Folder + "\\" + song.CoverFileName);
|
||||
result.Cover = new Base64Image(cover, cover.RawFormat);
|
||||
result.SongId = song.ID;
|
||||
if (includeCover)
|
||||
{
|
||||
Image cover = Image.FromFile(song.Folder + "\\" + song.CoverFileName);
|
||||
result.Cover = new Base64Image(cover, cover.RawFormat);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -175,10 +175,6 @@
|
||||
<HintPath>..\Output\AForge.Video.DirectShow.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ClientServerLib">
|
||||
<HintPath>..\ClientServerLib\ClientServerLib\bin\ClientServerLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Community.CsharpSqlite">
|
||||
<HintPath>..\Output\Community.CsharpSqlite.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -350,6 +346,9 @@
|
||||
<Content Include="Website\img\noCover.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Website\img\playlist.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Website\index.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -42,12 +42,19 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="A1" href="#displaySong" data-transition="slidefade">
|
||||
<a id="currentSongLink" href="#" data-transition="slidefade">
|
||||
<img src="img/music.png">
|
||||
<h2>Current Song</h2>
|
||||
<p>Display informations about the current song</p>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#selectSong" data-transition="slidefade">
|
||||
<img src="img/playlist.png">
|
||||
<h2>All songs</h2>
|
||||
<p>List all available songs</p>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#selectProfile" data-transition="slidefade">
|
||||
<img src="img/profiles.png">
|
||||
@@ -154,6 +161,18 @@
|
||||
</div>
|
||||
<!-- /page -->
|
||||
|
||||
<div id="selectSong" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||
<div data-role="header">
|
||||
<h1>All songs</h1>
|
||||
</div>
|
||||
<!-- /header -->
|
||||
|
||||
<div id="selectSongContent" data-role="content">
|
||||
<ul id="selectSongList" data-role="listview" data-filter="true" data-autodividers="true"></ul>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
<!-- /page -->
|
||||
|
||||
<div id="keyboard" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||
<div data-role="header">
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
var ownProfileId = 1;
|
||||
var profileIdRequest = 1;
|
||||
var ownProfileId = -1;
|
||||
var profileIdRequest = -1;
|
||||
var songIdRequest = -1
|
||||
var allSongsCache = null;
|
||||
|
||||
$(document).ready(function () {
|
||||
replaceTransitionHandler();
|
||||
@@ -135,7 +137,7 @@ function initPageLoadHandler() {
|
||||
//pageLoadHandler for displaySong
|
||||
$(document).on('pagebeforeshow', '#displaySong', function () {
|
||||
var promise = $.ajax({
|
||||
url: "getCurrentSong"
|
||||
url: "getSong?songId=" + songIdRequest
|
||||
}).done(function (result) {
|
||||
if (result.Title != null) {
|
||||
$('#displaySongTitle').text(result.Title);
|
||||
@@ -178,13 +180,48 @@ function initPageLoadHandler() {
|
||||
else {
|
||||
$('#displaySongLanguage').text("-");
|
||||
}
|
||||
|
||||
$('#displaySongIsDuet').text(result.IsDuet?"Yes":"No");
|
||||
|
||||
$('#displaySongIsDuet').text(result.IsDuet ? "Yes" : "No");
|
||||
});
|
||||
|
||||
// Save promise on page so the transition handler can find it.
|
||||
$(this).data('promise', promise);
|
||||
});
|
||||
|
||||
//pageLoadHandler for selectSong
|
||||
$(document).on('pagebeforeshow', '#selectSong', function () {
|
||||
function handleGetAllSongs() {
|
||||
$('#selectSongList').children().remove();
|
||||
|
||||
function handleSelectSongLineClick(e) {
|
||||
songIdRequest = parseInt(e.currentTarget.id.replace("selectSongLine_", ""));
|
||||
$.mobile.changePage("#displaySong", { transition: "slidefade" });
|
||||
}
|
||||
|
||||
for (var id in allSongsCache) {
|
||||
$('<li id="selectSongLine_' + allSongsCache[id].SongId + '"> <a href="#"> '/*+'<img src="' + ((data[profile].Avatar && data[profile].Avatar.base64Data) ? data[id].Avatar.base64Data : "img/profile.png") + '"> '*/ + ' <h2>' + allSongsCache[id].Artist + '</h2> <p>' + allSongsCache[id].Title + '</p> </a> </li>')
|
||||
.appendTo('#selectSongList')
|
||||
.click(handleSelectSongLineClick);
|
||||
}
|
||||
|
||||
$('#selectSongList').listview('refresh');
|
||||
}
|
||||
|
||||
if (allSongsCache == null) {
|
||||
var promise = $.ajax({
|
||||
url: "getAllSongs"
|
||||
}).done(function (data) {
|
||||
allSongsCache = data;
|
||||
handleGetAllSongs()
|
||||
});
|
||||
|
||||
// Save promise on page so the transition handler can find it.
|
||||
$(this).data('promise', promise);
|
||||
}
|
||||
else {
|
||||
handleGetAllSongs()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initLoginPageHandler() {
|
||||
@@ -202,6 +239,26 @@ function initMainPageHandler() {
|
||||
$.mobile.changePage("#displayProfile", { transition: "slidefade" });
|
||||
});
|
||||
|
||||
$('#currentSongLink').click(function () {
|
||||
$('#content').wrap('<div class="overlay" />');
|
||||
$.mobile.loading('show', {
|
||||
text: 'Getting current song...',
|
||||
textVisible: true
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "getCurrentSongId"
|
||||
}).done(function (result) {
|
||||
songIdRequest = parseInt(result);
|
||||
$.mobile.loading('hide');
|
||||
$('#content').unwrap();
|
||||
$.mobile.changePage("#displaySong", { transition: "slidefade" });
|
||||
}).fail(function (result) {
|
||||
$.mobile.loading('hide');
|
||||
$('#content').unwrap();
|
||||
});
|
||||
});
|
||||
|
||||
$('#mainPageTakePhotoLink').click(function () {
|
||||
if ($('#captureContainer').length > 0) {
|
||||
$('#captureContainer').remove();
|
||||
|
||||
Reference in new issue
Block a user