Able to return to the Player view by taping on the player indicator now. Added progress bar on the player indicator as well as the artist of the song
This commit is contained in:
@@ -405,8 +405,15 @@ namespace Mear.Playback
|
|||||||
}
|
}
|
||||||
|
|
||||||
var song = _mearQueue.ToArray()[_songIndex++];
|
var song = _mearQueue.ToArray()[_songIndex++];
|
||||||
|
if (song.Downloaded)
|
||||||
|
{
|
||||||
PlaySong(song.SongPath);
|
PlaySong(song.SongPath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StreamSong(song);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
private StackLayout _playerIndicatorLayout;
|
private StackLayout _playerIndicatorLayout;
|
||||||
|
private ProgressBar _songProgress;
|
||||||
private Button _controlButton;
|
private Button _controlButton;
|
||||||
|
private Label _songArtistLabel;
|
||||||
private Label _songTitleLabel;
|
private Label _songTitleLabel;
|
||||||
private AlbumViewModel _viewModel;
|
private AlbumViewModel _viewModel;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -33,15 +35,21 @@ namespace Mear.Views
|
|||||||
public AlbumView()
|
public AlbumView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
AddPlayerIndicator();
|
|
||||||
BackgroundControl();
|
|
||||||
|
|
||||||
BindingContext = _viewModel = new AlbumViewModel();
|
BindingContext = _viewModel = new AlbumViewModel();
|
||||||
|
|
||||||
|
Initialize();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
private async Task Initialize()
|
||||||
|
{
|
||||||
|
AddPlayerIndicator();
|
||||||
|
BackgroundControl();
|
||||||
|
BackgroundSongProgress();
|
||||||
|
}
|
||||||
private async Task AddPlayerIndicator()
|
private async Task AddPlayerIndicator()
|
||||||
{
|
{
|
||||||
var mainLayout = AlbumViewMainLayout;
|
var mainLayout = AlbumViewMainLayout;
|
||||||
@@ -55,28 +63,53 @@ namespace Mear.Views
|
|||||||
private async Task<StackLayout> ConfigureSongIndicatorLayout()
|
private async Task<StackLayout> ConfigureSongIndicatorLayout()
|
||||||
{
|
{
|
||||||
var indicatorLayout = new StackLayout();
|
var indicatorLayout = new StackLayout();
|
||||||
|
var songDetailLayout = new StackLayout();
|
||||||
indicatorLayout.Orientation = StackOrientation.Horizontal;
|
indicatorLayout.Orientation = StackOrientation.Horizontal;
|
||||||
|
indicatorLayout.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
indicatorLayout.MinimumWidthRequest = 400;
|
||||||
indicatorLayout.Padding = 5;
|
indicatorLayout.Padding = 5;
|
||||||
|
|
||||||
|
_songProgress = new ProgressBar();
|
||||||
|
_songProgress.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
_songProgress.MinimumWidthRequest = 400;
|
||||||
|
_songProgress.Progress = 0;
|
||||||
|
|
||||||
_controlButton = new Button();
|
_controlButton = new Button();
|
||||||
_controlButton.Clicked += ControlButton_Clicked;
|
_controlButton.Clicked += ControlButton_Clicked;
|
||||||
_songTitleLabel = new Label();
|
_songTitleLabel = new Label();
|
||||||
_songTitleLabel.HorizontalOptions = LayoutOptions.Center;
|
_songTitleLabel.FontSize = 13;
|
||||||
|
_songTitleLabel.HorizontalOptions = LayoutOptions.Start;
|
||||||
_songTitleLabel.VerticalOptions = LayoutOptions.Start;
|
_songTitleLabel.VerticalOptions = LayoutOptions.Start;
|
||||||
|
_songArtistLabel = new Label();
|
||||||
|
_songArtistLabel.FontSize = 10;
|
||||||
|
|
||||||
var isSongPlayer = MearPlayer.IsPlaying();
|
var isSongPlayer = MearPlayer.IsPlaying();
|
||||||
|
|
||||||
if (isSongPlayer)
|
if (isSongPlayer)
|
||||||
{
|
{
|
||||||
_controlButton.Text = "P";
|
_controlButton.Text = "P";
|
||||||
_songTitleLabel.Text = await MearPlayer.SongTitle();
|
_songTitleLabel.Text = MearPlayer.OnSong.Title;
|
||||||
|
_songArtistLabel.Text = MearPlayer.OnSong.Artist;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_controlButton.Text = "S";
|
_controlButton.Text = "S";
|
||||||
_songTitleLabel.Text = string.Empty;
|
_songTitleLabel.Text = string.Empty;
|
||||||
|
_songArtistLabel.Text = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_songTitleLabel.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
|
||||||
|
var tapped = new TapGestureRecognizer();
|
||||||
|
tapped.Tapped += OpenPlayer;
|
||||||
|
songDetailLayout.GestureRecognizers.Add(tapped);
|
||||||
|
|
||||||
|
songDetailLayout.Children.Add(_songTitleLabel);
|
||||||
|
songDetailLayout.Children.Add(_songArtistLabel);
|
||||||
|
songDetailLayout.Children.Add(_songProgress);
|
||||||
|
|
||||||
indicatorLayout.Children.Add(_controlButton);
|
indicatorLayout.Children.Add(_controlButton);
|
||||||
indicatorLayout.Children.Add(_songTitleLabel);
|
indicatorLayout.Children.Add(songDetailLayout);
|
||||||
|
|
||||||
return indicatorLayout;
|
return indicatorLayout;
|
||||||
}
|
}
|
||||||
@@ -94,7 +127,8 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
if (MearPlayer.SongHasBeenChanged(MearPlayer.MusicViews.Album))
|
if (MearPlayer.SongHasBeenChanged(MearPlayer.MusicViews.Album))
|
||||||
{
|
{
|
||||||
_songTitleLabel.Text = MearPlayer.SongTitle().Result;
|
_songTitleLabel.Text = MearPlayer.OnSong.Title;
|
||||||
|
_songArtistLabel.Text = MearPlayer.OnSong.Artist;
|
||||||
MearPlayer.ResetSongChange(MearPlayer.MusicViews.Album);
|
MearPlayer.ResetSongChange(MearPlayer.MusicViews.Album);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -107,9 +141,42 @@ namespace Mear.Views
|
|||||||
var msg = ex.Message;
|
var msg = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private async Task BackgroundSongProgress()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new Thread(async () =>
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
|
{
|
||||||
|
var progress = MearPlayer.ProgressValue().Result;
|
||||||
|
if (progress != null)
|
||||||
|
{
|
||||||
|
_songProgress.Progress = progress.Value / 100.0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await Task.Delay(250);
|
||||||
|
}
|
||||||
|
}).Start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
private async void OpenPlayer(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MearPlayer.IsPlaying())
|
||||||
|
{
|
||||||
|
Navigation.PushModalAsync(new NavigationPage(new MearPlayerView(MearPlayer.OnSong)));
|
||||||
|
}
|
||||||
|
}
|
||||||
private async void ControlButton_Clicked(object sender, EventArgs e)
|
private async void ControlButton_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MearPlayer.IsPlaying())
|
if (MearPlayer.IsPlaying())
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
private StackLayout _playerIndicatorLayout;
|
private StackLayout _playerIndicatorLayout;
|
||||||
|
private ProgressBar _songProgress;
|
||||||
private Button _controlButton;
|
private Button _controlButton;
|
||||||
|
private Label _songArtistLabel;
|
||||||
private Label _songTitleLabel;
|
private Label _songTitleLabel;
|
||||||
private ArtistViewModel _viewModel;
|
private ArtistViewModel _viewModel;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -33,8 +35,7 @@ namespace Mear.Views
|
|||||||
public ArtistView()
|
public ArtistView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
AddPlayerIndicator();
|
Initialize();
|
||||||
BackgroundControl();
|
|
||||||
|
|
||||||
BindingContext = _viewModel = new ArtistViewModel();
|
BindingContext = _viewModel = new ArtistViewModel();
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,12 @@ namespace Mear.Views
|
|||||||
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
private async Task Initialize()
|
||||||
|
{
|
||||||
|
AddPlayerIndicator();
|
||||||
|
BackgroundControl();
|
||||||
|
BackgroundSongProgress();
|
||||||
|
}
|
||||||
private async Task AddPlayerIndicator()
|
private async Task AddPlayerIndicator()
|
||||||
{
|
{
|
||||||
var mainLayout = ArtistViewMainLayout;
|
var mainLayout = ArtistViewMainLayout;
|
||||||
@@ -55,28 +62,54 @@ namespace Mear.Views
|
|||||||
private async Task<StackLayout> ConfigureSongIndicatorLayout()
|
private async Task<StackLayout> ConfigureSongIndicatorLayout()
|
||||||
{
|
{
|
||||||
var indicatorLayout = new StackLayout();
|
var indicatorLayout = new StackLayout();
|
||||||
|
var songDetailLayout = new StackLayout();
|
||||||
|
songDetailLayout.Orientation = StackOrientation.Vertical;
|
||||||
indicatorLayout.Orientation = StackOrientation.Horizontal;
|
indicatorLayout.Orientation = StackOrientation.Horizontal;
|
||||||
|
indicatorLayout.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
indicatorLayout.MinimumWidthRequest = 400;
|
||||||
indicatorLayout.Padding = 5;
|
indicatorLayout.Padding = 5;
|
||||||
|
|
||||||
|
_songProgress = new ProgressBar();
|
||||||
|
_songProgress.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
_songProgress.MinimumWidthRequest = 400;
|
||||||
|
_songProgress.Progress = 0;
|
||||||
|
|
||||||
_controlButton = new Button();
|
_controlButton = new Button();
|
||||||
_controlButton.Clicked += ControlButton_Clicked;
|
_controlButton.Clicked += ControlButton_Clicked;
|
||||||
_songTitleLabel = new Label();
|
_songTitleLabel = new Label();
|
||||||
_songTitleLabel.HorizontalOptions = LayoutOptions.Center;
|
_songTitleLabel.FontSize = 13;
|
||||||
|
_songTitleLabel.HorizontalOptions = LayoutOptions.Start;
|
||||||
_songTitleLabel.VerticalOptions = LayoutOptions.Start;
|
_songTitleLabel.VerticalOptions = LayoutOptions.Start;
|
||||||
|
_songArtistLabel = new Label();
|
||||||
|
_songArtistLabel.FontSize = 10;
|
||||||
|
|
||||||
var isSongPlayer = MearPlayer.IsPlaying();
|
var isSongPlayer = MearPlayer.IsPlaying();
|
||||||
|
|
||||||
if (isSongPlayer)
|
if (isSongPlayer)
|
||||||
{
|
{
|
||||||
_controlButton.Text = "P";
|
_controlButton.Text = "P";
|
||||||
_songTitleLabel.Text = await MearPlayer.SongTitle();
|
_songTitleLabel.Text = MearPlayer.OnSong.Title;
|
||||||
|
_songArtistLabel.Text = MearPlayer.OnSong.Artist;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_controlButton.Text = "S";
|
_controlButton.Text = "S";
|
||||||
_songTitleLabel.Text = string.Empty;
|
_songTitleLabel.Text = string.Empty;
|
||||||
|
_songArtistLabel.Text = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_songTitleLabel.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
|
||||||
|
var tapped = new TapGestureRecognizer();
|
||||||
|
tapped.Tapped += OpenPlayer;
|
||||||
|
songDetailLayout.GestureRecognizers.Add(tapped);
|
||||||
|
|
||||||
|
songDetailLayout.Children.Add(_songTitleLabel);
|
||||||
|
songDetailLayout.Children.Add(_songArtistLabel);
|
||||||
|
songDetailLayout.Children.Add(_songProgress);
|
||||||
|
|
||||||
indicatorLayout.Children.Add(_controlButton);
|
indicatorLayout.Children.Add(_controlButton);
|
||||||
indicatorLayout.Children.Add(_songTitleLabel);
|
indicatorLayout.Children.Add(songDetailLayout);
|
||||||
|
|
||||||
return indicatorLayout;
|
return indicatorLayout;
|
||||||
}
|
}
|
||||||
@@ -94,7 +127,8 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
if (MearPlayer.SongHasBeenChanged(MearPlayer.MusicViews.Artist))
|
if (MearPlayer.SongHasBeenChanged(MearPlayer.MusicViews.Artist))
|
||||||
{
|
{
|
||||||
_songTitleLabel.Text = MearPlayer.SongTitle().Result;
|
_songTitleLabel.Text = MearPlayer.OnSong.Title;
|
||||||
|
_songArtistLabel.Text = MearPlayer.OnSong.Artist;
|
||||||
MearPlayer.ResetSongChange(MearPlayer.MusicViews.Artist);
|
MearPlayer.ResetSongChange(MearPlayer.MusicViews.Artist);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -107,9 +141,42 @@ namespace Mear.Views
|
|||||||
var msg = ex.Message;
|
var msg = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private async Task BackgroundSongProgress()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new Thread(async () =>
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
|
{
|
||||||
|
var progress = MearPlayer.ProgressValue().Result;
|
||||||
|
if (progress != null)
|
||||||
|
{
|
||||||
|
_songProgress.Progress = progress.Value / 100.0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await Task.Delay(250);
|
||||||
|
}
|
||||||
|
}).Start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
private async void OpenPlayer(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MearPlayer.IsPlaying())
|
||||||
|
{
|
||||||
|
Navigation.PushModalAsync(new NavigationPage(new MearPlayerView(MearPlayer.OnSong)));
|
||||||
|
}
|
||||||
|
}
|
||||||
private async void ControlButton_Clicked(object sender, EventArgs e)
|
private async void ControlButton_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MearPlayer.IsPlaying())
|
if (MearPlayer.IsPlaying())
|
||||||
|
|||||||
@@ -46,6 +46,17 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
MearPlayer.OnSong = song;
|
MearPlayer.OnSong = song;
|
||||||
|
|
||||||
|
Initialize();
|
||||||
|
|
||||||
|
BindingContext = _viewModel = new MearPlayerViewModel(song);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
private async Task Initialize()
|
||||||
|
{
|
||||||
InitializeControls();
|
InitializeControls();
|
||||||
|
|
||||||
BackgroundSongElasping();
|
BackgroundSongElasping();
|
||||||
@@ -54,13 +65,7 @@ namespace Mear.Views
|
|||||||
//BackgroundControlInit();
|
//BackgroundControlInit();
|
||||||
|
|
||||||
InitializeOptions();
|
InitializeOptions();
|
||||||
|
|
||||||
BindingContext = _viewModel = new MearPlayerViewModel(song);
|
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
private ToolbarItem DownloadOption()
|
private ToolbarItem DownloadOption()
|
||||||
{
|
{
|
||||||
var dnloadOpt = new ToolbarItem();
|
var dnloadOpt = new ToolbarItem();
|
||||||
@@ -117,14 +122,17 @@ namespace Mear.Views
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Device.BeginInvokeOnMainThread(async () =>
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
|
{
|
||||||
|
if (MearPlayer.IsPlaying())
|
||||||
{
|
{
|
||||||
var curPos = await MearPlayer.ConvertToTime();
|
var curPos = await MearPlayer.ConvertToTime();
|
||||||
StartTime.Text = $"{curPos}";
|
StartTime.Text = $"{curPos}";
|
||||||
double? progVal = await MearPlayer.ProgressValue();
|
double? progVal = await MearPlayer.ProgressValue();
|
||||||
SongProgress.Value = progVal.Value;
|
SongProgress.Value = progVal.Value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await Task.Delay(500);
|
await Task.Delay(250);
|
||||||
}
|
}
|
||||||
}).Start();
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
private StackLayout _playerIndicatorLayout;
|
private StackLayout _playerIndicatorLayout;
|
||||||
|
private ProgressBar _songProgress;
|
||||||
private Button _controlButton;
|
private Button _controlButton;
|
||||||
|
private Label _songArtistLabel;
|
||||||
private Label _songTitleLabel;
|
private Label _songTitleLabel;
|
||||||
private SongViewModel _viewModel;
|
private SongViewModel _viewModel;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -39,13 +41,19 @@ namespace Mear.Views
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
BindingContext = _viewModel = new SongViewModel();
|
BindingContext = _viewModel = new SongViewModel();
|
||||||
AddPlayerIndicator();
|
|
||||||
BackgroundControl();
|
Initialize();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
private async Task Initialize()
|
||||||
|
{
|
||||||
|
AddPlayerIndicator();
|
||||||
|
BackgroundControl();
|
||||||
|
BackgroundSongProgress();
|
||||||
|
}
|
||||||
private async Task AddPlayerIndicator()
|
private async Task AddPlayerIndicator()
|
||||||
{
|
{
|
||||||
var mainLayout = SongViewMainLayout;
|
var mainLayout = SongViewMainLayout;
|
||||||
@@ -59,33 +67,66 @@ namespace Mear.Views
|
|||||||
private async Task<StackLayout> ConfigureSongIndicatorLayout()
|
private async Task<StackLayout> ConfigureSongIndicatorLayout()
|
||||||
{
|
{
|
||||||
var indicatorLayout = new StackLayout();
|
var indicatorLayout = new StackLayout();
|
||||||
|
var songDetailLayout = new StackLayout();
|
||||||
|
songDetailLayout.Orientation = StackOrientation.Vertical;
|
||||||
indicatorLayout.Orientation = StackOrientation.Horizontal;
|
indicatorLayout.Orientation = StackOrientation.Horizontal;
|
||||||
|
indicatorLayout.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
indicatorLayout.MinimumWidthRequest = 400;
|
||||||
indicatorLayout.Padding = 5;
|
indicatorLayout.Padding = 5;
|
||||||
|
|
||||||
|
_songProgress = new ProgressBar();
|
||||||
|
_songProgress.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
_songProgress.MinimumWidthRequest = 400;
|
||||||
|
_songProgress.Progress = 0;
|
||||||
|
|
||||||
_controlButton = new Button();
|
_controlButton = new Button();
|
||||||
_controlButton.Clicked += ControlButton_Clicked;
|
_controlButton.Clicked += ControlButton_Clicked;
|
||||||
_songTitleLabel = new Label();
|
_songTitleLabel = new Label();
|
||||||
_songTitleLabel.HorizontalOptions = LayoutOptions.Center;
|
_songTitleLabel.FontSize = 13;
|
||||||
|
_songTitleLabel.HorizontalOptions = LayoutOptions.Start;
|
||||||
_songTitleLabel.VerticalOptions = LayoutOptions.Start;
|
_songTitleLabel.VerticalOptions = LayoutOptions.Start;
|
||||||
|
_songArtistLabel = new Label();
|
||||||
|
_songArtistLabel.FontSize = 10;
|
||||||
|
|
||||||
var isSongPlayer = MearPlayer.IsPlaying();
|
var isSongPlayer = MearPlayer.IsPlaying();
|
||||||
|
|
||||||
if (isSongPlayer)
|
if (isSongPlayer)
|
||||||
{
|
{
|
||||||
_controlButton.Text = "P";
|
_controlButton.Text = "P";
|
||||||
_songTitleLabel.Text = await MearPlayer.SongTitle();
|
_songTitleLabel.Text = MearPlayer.OnSong.Title;
|
||||||
|
_songArtistLabel.Text = MearPlayer.OnSong.Artist;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_controlButton.Text = "S";
|
_controlButton.Text = "S";
|
||||||
_songTitleLabel.Text = string.Empty;
|
_songTitleLabel.Text = string.Empty;
|
||||||
|
_songArtistLabel.Text = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_songTitleLabel.HorizontalOptions = LayoutOptions.Fill;
|
||||||
|
|
||||||
|
var tapped = new TapGestureRecognizer();
|
||||||
|
tapped.Tapped += OpenPlayer;
|
||||||
|
songDetailLayout.GestureRecognizers.Add(tapped);
|
||||||
|
|
||||||
|
songDetailLayout.Children.Add(_songTitleLabel);
|
||||||
|
songDetailLayout.Children.Add(_songArtistLabel);
|
||||||
|
songDetailLayout.Children.Add(_songProgress);
|
||||||
|
|
||||||
indicatorLayout.Children.Add(_controlButton);
|
indicatorLayout.Children.Add(_controlButton);
|
||||||
indicatorLayout.Children.Add(_songTitleLabel);
|
indicatorLayout.Children.Add(songDetailLayout);
|
||||||
|
|
||||||
return indicatorLayout;
|
return indicatorLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
private async void OpenPlayer(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MearPlayer.IsPlaying())
|
||||||
|
{
|
||||||
|
Navigation.PushModalAsync(new NavigationPage(new MearPlayerView(MearPlayer.OnSong)));
|
||||||
|
}
|
||||||
|
}
|
||||||
private async void ControlButton_Clicked(object sender, EventArgs e)
|
private async void ControlButton_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MearPlayer.IsPlaying())
|
if (MearPlayer.IsPlaying())
|
||||||
@@ -160,7 +201,8 @@ namespace Mear.Views
|
|||||||
{
|
{
|
||||||
if (MearPlayer.SongHasBeenChanged(MearPlayer.MusicViews.Song))
|
if (MearPlayer.SongHasBeenChanged(MearPlayer.MusicViews.Song))
|
||||||
{
|
{
|
||||||
_songTitleLabel.Text = MearPlayer.SongTitle().Result;
|
_songTitleLabel.Text = MearPlayer.OnSong.Title;
|
||||||
|
_songArtistLabel.Text = MearPlayer.OnSong.Artist;
|
||||||
MearPlayer.ResetSongChange(MearPlayer.MusicViews.Song);
|
MearPlayer.ResetSongChange(MearPlayer.MusicViews.Song);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -173,6 +215,32 @@ namespace Mear.Views
|
|||||||
var msg = ex.Message;
|
var msg = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private async Task BackgroundSongProgress()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new Thread(async () =>
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Device.BeginInvokeOnMainThread(async () =>
|
||||||
|
{
|
||||||
|
var progress = MearPlayer.ProgressValue().Result;
|
||||||
|
if (progress != null)
|
||||||
|
{
|
||||||
|
_songProgress.Progress = progress.Value / 100.0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await Task.Delay(250);
|
||||||
|
}
|
||||||
|
}).Start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Test
|
#region Test
|
||||||
|
|||||||
Reference in New Issue
Block a user