--- /dev/null
+using System;
+using MusicPlayer.Views;
+using MusicPlayer.ViewModels;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using MusicPlayer.Models;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Core
+{
+ class PlayingTrackEventHandlerArgs : EventArgs
+ {
+ public PlayingTrackEventHandlerArgs(string mediaId)
+ {
+ CurrentTrackId = mediaId;
+ }
+
+ public string CurrentTrackId { get; private set; }
+ }
+ class CurrentPlayingTrack
+ {
+ private static readonly CurrentPlayingTrack instance = new CurrentPlayingTrack();
+
+ public event EventHandler<PlayingTrackEventHandlerArgs> PlayingTrackChanged;
+
+ public CurrentPlayingTrack()
+ {
+ MediaId = null;
+ }
+
+ public static CurrentPlayingTrack Instance
+ {
+ get => instance;
+ }
+
+ public string MediaId { get; private set; }
+
+ public void SetMediaId(string id)
+ {
+ MediaId = id;
+ Tizen.Log.Info(AppConstants.LogTag, "Updating Current track");
+ PlayingTrackChanged?.Invoke(this, new PlayingTrackEventHandlerArgs(id));
+ }
+ }
+}
UpdateAlbumDetailData();\r
TotalTracks = listViewModel.Count.ToString();\r
listViewModel.CollectionChanged += OnCollectionChanged;\r
+ CurrentPlayingTrack.Instance.PlayingTrackChanged += OnPlayingTrackChanged;\r
}\r
\r
+ private void OnPlayingTrackChanged(object sender, PlayingTrackEventHandlerArgs e)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "On Current track Changed");\r
+ UpdatePlayingTrack();\r
+ }\r
+\r
+ public Track PlayingTrack { get; set; }\r
+\r
private int id;\r
\r
public int Id\r
{\r
AlbumDataProvider.AlbumDataChanged -= OnAlbumDetailChanged;\r
ListViewModel.CollectionChanged -= OnCollectionChanged;\r
- ListViewModel.Clear();\r
+ //ListViewModel.Clear();\r
}\r
\r
public void PlayAll()\r
listViewModel.Clear();\r
List<AudioInfo> trackList = AlbumDataProvider.GetAlbumTrackList(Id);\r
listViewModel.CreateData(trackList);\r
+ UpdatePlayingTrack();\r
+ }\r
+\r
+ private void UpdatePlayingTrack()\r
+ {\r
+ if (PlayingTrack != null)\r
+ {\r
+ PlayingTrack.IsPlaying = false;\r
+ }\r
+ PlayingTrack = null;\r
+ string currentTrackId = CurrentPlayingTrack.Instance.MediaId;\r
+ if (currentTrackId != null)\r
+ {\r
+ foreach (Track item in listViewModel)\r
+ {\r
+ if (currentTrackId == item.Id)\r
+ {\r
+ item.IsPlaying = true;\r
+ PlayingTrack = item;\r
+ break;\r
+ }\r
+ }\r
+ }\r
}\r
\r
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)\r
groupListViewModel = new ListViewModel<ArtistDetailAlbum>();
UpdateArtistDetailView();
+ CurrentPlayingTrack.Instance.PlayingTrackChanged += OnPlayingTrackChanged;
}
+ private void OnPlayingTrackChanged(object sender, PlayingTrackEventHandlerArgs e)
+ {
+ Tizen.Log.Info(AppConstants.LogTag, "On Current track Changed");
+ UpdatePlayingTrack();
+ }
+
+ public Track PlayingTrack { get; set; }
+
private string artistName;
public string ArtistName
public void OnViewDeleted()
{
ArtistDataProvider.ArtistDataChanged -= OnArtistDetailChanged;
- trackListViewModel.Clear();
- albumListViewModel.Clear();
- groupListViewModel.Clear();
+ //trackListViewModel.Clear();
+ //albumListViewModel.Clear();
+ //groupListViewModel.Clear();
}
public void PlayAll()
}
groupListViewModel.Add(artistAlbum);
}
+ UpdatePlayingTrack();
+ }
+
+ private void UpdatePlayingTrack()
+ {
+ if (PlayingTrack != null)
+ {
+ PlayingTrack.IsPlaying = false;
+ }
+ PlayingTrack = null;
+ string currentTrackId = CurrentPlayingTrack.Instance.MediaId;
+ if (currentTrackId != null)
+ {
+ foreach (Track item in TrackListViewModel)
+ {
+ if (currentTrackId == item.Id)
+ {
+ item.IsPlaying = true;
+ PlayingTrack = item;
+ break;
+ }
+ }
+ }
}
}
}
{
Tizen.Log.Info(AppConstants.LogTag, "Setting Current track");
UpdateCurrentPlayingTrack(track);
- playerModel.CurrentTrack = track;
- lyricsViewModel.CurrentTrack = track;
//TO DO need to set index properly
Track current = playingListViewModel.Current();
if (current == null)
private void UpdateCurrentPlayingTrack(Track newTrack)
{
- Track oldTrack = playerModel.CurrentTrack;
- if(oldTrack != null)
- {
- oldTrack.IsPlaying = false;
- }
- if (newTrack != null)
- {
- newTrack.IsPlaying = true;
- }
+ playerModel.CurrentTrack = newTrack;
+ lyricsViewModel.CurrentTrack = newTrack;
+ CurrentPlayingTrack.Instance.SetMediaId(newTrack.Id);
}
private void UpdatePlayingStatus(PlayingStatus status)
UpdatePlaylistDetails();
PlaylistTrackCount = listViewModel.Count.ToString();
ListViewModel.CollectionChanged += OnCollectionChanged;
+ CurrentPlayingTrack.Instance.PlayingTrackChanged += OnPlayingTrackChanged;
+ }
+
+ private void OnPlayingTrackChanged(object sender, PlayingTrackEventHandlerArgs e)
+ {
+ Tizen.Log.Info(AppConstants.LogTag, "On Current track Changed");
+ UpdatePlayingTrack();
}
public string PlaylistName { get; set; }
set => isNotDefaultPlaylist = value;
}
+ public Track PlayingTrack { get; set; }
+
// TODO do we really need this ?
public void OnViewDeleted()
{
PlaylistManager.Instance.PlaylistDataChanged -= OnPlaylistDetailChanged;
ListViewModel.CollectionChanged -= OnCollectionChanged;
- ListViewModel.Clear();
+ //ListViewModel.Clear();
}
public void PlayAll()
}
listViewModel.Clear();
listViewModel.CreateData(CreatePlaylistAudioData(playlist.Id));
+ UpdatePlayingTrack();
+ }
+
+ private void UpdatePlayingTrack()
+ {
+ string currentTrackId = CurrentPlayingTrack.Instance.MediaId;
+ string oldTrackId = null;
+ if (PlayingTrack != null)
+ {
+ oldTrackId = PlayingTrack.Id;
+ }
+ if (currentTrackId != oldTrackId)
+ {
+ PlayingTrack = null;
+ foreach (Track item in listViewModel)
+ {
+ if (oldTrackId == item.Id)
+ {
+ item.IsPlaying = false;
+ }
+ if (currentTrackId == item.Id)
+ {
+ item.IsPlaying = true;
+ PlayingTrack = item;
+ }
+ }
+ }
}
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
CreateTrackData();\r
listViewModel.CollectionChanged += OnCollectionChanged;\r
TrackCount = listViewModel.Count.ToString();\r
+ CurrentPlayingTrack.Instance.PlayingTrackChanged += OnPlayingTrackChanged;\r
+ }\r
+\r
+ private void OnPlayingTrackChanged(object sender, PlayingTrackEventHandlerArgs e)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "On Current track Changed");\r
+ UpdatePlayingTrack();\r
}\r
\r
private readonly ListViewModel<Track> listViewModel;\r
}\r
}\r
\r
+ public Track PlayingTrack { get; set; }\r
+\r
public void OnTrackSelected(object selectedItem)\r
{\r
PlaybackHelper.Instance.PlayCurrent(ListViewModel, (Track)selectedItem);\r
List<AudioInfo> trackList = TrackDataProvider.CurrentTrackList();\r
listViewModel.Clear();\r
listViewModel.CreateData(trackList);\r
+ UpdatePlayingTrack();\r
+ }\r
+\r
+ private void UpdatePlayingTrack()\r
+ {\r
+ if (PlayingTrack != null)\r
+ {\r
+ PlayingTrack.IsPlaying = false;\r
+ }\r
+ PlayingTrack = null;\r
+ string currentTrackId = CurrentPlayingTrack.Instance.MediaId;\r
+ if (currentTrackId != null)\r
+ {\r
+ foreach (Track item in listViewModel)\r
+ {\r
+ if (currentTrackId == item.Id)\r
+ {\r
+ item.IsPlaying = true;\r
+ PlayingTrack = item;\r
+ break;\r
+ }\r
+ }\r
+ }\r
}\r
\r
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)\r
using Tizen.NUI.Components;\r
using Tizen.NUI.BaseComponents;\r
using Tizen.NUI;\r
+using Tizen.NUI.Binding;\r
using MusicPlayer.Common;\r
\r
namespace MusicPlayer.Views\r
private const int LeftPadding = 64;\r
private const int X = 0;\r
\r
+ public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(nameof(IsPlaying), typeof(bool), typeof(AlbumDetailLayout), false, propertyChanged: (bindable, oldValue, newValue) =>\r
+ {\r
+ var instance = (AlbumDetailLayout)bindable;\r
+ if (newValue != null)\r
+ {\r
+ bool newPlaying = (bool)newValue;\r
+ bool oldPlaying = (bool)oldValue;\r
+ if (oldPlaying != newPlaying)\r
+ {\r
+ instance.UpdateItem(newPlaying);\r
+ }\r
+ }\r
+ },\r
+ defaultValueCreator: (bindable) => ((AlbumDetailLayout)bindable).isPlaying);\r
+\r
public AlbumDetailLayout(int width = 832, int height = 108) : base()\r
{\r
base.OnInitialize();\r
subtitleLabel = CreateSubTitleLabel();\r
additionalLabel = CreateAdditionalLabel(width);\r
itemSeperator = CreateItemSeparator(width, height);\r
- IsCreateByXaml = true;\r
+ UpdateLabelColors();\r
+ ThemeManager.ThemeChanged += OnThemeUpdated;\r
}\r
\r
private TextLabel CreateTitleLabel()\r
{\r
TextLabel titleLabel = new TextLabel()\r
{\r
- StyleName = "ItemLabel",\r
- ThemeChangeSensitive = true,\r
Size2D = new Size2D(596, 40),\r
PixelSize = 32,\r
FontFamily = "BreezeSans",\r
{\r
TextLabel subtitleLabel = new TextLabel()\r
{\r
- StyleName = "ItemLabel",\r
- ThemeChangeSensitive = true,\r
Size2D= new Size2D(596,36),\r
PixelSize = 28,\r
FontFamily = "BreezeSans",\r
{\r
TextLabel additionalLabel = new TextLabel()\r
{\r
- StyleName = "ItemLabel",\r
- ThemeChangeSensitive = true,\r
Size2D= new Size2D(108,36),\r
PixelSize = 28,\r
FontFamily = "BreezeSans",\r
get => additionalLabel;\r
}\r
\r
+ private bool isPlaying = false;\r
+\r
+ public bool IsPlaying\r
+ {\r
+ get => (bool)GetValue(IsPlayingProperty);\r
+ set => SetValue(IsPlayingProperty, value);\r
+ }\r
+\r
+ private void UpdateItem(bool currentValue)\r
+ {\r
+ if (currentValue)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "setting highlight color");\r
+ if (titleLabel != null)\r
+ {\r
+ titleLabel.TextColor = UIColors.HEX1473E6;\r
+ }\r
+ if (subtitleLabel != null)\r
+ {\r
+ subtitleLabel.TextColor = UIColors.HEX1473E6;\r
+ }\r
+ if (additionalLabel != null)\r
+ {\r
+ additionalLabel.TextColor = UIColors.HEX1473E6;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "setting normal color");\r
+ UpdateLabelColors();\r
+ }\r
+ isPlaying = currentValue;\r
+ }\r
+\r
+ private void OnThemeUpdated(object sender, ThemeChangedEventArgs e)\r
+ {\r
+ if (e.IsPlatformThemeChanged && IsPlaying == false)\r
+ {\r
+ UpdateLabelColors();\r
+ }\r
+ }\r
+\r
+ private void UpdateLabelColors()\r
+ {\r
+ string currentPlatformThemeId = ThemeManager.PlatformThemeId;\r
+ if (currentPlatformThemeId.Equals(AppConstants.LightPlatformThemeId))\r
+ {\r
+ if (titleLabel != null)\r
+ {\r
+ titleLabel.TextColor = UIColors.HEX001447;\r
+ }\r
+ if (subtitleLabel != null)\r
+ {\r
+ subtitleLabel.TextColor = UIColors.HEX001447;\r
+ }\r
+ if (additionalLabel != null)\r
+ {\r
+ additionalLabel.TextColor = UIColors.HEX001447;\r
+ }\r
+ }\r
+ else if (currentPlatformThemeId.Equals(AppConstants.DarkPlatformThemeId))\r
+ {\r
+ if (titleLabel != null)\r
+ {\r
+ titleLabel.TextColor = Color.White;\r
+ }\r
+ if (subtitleLabel != null)\r
+ {\r
+ subtitleLabel.TextColor = Color.White;\r
+ }\r
+ if (additionalLabel != null)\r
+ {\r
+ additionalLabel.TextColor = Color.White;\r
+ }\r
+ }\r
+ }\r
+\r
protected override void Dispose(DisposeTypes type)\r
{\r
if (Disposed)\r
UpdateCollectionView();\r
AddAlbumArt();\r
AddAlbumInfo();\r
+ TouchEvent += (object source, TouchEventArgs e) => false;\r
}\r
\r
public override string GetTitleText()\r
layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
layout.AdditionalLabel.SetBinding(TextLabel.TextProperty, "Duration");\r
+ layout.SetBinding(AlbumDetailLayout.IsPlayingProperty, "IsPlaying");\r
return layout;\r
});\r
collectionView.ItemsSource = viewModel.ListViewModel;\r
using Tizen.NUI.Components;
using Tizen.NUI.BaseComponents;
using Tizen.NUI;
+using Tizen.NUI.Binding;
using MusicPlayer.Common;
namespace MusicPlayer.Views
private TextLabel titleLabel;
private TextLabel extraLabel;
+ public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(nameof(IsPlaying), typeof(bool), typeof(ArtistDetailItemLayout), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (ArtistDetailItemLayout)bindable;
+ if (newValue != null)
+ {
+ bool newPlaying = (bool)newValue;
+ bool oldPlaying = (bool)oldValue;
+ if (oldPlaying != newPlaying)
+ {
+ instance.UpdateItem(newPlaying);
+ }
+ }
+ },
+ defaultValueCreator: (bindable) => ((ArtistDetailItemLayout)bindable).isPlaying);
+
public ArtistDetailItemLayout(int width = 1792, int height = 108) : base()
{
base.OnInitialize();
- base.IsCreateByXaml = true;
Width = width;
Height = height;
WidthSpecification = Width;
titleLabel = CreateTitleLabel();
extraLabel = CreateExtraLabel();
itemSeperator = CreateItemSeparator();
- IsCreateByXaml = true;
+ UpdateLabelColors();
+ ThemeManager.ThemeChanged += OnThemeUpdated;
}
private View CreateItemSeparator()
{
TextLabel titleLabel = new TextLabel()
{
- StyleName = "ItemLabel",
- ThemeChangeSensitive = true,
Size2D = new Size2D(1272, 40),
PixelSize = 32,
FontFamily = "BreezeSans",
{
TextLabel extraLabel = new TextLabel()
{
- StyleName = "ItemLabel",
- ThemeChangeSensitive = true,
Size2D = new Size2D(360, 36),
PixelSize = 28,
FontFamily = "BreezeSans",
get => extraLabel;
}
+ private bool isPlaying = false;
+
+ public bool IsPlaying
+ {
+ get => (bool)GetValue(IsPlayingProperty);
+ set => SetValue(IsPlayingProperty, value);
+ }
+
+ private void UpdateItem(bool currentValue)
+ {
+ if (currentValue)
+ {
+ Tizen.Log.Info(AppConstants.LogTag, "setting highlight color");
+ if (titleLabel != null)
+ {
+ titleLabel.TextColor = UIColors.HEX1473E6;
+ }
+ if (extraLabel != null)
+ {
+ extraLabel.TextColor = UIColors.HEX1473E6;
+ }
+ }
+ else
+ {
+ Tizen.Log.Info(AppConstants.LogTag, "setting normal color");
+ UpdateLabelColors();
+ }
+ isPlaying = currentValue;
+ }
+
+ private void OnThemeUpdated(object sender, ThemeChangedEventArgs e)
+ {
+ if (e.IsPlatformThemeChanged && IsPlaying == false)
+ {
+ UpdateLabelColors();
+ }
+ }
+
+ private void UpdateLabelColors()
+ {
+ string currentPlatformThemeId = ThemeManager.PlatformThemeId;
+ if (currentPlatformThemeId.Equals(AppConstants.LightPlatformThemeId))
+ {
+ if (titleLabel != null)
+ {
+ titleLabel.TextColor = UIColors.HEX001447;
+ }
+ if (extraLabel != null)
+ {
+ extraLabel.TextColor = UIColors.HEX001447;
+ }
+ }
+ else if (currentPlatformThemeId.Equals(AppConstants.DarkPlatformThemeId))
+ {
+ if (titleLabel != null)
+ {
+ titleLabel.TextColor = Color.White;
+ }
+ if(extraLabel != null)
+ {
+ extraLabel.TextColor = Color.White;
+ }
+ }
+ }
+
protected override void Dispose(DisposeTypes type)
{
if (Disposed)
countLabel.SetBinding(TextLabel.TextProperty, "TotalCount");
UpdateCollectionView();
Add(listContainer);
+ TouchEvent += (object source, TouchEventArgs e) => false;
}
public override string GetTitleText()
ArtistDetailItemLayout layout = new ArtistDetailItemLayout();
layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
layout.ExtraLabel.SetBinding(TextLabel.TextProperty, "Duration");
+ layout.SetBinding(ArtistDetailItemLayout.IsPlayingProperty, "IsPlaying");
return layout;
});
collectionView.GroupHeaderTemplate = new DataTemplate(() =>
private void OnItemSelected(object sender, SelectionChangedEventArgs e)
{
+ if (collectionView.SelectedItem == null)
+ {
+ return;
+ }
viewModel.OnItemSelected(collectionView.SelectedItem);
+ collectionView.SelectedItem = null;
}
private void ItemSourceChanged(object sender, EventArgs e)
layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");
layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");
- //layout.SetBinding(ListItemLayout.IsPlayingProperty, "IsPlaying"); //Need to Modify
+ layout.SetBinding(ListItemLayout.IsPlayingProperty, "IsPlaying");
return layout;
});
collectionView.SelectionChanged += OnTrackSelection;
layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");\r
layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
- //layout.SetBinding(ListItemLayout.IsPlayingProperty, "IsPlaying"); //Need to Modify\r
+ layout.SetBinding(ListItemLayout.IsPlayingProperty, "IsPlaying");\r
return layout;\r
});\r
collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;\r
</ItemGroup>\r
\r
<ItemGroup>\r
- <PackageReference Include="Tizen.NET" Version="10.0.0.16834">\r
+ <PackageReference Include="Tizen.NET" Version="10.0.0.16872">\r
<ExcludeAssets>Runtime</ExcludeAssets>\r
</PackageReference>\r
<PackageReference Include="Tizen.NET.Sdk" Version="1.1.6" />\r