Add current songInfo to the Webserver and Site
This commit is contained in:
1 parent
8dfa321c8a
commit
197f003211
10 files changed
+196
-3
No files matched your search
@@ -67,6 +67,17 @@ namespace ClientServerLib
|
||||
|
||||
#endregion
|
||||
|
||||
#region songs
|
||||
|
||||
private static GetCurrentSongDelegate getCurrentSong;
|
||||
public static GetCurrentSongDelegate GetCurrentSong
|
||||
{
|
||||
internal get { return CServer.getCurrentSong; }
|
||||
set { CServer.getCurrentSong = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public CServer(int port)
|
||||
{
|
||||
baseAddress = new Uri("http://localhost:" + port + "/");
|
||||
|
||||
@@ -84,6 +84,16 @@ namespace ClientServerLib
|
||||
Stream GetImgFile(String filename);
|
||||
|
||||
#endregion
|
||||
|
||||
#region songs
|
||||
|
||||
[OperationContract]
|
||||
[WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "/getCurrentSong")]
|
||||
SongInfo getCurrentSong();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
class CWebservice : ICWebservice
|
||||
@@ -135,7 +145,7 @@ namespace ClientServerLib
|
||||
#region photo
|
||||
|
||||
public bool sendPhoto(PhotoData photo)
|
||||
{
|
||||
{
|
||||
return CServer.SendPhoto(photo);
|
||||
}
|
||||
|
||||
@@ -236,5 +246,14 @@ namespace ClientServerLib
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region songs
|
||||
|
||||
public SongInfo getCurrentSong()
|
||||
{
|
||||
return CServer.GetCurrentSong();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -90,4 +90,29 @@ namespace ClientServerLib
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region songs
|
||||
|
||||
public delegate SongInfo GetCurrentSongDelegate();
|
||||
|
||||
[DataContract]
|
||||
public struct SongInfo
|
||||
{
|
||||
[DataMember]
|
||||
public string Title;
|
||||
[DataMember]
|
||||
public string Artist;
|
||||
[DataMember]
|
||||
public Base64Image Cover;
|
||||
[DataMember]
|
||||
public string Genre { get; set; }
|
||||
[DataMember]
|
||||
public string Language { get; set; }
|
||||
[DataMember]
|
||||
public string Year { get; set; }
|
||||
[DataMember]
|
||||
public bool IsDuet { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -28,6 +28,7 @@ using ClientServerLib;
|
||||
using Vocaluxe.Lib.Input;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Profile;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Base.Server
|
||||
{
|
||||
@@ -59,6 +60,7 @@ namespace Vocaluxe.Base.Server
|
||||
CServer.GetProfileList = getProfileList;
|
||||
CServer.SendPhoto = sendPhoto;
|
||||
CServer.GetSiteFile = getSiteFile;
|
||||
CServer.GetCurrentSong = getCurrentSong;
|
||||
|
||||
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
|
||||
Controller.Init();
|
||||
@@ -324,6 +326,28 @@ namespace Vocaluxe.Base.Server
|
||||
|
||||
#endregion
|
||||
|
||||
#region songs
|
||||
|
||||
private static SongInfo getCurrentSong()
|
||||
{
|
||||
SongInfo result = new SongInfo();
|
||||
CSong song = CGame.GetSong();
|
||||
if (song != null)
|
||||
{
|
||||
result.Title = song.Title;
|
||||
result.Artist = song.Artist;
|
||||
result.Genre = song.Genre.FirstOrDefault();
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static string _SaveImage(Base64Image imageDate, string name, string folder)
|
||||
{
|
||||
Image avatarImage = imageDate.getImage();
|
||||
|
||||
@@ -344,6 +344,12 @@
|
||||
<CustomToolNamespace>css</CustomToolNamespace>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Website\img\music.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Website\img\noCover.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Website\index.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -39,3 +39,18 @@
|
||||
.ui-loading .ui-loader-background {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#displaySongCover {
|
||||
height: 75%;
|
||||
max-height: 250px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#displaySongContent {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#displaySongContent span {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 268 KiB |
@@ -41,6 +41,13 @@
|
||||
<p>Edit your profile</p>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="A1" href="#displaySong" 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="#selectProfile" data-transition="slidefade">
|
||||
<img src="img/profiles.png">
|
||||
@@ -117,6 +124,37 @@
|
||||
</div>
|
||||
<!-- /page -->
|
||||
|
||||
<div id="displaySong" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||
<div data-role="header">
|
||||
<h1 id="displaySongTitle">No current song</h1>
|
||||
</div>
|
||||
<!-- /header -->
|
||||
|
||||
<div id="displaySongContent" data-role="content">
|
||||
<img id="displaySongCover" src="img/noCover.png" alt="Cover">
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label for="displaySongArtist" class="input">Artist:</label>
|
||||
<span id="displaySongArtist" data-mini="true">-</span>
|
||||
<br />
|
||||
<label for="displaySongGenre" class="input">Genre:</label>
|
||||
<span id="displaySongGenre" data-mini="true">-</span>
|
||||
<br />
|
||||
<label for="displaySongYear" class="input">Year:</label>
|
||||
<span id="displaySongYear" data-mini="true">-</span>
|
||||
<br />
|
||||
<label for="displaySongLanguage" class="input">Language:</label>
|
||||
<span id="displaySongLanguage" data-mini="true">-</span>
|
||||
<br />
|
||||
<label for="displaySongIsDuet" class="input">Duet:</label>
|
||||
<span id="displaySongIsDuet" data-mini="true">-</span>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
<!-- /page -->
|
||||
|
||||
|
||||
<div id="keyboard" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||
<div data-role="header">
|
||||
<h1>Keyboard</h1>
|
||||
|
||||
@@ -28,6 +28,7 @@ function replaceTransitionHandler() {
|
||||
}
|
||||
|
||||
function initPageLoadHandler() {
|
||||
//pageLoadHandler for displayProfile
|
||||
$(document).on('pagebeforeshow', '#displayProfile', function () {
|
||||
var promise = $.ajax({
|
||||
url: "getProfile?profileId=" + profileIdRequest
|
||||
@@ -106,6 +107,7 @@ function initPageLoadHandler() {
|
||||
$(this).data('promise', promise);
|
||||
});
|
||||
|
||||
//pageLoadHandler for selectProfile
|
||||
$(document).on('pagebeforeshow', '#selectProfile', function () {
|
||||
var promise = $.ajax({
|
||||
url: "getProfileList"
|
||||
@@ -130,6 +132,59 @@ function initPageLoadHandler() {
|
||||
$(this).data('promise', promise);
|
||||
});
|
||||
|
||||
//pageLoadHandler for displaySong
|
||||
$(document).on('pagebeforeshow', '#displaySong', function () {
|
||||
var promise = $.ajax({
|
||||
url: "getCurrentSong"
|
||||
}).done(function (result) {
|
||||
if (result.Title != null) {
|
||||
$('#displaySongTitle').text(result.Title);
|
||||
}
|
||||
else {
|
||||
$('#displaySongTitle').text("No current song");
|
||||
}
|
||||
|
||||
if (result.Cover && result.Cover.base64Data) {
|
||||
$('#displaySongCover').prop("src", result.Cover.base64Data);
|
||||
}
|
||||
else {
|
||||
$('#displaySongCover').prop("src", "img/noCover.png");
|
||||
}
|
||||
|
||||
if (result.Artist != null) {
|
||||
$('#displaySongArtist').text(result.Artist);
|
||||
}
|
||||
else {
|
||||
$('#displaySongArtist').text("-");
|
||||
}
|
||||
|
||||
if (result.Genre != null) {
|
||||
$('#displaySongGenre').text(result.Genre);
|
||||
}
|
||||
else {
|
||||
$('#displaySongGenre').text("-");
|
||||
}
|
||||
|
||||
if (result.Year != null && result.Year != "") {
|
||||
$('#displaySongYear').text(result.Year);
|
||||
}
|
||||
else {
|
||||
$('#displaySongYear').text("-");
|
||||
}
|
||||
|
||||
if (result.Language != null) {
|
||||
$('#displaySongLanguage').text(result.Language);
|
||||
}
|
||||
else {
|
||||
$('#displaySongLanguage').text("-");
|
||||
}
|
||||
|
||||
$('#displaySongIsDuet').text(result.IsDuet?"Yes":"No");
|
||||
});
|
||||
|
||||
// Save promise on page so the transition handler can find it.
|
||||
$(this).data('promise', promise);
|
||||
});
|
||||
}
|
||||
|
||||
function initLoginPageHandler() {
|
||||
@@ -137,13 +192,13 @@ function initLoginPageHandler() {
|
||||
ownProfileId = parseInt($('#playerId').prop("value"));
|
||||
if (ownProfileId != "NaN") {
|
||||
$.mobile.changePage("#main", { transition: "slidefade" });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initMainPageHandler() {
|
||||
$('#yourProfileLink').click(function () {
|
||||
profileIdRequest = ownProfileId;
|
||||
profileIdRequest = ownProfileId;
|
||||
$.mobile.changePage("#displayProfile", { transition: "slidefade" });
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user