Using System.Diagnostics.Debug. First pass at player controls styling

This commit is contained in:
watsonb8 2019-12-04 14:53:49 -08:00
parent 22a524cfd1
commit 187de97503
25 changed files with 169 additions and 101 deletions

View File

@ -518,6 +518,17 @@
<Content Include="Resources\backward.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\pause.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\menu.png">
</Content>
<Content Include="Resources\shuffle.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\loop.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Grpc.Tools.2.25.0\build\Grpc.Tools.targets" Condition="Exists('..\packages\Grpc.Tools.2.25.0\build\Grpc.Tools.targets')" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,12 +1,26 @@
Label {
color: darkgray;
#PlayerControlContainer {
background-color: #626363;
}
Label {
color: white;
text-align: left;
vertical-align: middle;
word-wrap: break-word;
}
#MediaInfoLayout label {
margin-left: 20;
#MediaInfoContainer {
width: 150;
margin-top: 10;
margin-bottom: 10;
}
#MediaInfoContainer label {
margin-left: 20;
}
#AlbumArtBoxView {
background-color: black;
width: 80;
}
ImageButton {

View File

@ -12,25 +12,30 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="100"/>
Width="150"/>
<ColumnDefinition
Width="*"/>
<ColumnDefinition
Width="100"/>
</Grid.ColumnDefinitions>
<StackLayout
x:Name="MediaInfoLayout"
HorizontalOptions="StartAndExpand"
Grid.Column="0">
<Label
x:Name="SongTitleLabel"
LineBreakMode="TailTruncation"/>
<Label
x:Name="ArtistNameLabel"
LineBreakMode="TailTruncation"/>
Orientation="Horizontal">
<BoxView
x:Name="AlbumArtBoxView"/>
<StackLayout
x:Name="MediaInfoContainer"
HorizontalOptions="StartAndExpand"
Grid.Column="0">
<Label
x:Name="SongTitleLabel"
LineBreakMode="TailTruncation"/>
<Label
x:Name="ArtistNameLabel"
LineBreakMode="TailTruncation"/>
</StackLayout>
</StackLayout>
<StackLayout
x:Name="PlayerControlLayout"
x:Name="PlayerControlContainer"
Grid.Column="1"
HorizontalOptions="Center"
Orientation="Horizontal">
@ -38,8 +43,7 @@
x:Name="PreviousButton"
Source="Resources/backward.png"/>
<imgBtn:ImageButton
x:Name="PlayButton"
Source="Resources/play.png"/>
x:Name="PlayButton"/>
<imgBtn:ImageButton
x:Name="NextButton"
Source="Resources/forwards.png"/>

View File

@ -9,6 +9,7 @@ namespace Aurora.Design.Components.MediaPlayer
{
InitializeComponent();
PlayButton.Source = ImageSource.FromFile("Resources/play.png");
}
#region SongTitle Bindable
@ -16,7 +17,11 @@ namespace Aurora.Design.Components.MediaPlayer
BindableProperty.Create(propertyName: "SongTitle",
returnType: typeof(string),
declaringType: typeof(Player),
propertyChanged: OnSongTitlePropertyChanged);
propertyChanged: (BindableObject bindable, object oldValue, object newValue) =>
{
Player component = bindable as Player;
component.SongTitleLabel.Text = (string)newValue;
});
public string SongTitle
{
@ -30,12 +35,6 @@ namespace Aurora.Design.Components.MediaPlayer
}
}
private static void OnSongTitlePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
Player component = bindable as Player;
component.SongTitleLabel.Text = (string)newValue;
}
#endregion SongTitle Bindable
#region ArtistName Bindable
@ -43,7 +42,11 @@ namespace Aurora.Design.Components.MediaPlayer
BindableProperty.Create(propertyName: "ArtistName",
returnType: typeof(string),
declaringType: typeof(Player),
propertyChanged: OnArtistNamePropertyChanged);
propertyChanged: (BindableObject bindable, object oldValue, object newValue) =>
{
Player component = bindable as Player;
component.ArtistNameLabel.Text = (string)newValue;
});
public string ArtistName
{
@ -57,12 +60,6 @@ namespace Aurora.Design.Components.MediaPlayer
}
}
private static void OnArtistNamePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
Player component = bindable as Player;
component.ArtistNameLabel.Text = (string)newValue;
}
#endregion ArtistName Bindable
#region PreviousButton
@ -275,5 +272,32 @@ namespace Aurora.Design.Components.MediaPlayer
component.NextButton.IsEnabled = cmd.CanExecute(null);
}
#endregion PlayButton
#region Playing Bindable
public static readonly BindableProperty IsPlayingProperty =
BindableProperty.Create(
propertyName: "IsPlaying",
returnType: typeof(bool),
declaringType: typeof(Player),
propertyChanged: (BindableObject bindable, object oldValue, object newValue) =>
{
Player control = (Player)bindable;
if ((bool)newValue == true)
{
control.PlayButton.Source = ImageSource.FromFile("Resources/pause.png");
}
else
{
control.PlayButton.Source = ImageSource.FromFile("Resources/play.png");
}
});
public bool IsPlaying
{
get { return (bool)GetValue(IsPlayingProperty); }
set { SetValue(IsPlayingProperty, value); }
}
#endregion Playing Binadable
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Aurora.Design.Converters
{
public class PlayIconConverter
{
public PlayIconConverter()
{
}
}
}

View File

@ -72,6 +72,8 @@ namespace Aurora.Design.Views
public SetPlayerVisibleDelegate SetPlayerVisible { get; set; }
public SetIsPlayingDelegate SetIsPlaying { get; set; }
#endregion Player
#region Lifecycle

View File

@ -3,7 +3,7 @@
}
#Header {
background-color: #232323;
background-color: transparent;
}
#Header > Entry {
@ -14,7 +14,7 @@
#TitleContainer {
margin-top: 10;
background-color: #3a3a3a;
background-color: transparent;
}
#TitleContainer Label {

View File

@ -17,10 +17,15 @@
<RowDefinition Height="*"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--Header-->
<StackLayout
x:Name="Header"
Grid.Row="0"
Grid.ColumnSpan="2"
Orientation="Horizontal">
<Entry Text="Search"/>
</StackLayout>
@ -28,35 +33,31 @@
<!--Title-->
<StackLayout
Grid.Row="1"
Grid.ColumnSpan="2"
x:Name="TitleContainer">
<Label Text="{Binding Title}" TextColor="White"/>
</StackLayout>
<!--Library Grid-->
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--Sidebar-->
<navigation:NavigationMenu
Grid.Column="0"
Grid.RowSpan="3"
x:Name="MasterPage"
Items="{Binding Pages}"
SelectedItem="{Binding SelectedItem}"/>
<navigation:NavigationMenu
Grid.Column="0"
x:Name="MasterPage"
Items="{Binding Pages}"
SelectedItem="{Binding SelectedItem}"/>
<views:PageContainer
Grid.Column="1"
Grid.Row="0"
x:Name="ContentPage"/>
</Grid>
<!--Page Container-->
<views:PageContainer
Grid.Column="1"
Grid.Row="2"
x:Name="ContentPage"/>
<!--Music Player-->
<mp:Player
x:Name="Player"
Grid.Row="3"
HeightRequest="50"/>
x:Name="Player"
Grid.Row="3"
Grid.ColumnSpan="2"
HeightRequest="50"/>
</Grid>
</ContentPage>

View File

@ -17,7 +17,9 @@ namespace Aurora.Design.Views.Main
/// <param name="media"></param>
public delegate void SetPlayerMetadataDelegate(BaseMedia media);
public delegate void SetPlayerVisibleDelegate(Boolean visible);
public delegate void SetPlayerVisibleDelegate(bool visible);
public delegate void SetIsPlayingDelegate(bool playing);
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainView : ContentPage//, IDisposable
@ -139,6 +141,7 @@ namespace Aurora.Design.Views.Main
{
vm.SetPlayerMetadata = null;
vm.SetPlayerVisible = null;
vm.SetIsPlaying = null;
}
/// <summary>
@ -152,8 +155,10 @@ namespace Aurora.Design.Views.Main
_player.PreviousButtonCommand = new Command(vm.OnPreviousButtonExecute, vm.CanPreviousButtonExecute);
//Assign SetPlayer delegate
vm.SetPlayerMetadata = SetPlayer;
vm.SetPlayerVisible = SetPlayerVisible;
vm.SetIsPlaying = SetIsPlaying;
}
/// <summary>
@ -178,6 +183,11 @@ namespace Aurora.Design.Views.Main
{
_player.IsVisible = visible;
}
private void SetIsPlaying(bool playing)
{
_player.IsPlaying = playing;
}
}
}

View File

@ -257,7 +257,7 @@ namespace Aurora.Design.Views.Party
}
catch (Exception ex)
{
Console.WriteLine("Exception occurred while receiviing events: ", ex.Message);
System.Diagnostics.Debug.WriteLine("Exception occurred while receiviing events: ", ex.Message);
}
}
@ -285,7 +285,7 @@ namespace Aurora.Design.Views.Party
}
catch (Exception ex)
{
Console.WriteLine("Exception occurred while receiviing events: ", ex.Message);
System.Diagnostics.Debug.WriteLine("Exception occurred while receiviing events: ", ex.Message);
}
}
@ -419,7 +419,7 @@ namespace Aurora.Design.Views.Party
}
catch (Exception ex)
{
Console.WriteLine("Error subscribing to events: " + ex.Message);
System.Diagnostics.Debug.WriteLine("Error subscribing to events: " + ex.Message);
}
}
@ -449,7 +449,7 @@ namespace Aurora.Design.Views.Party
}
Console.WriteLine(string.Format("CLIENT {0} - SubscribeToEvents called from client with id", SettingsService.Instance.ClientId));
System.Diagnostics.Debug.WriteLine(string.Format("CLIENT {0} - SubscribeToEvents called from client with id", SettingsService.Instance.ClientId));
await _client.RemoteEventClient.SubscribeToEventsAsync(req);
}
private async Task UnsubscribeFromEvents()

View File

@ -22,8 +22,6 @@ namespace Aurora.Design.Views.Songs
_songsList = new ObservableCollection<BaseMedia>();
PlayCommand = new Command(OnPlayButtonExecute, CanPlayButtonExecute);
_player.PlaybackStateChanged += OnPlaybackStateChanged;
Initialize();
}
@ -87,6 +85,10 @@ namespace Aurora.Design.Views.Songs
public async override void OnPlayButtonExecute()
{
if (_selectedSong == null)
{
return;
}
base.Media = _selectedSong;
if (!_player.IsMediaLoaded(base.Media))
{
@ -98,16 +100,19 @@ namespace Aurora.Design.Views.Songs
case PlaybackState.Buffering:
{
_player.Play();
SetIsPlaying(true);
break;
}
case PlaybackState.Playing:
{
_player.Pause();
SetIsPlaying(false);
break;
}
case PlaybackState.Stopped:
{
_player.Play();
SetIsPlaying(true);
break;
}
}
@ -124,18 +129,5 @@ namespace Aurora.Design.Views.Songs
}
#endregion Commands
#region Events
/// <summary>
/// PlayerService playback state changed event handler.
/// </summary>
/// <param name="sender">The sending object.</param>
/// <param name="args">Event arguments.</param>
public void OnPlaybackStateChanged(object sender, PlaybackStateChangedEventArgs args)
{
OnPropertyChanged("PlayButtonText");
}
#endregion Events
}
}

View File

@ -69,11 +69,11 @@ namespace Aurora.Models.Media
await this.DataStream.WriteAsync(buffer, 0, buffer.Length);
}
Console.WriteLine("Done receiving stream");
System.Diagnostics.Debug.WriteLine("Done receiving stream");
}
catch (Exception ex)
{
Console.WriteLine("Exception caught while loading remote audio:" + ex.Message);
System.Diagnostics.Debug.WriteLine("Exception caught while loading remote audio:" + ex.Message);
}
}
await base.Load();

View File

@ -28,12 +28,12 @@ namespace Aurora.RemoteImpl
Grpc.Core.ServerCallContext context)
{
string peerId = Combine(new string[] { context.Peer, request.ClientId });
Console.WriteLine(string.Format("SERVER - Events request received from peer: {0}", peerId));
System.Diagnostics.Debug.WriteLine(string.Format("SERVER - Events request received from peer: {0}", peerId));
AutoResetEvent are = new AutoResetEvent(false);
Action<BaseEvent> callback = (BaseEvent bEvent) =>
{
Console.WriteLine(string.Format("SERVER - Event fired for peer: {0}", peerId));
System.Diagnostics.Debug.WriteLine(string.Format("SERVER - Event fired for peer: {0}", peerId));
//TODO need to remove callback if stream no longer exists IE. Client crashed or stopped
responseStream.WriteAsync(bEvent);
@ -52,7 +52,7 @@ namespace Aurora.RemoteImpl
/// <returns></returns>
public override Task<SubscriptionResponse> SubscribeToEvents(SubscribeRequest request, Grpc.Core.ServerCallContext context)
{
Console.WriteLine(string.Format("SERVER - Subscription from client with id: {0}", request.ClientId));
System.Diagnostics.Debug.WriteLine(string.Format("SERVER - Subscription from client with id: {0}", request.ClientId));
EventManager.Instance.AddSubscriptionList(Combine(new string[] { context.Peer, request.ClientId }), request.EventTypes.ToList());
return Task.FromResult(new SubscriptionResponse { Successful = true });

View File

@ -40,7 +40,7 @@ namespace Aurora.RemoteImpl
IpAddress = context.Host,
};
Console.WriteLine("SERVER - Client joined party: " + partyMember.Id);
System.Diagnostics.Debug.WriteLine("SERVER - Client joined party: " + partyMember.Id);
_partyMembers.Add(partyMember);
@ -128,7 +128,7 @@ namespace Aurora.RemoteImpl
}
catch (Exception ex)
{
Console.WriteLine(string.Format("Error preparing queue: {0}", ex.Message));
System.Diagnostics.Debug.WriteLine(string.Format("Error preparing queue: {0}", ex.Message));
}
}

View File

@ -33,7 +33,7 @@ namespace Aurora.RemoteImpl
}
//Send stream
Console.WriteLine("Begin sending file");
System.Diagnostics.Debug.WriteLine("Begin sending file");
byte[] buffer = new byte[2048]; // read in chunks of 2KB
int bytesRead;
while ((bytesRead = songCopy.DataStream.Read(buffer, 0, buffer.Length)) > 0)
@ -41,11 +41,11 @@ namespace Aurora.RemoteImpl
Google.Protobuf.ByteString bufferByteString = Google.Protobuf.ByteString.CopyFrom(buffer);
await responseStream.WriteAsync(new Chunk { Content = bufferByteString });
}
Console.WriteLine("Done sending file");
System.Diagnostics.Debug.WriteLine("Done sending file");
}
catch (Exception ex)
{
Console.WriteLine("Exception caught while sending audio file: " + ex.Message);
System.Diagnostics.Debug.WriteLine("Exception caught while sending audio file: " + ex.Message);
}
}
}

View File

@ -41,7 +41,7 @@ namespace Aurora.RemoteImpl
ServerTimeTicks = Utils.TimeUtils.GetNetworkTime().DateTime.Ticks
};
await responseStream.WriteAsync(sync);
Console.WriteLine("Sent Sync");
System.Diagnostics.Debug.WriteLine("Sent Sync");
await Task.Delay(5000);
}
}

View File

@ -95,7 +95,7 @@ namespace Aurora.Services.ClientService
{
_eventCancellationTokenSource = new CancellationTokenSource();
string clientId = SettingsService.Instance.ClientId;
Console.WriteLine(string.Format("CLIENT {0} - GetEvents called from client with id", clientId));
System.Diagnostics.Debug.WriteLine(string.Format("CLIENT {0} - GetEvents called from client with id", clientId));
using (AsyncServerStreamingCall<BaseEvent> eventStream = _remoteEventsClient
.GetEvents(new EventsRequest { ClientId = SettingsService.Instance.ClientId }))
{
@ -126,14 +126,14 @@ namespace Aurora.Services.ClientService
}
catch (Exception ex)
{
Console.WriteLine("Exception while parsing event ---" + ex.Message);
System.Diagnostics.Debug.WriteLine("Exception while parsing event ---" + ex.Message);
}
}
}
catch (Exception ex)
{
Console.WriteLine(string.Format("EXCEPTION while parsing events --- " + ex.Message));
System.Diagnostics.Debug.WriteLine(string.Format("EXCEPTION while parsing events --- " + ex.Message));
}
}
}

View File

@ -187,7 +187,7 @@ namespace Aurora.Services.EventManager
executionTask.ContinueWith((Task task) =>
{
var exception = executionTask.Exception;
Console.WriteLine(string.Format("SERVER --- Exception occurred firing event"));
System.Diagnostics.Debug.WriteLine(string.Format("SERVER --- Exception occurred firing event"));
this._actionList.Remove(pair.Key);
},
TaskContinuationOptions.OnlyOnFaulted);

View File

@ -147,21 +147,21 @@ namespace Aurora.Services.PlayerService
newPosition - oldPosition < -0.001)
{
_mediaPlayer.Position = newPosition;
Console.WriteLine(string.Format("**Audio synced**"));
// Console.WriteLine(string.Format("Remote Server Time {0}", new DateTime(sync.ServerTimeTicks).ToLongTimeString()));
// Console.WriteLine(string.Format("Remote Track Time: {0}", sync.TrackPosition));
// Console.WriteLine(string.Format("Local Server Time: {0}", time.DateTime.ToLongTimeString()));
// Console.WriteLine(string.Format("Local Track Time: {0}", _mediaPlayer.Position));
// Console.WriteLine(string.Format("Offset: {0}", offset));
// Console.WriteLine(string.Format("Old Position: {0}", oldPosition));
// Console.WriteLine(string.Format("New Position: {0}", newPosition));
System.Diagnostics.Debug.WriteLine(string.Format("**Audio synced**"));
// System.Diagnostics.Debug.WriteLine(string.Format("Remote Server Time {0}", new DateTime(sync.ServerTimeTicks).ToLongTimeString()));
// System.Diagnostics.Debug.WriteLine(string.Format("Remote Track Time: {0}", sync.TrackPosition));
// System.Diagnostics.Debug.WriteLine(string.Format("Local Server Time: {0}", time.DateTime.ToLongTimeString()));
// System.Diagnostics.Debug.WriteLine(string.Format("Local Track Time: {0}", _mediaPlayer.Position));
// System.Diagnostics.Debug.WriteLine(string.Format("Offset: {0}", offset));
// System.Diagnostics.Debug.WriteLine(string.Format("Old Position: {0}", oldPosition));
// System.Diagnostics.Debug.WriteLine(string.Format("New Position: {0}", newPosition));
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Exception caught while attempting to sync: " + ex.Message);
System.Diagnostics.Debug.WriteLine("Exception caught while attempting to sync: " + ex.Message);
}
}
});

View File

@ -73,7 +73,7 @@ namespace Aurora.Services
try
{
Console.WriteLine(string.Format("Starting gRPC server at hostname: {0}, port: {1}", _hostname, _port));
System.Diagnostics.Debug.WriteLine(string.Format("Starting gRPC server at hostname: {0}, port: {1}", _hostname, _port));
if (!Initialized)
{
@ -93,7 +93,7 @@ namespace Aurora.Services
}
catch (Exception ex)
{
Console.WriteLine(string.Format("Error starting gRPC server: {0}", ex.Message));
System.Diagnostics.Debug.WriteLine(string.Format("Error starting gRPC server: {0}", ex.Message));
}
}

View File

@ -73,7 +73,7 @@ namespace Aurora.Utils
}
catch (Exception ex)
{
Console.WriteLine($"{ex.GetType()} {ex.Message}\n{ex.StackTrace}");
System.Diagnostics.Debug.WriteLine($"{ex.GetType()} {ex.Message}\n{ex.StackTrace}");
ex = ex.InnerException;
}
}