2020-02-01 01:41:45 +00:00
|
|
|
using System;
|
2020-02-02 15:26:47 +00:00
|
|
|
using System.Collections.ObjectModel;
|
2020-02-01 01:41:45 +00:00
|
|
|
using System.Collections.Generic;
|
2020-02-02 21:49:01 +00:00
|
|
|
using Aurora.Proto.Party;
|
2020-02-02 15:26:47 +00:00
|
|
|
using Aurora.Services.Library;
|
2020-02-02 18:05:14 +00:00
|
|
|
using Aurora.Services.Settings;
|
2020-02-02 15:26:47 +00:00
|
|
|
using Aurora.Models.Media;
|
2020-02-02 21:49:01 +00:00
|
|
|
using Aurora.Services.EventManager;
|
2020-02-02 15:26:47 +00:00
|
|
|
using Autofac;
|
2020-02-01 01:41:45 +00:00
|
|
|
|
|
|
|
namespace Aurora.Services.Server.Controllers
|
|
|
|
{
|
|
|
|
public partial class RemotePartyController : RemotePartyService.RemotePartyServiceBase
|
|
|
|
{
|
2020-02-02 15:26:47 +00:00
|
|
|
private ILibraryService _libraryService;
|
2020-02-02 18:05:14 +00:00
|
|
|
private ISettingsService _settingsService;
|
|
|
|
private IEventManager _eventManager;
|
2020-02-02 15:26:47 +00:00
|
|
|
|
2020-02-01 01:41:45 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Constructor for partial class
|
|
|
|
/// </summary>
|
2020-02-02 18:05:14 +00:00
|
|
|
public RemotePartyController(string partyName, string description, ILibraryService libraryService, ISettingsService settingsService, IEventManager eventManager)
|
2020-02-01 01:41:45 +00:00
|
|
|
{
|
|
|
|
this._startDateTime = DateTime.UtcNow;
|
|
|
|
this._displayName = partyName;
|
|
|
|
this._description = description;
|
|
|
|
this._memberList = new SortedList<string, Member>();
|
2020-02-02 15:26:47 +00:00
|
|
|
this._mediaList = new SortedList<string, Media>();
|
|
|
|
|
|
|
|
_libraryService = libraryService;
|
2020-02-02 18:05:14 +00:00
|
|
|
this._settingsService = settingsService;
|
2020-02-01 01:41:45 +00:00
|
|
|
|
2020-02-02 18:05:14 +00:00
|
|
|
string userName = _settingsService.Username;
|
2020-02-01 01:41:45 +00:00
|
|
|
|
2020-02-02 18:05:14 +00:00
|
|
|
this._eventManager = eventManager;
|
2020-02-01 01:41:45 +00:00
|
|
|
|
|
|
|
this._hostMember = new Member()
|
|
|
|
{
|
|
|
|
Name = GetNewMemberResourceName(_partyResourceName, ServerService.GetLocalIPAddress(), userName),
|
|
|
|
UserName = userName,
|
|
|
|
IpAddress = ServerService.GetLocalIPAddress(),
|
|
|
|
};
|
|
|
|
|
|
|
|
this._memberList.Add(_hostMember.Name, _hostMember);
|
|
|
|
|
|
|
|
//Add media from library
|
2020-02-02 15:26:47 +00:00
|
|
|
//This will change as queuing operation gets solidified
|
|
|
|
//Simply return the hosts library
|
|
|
|
ObservableCollection<BaseMedia> queue = _libraryService.GetLibrary();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (BaseMedia media in queue)
|
|
|
|
{
|
|
|
|
AudioMetadata metadata = new AudioMetadata();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (media.Metadata is AudioMetadata)
|
|
|
|
{
|
|
|
|
metadata = media.Metadata as AudioMetadata;
|
|
|
|
|
|
|
|
Media data = new Media();
|
2020-02-02 18:05:14 +00:00
|
|
|
data.Name = string.Format("{0}/{1}", partyName, media.Id);
|
2020-02-02 15:26:47 +00:00
|
|
|
if (metadata.Title != null)
|
|
|
|
{
|
|
|
|
data.Title = metadata.Title;
|
|
|
|
}
|
|
|
|
if (metadata.Artist != null)
|
|
|
|
{
|
|
|
|
data.Artist = metadata.Artist;
|
|
|
|
}
|
|
|
|
if (metadata.Album != null)
|
|
|
|
{
|
|
|
|
data.Album = metadata.Album;
|
|
|
|
}
|
|
|
|
if (metadata.Duration != null)
|
|
|
|
{
|
|
|
|
data.Duration = metadata.Duration;
|
|
|
|
}
|
2020-02-01 01:41:45 +00:00
|
|
|
|
2020-02-02 15:26:47 +00:00
|
|
|
_mediaList.Add(data.Name, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Console.WriteLine(string.Format("Error preparing queue: {0}", ex.Message));
|
|
|
|
}
|
|
|
|
}
|
2020-02-01 01:41:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|