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; }
|
set { CServer.getProfileList = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region photo
|
#region photo
|
||||||
@@ -69,13 +68,28 @@ namespace ClientServerLib
|
|||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|
||||||
private static GetCurrentSongDelegate getCurrentSong;
|
private static GetSongDelegate getSong;
|
||||||
public static GetCurrentSongDelegate GetCurrentSong
|
public static GetSongDelegate GetSong
|
||||||
{
|
{
|
||||||
internal get { return CServer.getCurrentSong; }
|
internal get { return CServer.getSong; }
|
||||||
set { CServer.getCurrentSong = value; }
|
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
|
#endregion
|
||||||
|
|
||||||
public CServer(int port)
|
public CServer(int port)
|
||||||
|
|||||||
@@ -90,8 +90,20 @@ namespace ClientServerLib
|
|||||||
[OperationContract]
|
[OperationContract]
|
||||||
[WebInvoke(Method = "GET",
|
[WebInvoke(Method = "GET",
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getCurrentSong")]
|
UriTemplate = "/getSong?songId={songId}")]
|
||||||
SongInfo getCurrentSong();
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -249,11 +261,22 @@ namespace ClientServerLib
|
|||||||
|
|
||||||
#region songs
|
#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
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
|
|||||||
namespace ClientServerLib
|
namespace ClientServerLib
|
||||||
{
|
{
|
||||||
public delegate bool SendKeyEventDelegate(string key);
|
public delegate bool SendKeyEventDelegate(string key);
|
||||||
|
|
||||||
|
|
||||||
#region profile
|
#region profile
|
||||||
|
|
||||||
@@ -93,7 +93,11 @@ namespace ClientServerLib
|
|||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|
||||||
public delegate SongInfo GetCurrentSongDelegate();
|
public delegate SongInfo GetSongDelegate(int songId);
|
||||||
|
|
||||||
|
public delegate SongInfo[] GetAllSongsDelegate();
|
||||||
|
|
||||||
|
public delegate int GetCurrentSongIdDelegate();
|
||||||
|
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public struct SongInfo
|
public struct SongInfo
|
||||||
@@ -112,6 +116,8 @@ namespace ClientServerLib
|
|||||||
public string Year { get; set; }
|
public string Year { get; set; }
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public bool IsDuet { get; set; }
|
public bool IsDuet { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public int SongId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ namespace Vocaluxe.Base.Server
|
|||||||
CServer.GetProfileList = getProfileList;
|
CServer.GetProfileList = getProfileList;
|
||||||
CServer.SendPhoto = sendPhoto;
|
CServer.SendPhoto = sendPhoto;
|
||||||
CServer.GetSiteFile = getSiteFile;
|
CServer.GetSiteFile = getSiteFile;
|
||||||
CServer.GetCurrentSong = getCurrentSong;
|
CServer.GetSong = getSong;
|
||||||
|
CServer.GetAllSongs = getAllSongs;
|
||||||
|
CServer.GetCurrentSongId = getCurrentSongId;
|
||||||
|
|
||||||
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
|
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
|
||||||
Controller.Init();
|
Controller.Init();
|
||||||
@@ -328,10 +330,32 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
#region songs
|
#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();
|
SongInfo result = new SongInfo();
|
||||||
CSong song = CGame.GetSong();
|
|
||||||
if (song != null)
|
if (song != null)
|
||||||
{
|
{
|
||||||
result.Title = song.Title;
|
result.Title = song.Title;
|
||||||
@@ -340,8 +364,12 @@ namespace Vocaluxe.Base.Server
|
|||||||
result.Language = song.Language.FirstOrDefault();
|
result.Language = song.Language.FirstOrDefault();
|
||||||
result.Year = song.Year;
|
result.Year = song.Year;
|
||||||
result.IsDuet = song.IsDuet;
|
result.IsDuet = song.IsDuet;
|
||||||
Image cover = Image.FromFile(song.Folder + "\\" + song.CoverFileName);
|
result.SongId = song.ID;
|
||||||
result.Cover = new Base64Image(cover, cover.RawFormat);
|
if (includeCover)
|
||||||
|
{
|
||||||
|
Image cover = Image.FromFile(song.Folder + "\\" + song.CoverFileName);
|
||||||
|
result.Cover = new Base64Image(cover, cover.RawFormat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,10 +175,6 @@
|
|||||||
<HintPath>..\Output\AForge.Video.DirectShow.dll</HintPath>
|
<HintPath>..\Output\AForge.Video.DirectShow.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ClientServerLib">
|
|
||||||
<HintPath>..\ClientServerLib\ClientServerLib\bin\ClientServerLib.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Community.CsharpSqlite">
|
<Reference Include="Community.CsharpSqlite">
|
||||||
<HintPath>..\Output\Community.CsharpSqlite.dll</HintPath>
|
<HintPath>..\Output\Community.CsharpSqlite.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -350,6 +346,9 @@
|
|||||||
<Content Include="Website\img\noCover.png">
|
<Content Include="Website\img\noCover.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Website\img\playlist.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Website\index.html">
|
<Content Include="Website\index.html">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -42,12 +42,19 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a id="A1" href="#displaySong" data-transition="slidefade">
|
<a id="currentSongLink" href="#" data-transition="slidefade">
|
||||||
<img src="img/music.png">
|
<img src="img/music.png">
|
||||||
<h2>Current Song</h2>
|
<h2>Current Song</h2>
|
||||||
<p>Display informations about the current song</p>
|
<p>Display informations about the current song</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</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>
|
<li>
|
||||||
<a href="#selectProfile" data-transition="slidefade">
|
<a href="#selectProfile" data-transition="slidefade">
|
||||||
<img src="img/profiles.png">
|
<img src="img/profiles.png">
|
||||||
@@ -154,6 +161,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- /page -->
|
<!-- /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 id="keyboard" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||||
<div data-role="header">
|
<div data-role="header">
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
var ownProfileId = 1;
|
var ownProfileId = -1;
|
||||||
var profileIdRequest = 1;
|
var profileIdRequest = -1;
|
||||||
|
var songIdRequest = -1
|
||||||
|
var allSongsCache = null;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
replaceTransitionHandler();
|
replaceTransitionHandler();
|
||||||
@@ -135,7 +137,7 @@ function initPageLoadHandler() {
|
|||||||
//pageLoadHandler for displaySong
|
//pageLoadHandler for displaySong
|
||||||
$(document).on('pagebeforeshow', '#displaySong', function () {
|
$(document).on('pagebeforeshow', '#displaySong', function () {
|
||||||
var promise = $.ajax({
|
var promise = $.ajax({
|
||||||
url: "getCurrentSong"
|
url: "getSong?songId=" + songIdRequest
|
||||||
}).done(function (result) {
|
}).done(function (result) {
|
||||||
if (result.Title != null) {
|
if (result.Title != null) {
|
||||||
$('#displaySongTitle').text(result.Title);
|
$('#displaySongTitle').text(result.Title);
|
||||||
@@ -178,13 +180,48 @@ function initPageLoadHandler() {
|
|||||||
else {
|
else {
|
||||||
$('#displaySongLanguage').text("-");
|
$('#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.
|
// Save promise on page so the transition handler can find it.
|
||||||
$(this).data('promise', promise);
|
$(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() {
|
function initLoginPageHandler() {
|
||||||
@@ -202,6 +239,26 @@ function initMainPageHandler() {
|
|||||||
$.mobile.changePage("#displayProfile", { transition: "slidefade" });
|
$.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 () {
|
$('#mainPageTakePhotoLink').click(function () {
|
||||||
if ($('#captureContainer').length > 0) {
|
if ($('#captureContainer').length > 0) {
|
||||||
$('#captureContainer').remove();
|
$('#captureContainer').remove();
|
||||||
|
|||||||
Reference in new issue
Block a user