Added GetQueue method that returns the hosts library
This commit is contained in:
parent
9a34e31f9c
commit
a13e491a7e
@ -23,7 +23,8 @@
|
|||||||
Members="{Binding Members}"/>
|
Members="{Binding Members}"/>
|
||||||
<Label
|
<Label
|
||||||
Text="Queue"/>
|
Text="Queue"/>
|
||||||
<qu:Queue/>
|
<qu:Queue
|
||||||
|
ItemsSource="{Binding Queue}"/>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<hs:HostSelector
|
<hs:HostSelector
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Grpc.Core;
|
|
||||||
using Aurora.Services;
|
using Aurora.Services;
|
||||||
using Aurora.Proto.General;
|
using Aurora.Proto.General;
|
||||||
using Aurora.Proto.Party;
|
using Aurora.Proto.Party;
|
||||||
using Aurora.Proto.Playback;
|
|
||||||
using Aurora.Proto.Events;
|
using Aurora.Proto.Events;
|
||||||
using Aurora.Services.ClientService;
|
using Aurora.Services.ClientService;
|
||||||
|
using Aurora.Models.Media;
|
||||||
|
|
||||||
namespace Aurora.Design.Views.Party
|
namespace Aurora.Design.Views.Party
|
||||||
{
|
{
|
||||||
@ -27,12 +25,15 @@ namespace Aurora.Design.Views.Party
|
|||||||
private string _hostname;
|
private string _hostname;
|
||||||
private ObservableCollection<PartyMember> _members;
|
private ObservableCollection<PartyMember> _members;
|
||||||
|
|
||||||
|
private ObservableCollection<RemoteMediaData> _queue;
|
||||||
|
|
||||||
public PartyViewModel()
|
public PartyViewModel()
|
||||||
{
|
{
|
||||||
this.JoinCommand = new Command(OnJoinExecute, CanJoinExecute);
|
this.JoinCommand = new Command(OnJoinExecute, CanJoinExecute);
|
||||||
this.HostCommand = new Command(OnHostExecute, CanHostExecute);
|
this.HostCommand = new Command(OnHostExecute, CanHostExecute);
|
||||||
|
|
||||||
_members = new ObservableCollection<PartyMember>();
|
_members = new ObservableCollection<PartyMember>();
|
||||||
|
_queue = new ObservableCollection<RemoteMediaData>();
|
||||||
|
|
||||||
SetState(PartyState.SelectingHost);
|
SetState(PartyState.SelectingHost);
|
||||||
|
|
||||||
@ -69,6 +70,21 @@ namespace Aurora.Design.Views.Party
|
|||||||
get { return _state != PartyState.SelectingHost; }
|
get { return _state != PartyState.SelectingHost; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<RemoteMediaData> Queue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _queue;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != _queue)
|
||||||
|
{
|
||||||
|
SetProperty(ref _queue, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Command JoinCommand { get; set; }
|
public Command JoinCommand { get; set; }
|
||||||
public Command HostCommand { get; set; }
|
public Command HostCommand { get; set; }
|
||||||
|
|
||||||
@ -189,6 +205,14 @@ namespace Aurora.Design.Views.Party
|
|||||||
|
|
||||||
Console.WriteLine(string.Format("CLIENT {0} - SubscribeToEvents called from client with id", SettingsService.Instance.ClientId));
|
Console.WriteLine(string.Format("CLIENT {0} - SubscribeToEvents called from client with id", SettingsService.Instance.ClientId));
|
||||||
ClientService.Instance.RemoteEventClient.SubscribeToEvents(req);
|
ClientService.Instance.RemoteEventClient.SubscribeToEvents(req);
|
||||||
|
|
||||||
|
QueueResponse queueResponse = ClientService.Instance.RemotePartyClient.GetQueue(new Empty());
|
||||||
|
|
||||||
|
Queue.Clear();
|
||||||
|
foreach (RemoteMediaData data in queueResponse.MediaList)
|
||||||
|
{
|
||||||
|
Queue.Add(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ service RemotePartyService {
|
|||||||
rpc JoinParty(JoinPartyRequest) returns (JoinPartyResponse);
|
rpc JoinParty(JoinPartyRequest) returns (JoinPartyResponse);
|
||||||
rpc LeaveParty(LeavePartyRequest) returns (LeavePartyResponse);
|
rpc LeaveParty(LeavePartyRequest) returns (LeavePartyResponse);
|
||||||
rpc GetPartyMembers(Aurora.Proto.General.Empty) returns (MembersResponse);
|
rpc GetPartyMembers(Aurora.Proto.General.Empty) returns (MembersResponse);
|
||||||
|
rpc GetQueue(Aurora.Proto.General.Empty) returns (QueueResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
message JoinPartyRequest {
|
message JoinPartyRequest {
|
||||||
@ -34,14 +35,22 @@ message PartyMember {
|
|||||||
string ipAddress = 3;
|
string ipAddress = 3;
|
||||||
int32 port = 4;
|
int32 port = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message MembersResponse {
|
message MembersResponse {
|
||||||
repeated PartyMember members = 1;
|
repeated PartyMember members = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum PartyJoinedStatusEnum {
|
enum PartyJoinedStatusEnum {
|
||||||
Connected = 0;
|
Connected = 0;
|
||||||
Disconnected = 1;
|
Disconnected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message QueueResponse{
|
||||||
|
repeated RemoteMediaData mediaList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoteMediaData {
|
||||||
|
string title = 1;
|
||||||
|
string artist = 2;
|
||||||
|
string album = 3;
|
||||||
|
string duration = 4;
|
||||||
|
}
|
||||||
|
@ -5,6 +5,9 @@ using System.Linq;
|
|||||||
using Aurora.Proto.Party;
|
using Aurora.Proto.Party;
|
||||||
using Aurora.Proto.Events;
|
using Aurora.Proto.Events;
|
||||||
using Aurora.Services.EventManager;
|
using Aurora.Services.EventManager;
|
||||||
|
using Aurora.Services;
|
||||||
|
using Aurora.Models.Media;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace Aurora.RemoteImpl
|
namespace Aurora.RemoteImpl
|
||||||
{
|
{
|
||||||
@ -82,5 +85,50 @@ namespace Aurora.RemoteImpl
|
|||||||
response.Members.AddRange(_partyMembers);
|
response.Members.AddRange(_partyMembers);
|
||||||
return Task.FromResult(response);
|
return Task.FromResult(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task<QueueResponse> GetQueue(Proto.General.Empty empty, Grpc.Core.ServerCallContext context)
|
||||||
|
{
|
||||||
|
//This will change as queuing operation gets solidified
|
||||||
|
//Simply return the hosts library
|
||||||
|
|
||||||
|
ObservableCollection<BaseMedia> queue = LibraryService.Instance.GetLibrary();
|
||||||
|
|
||||||
|
QueueResponse mediaList = new QueueResponse();
|
||||||
|
foreach (BaseMedia media in queue)
|
||||||
|
{
|
||||||
|
AudioMetadata metadata = new AudioMetadata();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (media.Metadata is AudioMetadata)
|
||||||
|
{
|
||||||
|
metadata = media.Metadata as AudioMetadata;
|
||||||
|
|
||||||
|
RemoteMediaData data = new RemoteMediaData();
|
||||||
|
data.Title = metadata.Title == null ? 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaList.MediaList.Add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(string.Format("Error preparing queue: {0}", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult(mediaList);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user