--- /dev/null
+using Tizen.Multimedia;
+using System.ComponentModel;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Models
+{
+ class LyricsModel: PropertyNotifier
+ {
+ public LyricsModel()
+ {
+ }
+
+ public LyricsModel(string thumbPath, string lyrics)
+ {
+ ThumbPath = thumbPath;
+ Lyrics = lyrics;
+ }
+
+ private string thumbPath;
+
+ public string ThumbPath
+ {
+ get => thumbPath;
+ set => SetProperty(ref thumbPath, value);
+ }
+
+ private string lyrics;
+
+ public string Lyrics
+ {
+ get => lyrics;
+ set => SetProperty(ref lyrics, value);
+ }
+ }
+}
--- /dev/null
+using Tizen.Multimedia;
+using MusicPlayer.Models;
+
+namespace MusicPlayer.ViewModels
+{
+ class LyricsViewModel
+ {
+ internal LyricsModel lyricsModel;
+
+ public LyricsViewModel()
+ {
+ lyricsModel = new LyricsModel();
+ }
+
+ public LyricsViewModel(Track currentTrack)
+ {
+ FilePath = currentTrack.FilePath;
+ lyricsModel = new LyricsModel(currentTrack.ThumbnailPath, GetLyrics(FilePath));
+ }
+
+ public string FilePath { get; set; }
+
+ private Track currentTrack;
+
+ public Track CurrentTrack
+ {
+ get => currentTrack;
+ set
+ {
+ currentTrack = value;
+ FilePath = currentTrack.FilePath;
+ lyricsModel.ThumbPath = currentTrack.ThumbnailPath;
+ lyricsModel.Lyrics = GetLyrics(FilePath);
+ }
+ }
+
+ private string GetLyrics(string path)
+ {
+ var metadataExtractor = new MetadataExtractor(path);
+ Metadata metadata = metadataExtractor.GetMetadata();
+ return metadata.UnsyncLyrics;
+ }
+ }
+}
--- /dev/null
+using Tizen.NUI;
+using Tizen.NUI.Binding;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using MusicPlayer.ViewModels;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views
+{
+ class LyricsView : View
+ {
+ private const int ViewSize = 784;
+ private const int LyricsViewMargin = 40;
+ private const int LyricsViewSize = 704;
+
+ private readonly LyricsViewModel lyricsViewModel;
+
+ private ImageView thumbView;
+ private ScrollableBase scrollView;
+ private TextLabel lyricsLabel;
+
+ public LyricsView(LyricsViewModel lyricsViewModel) : base()
+ {
+ this.lyricsViewModel = lyricsViewModel;
+ BindingContext = lyricsViewModel.lyricsModel;
+ Size2D = new Size2D(ViewSize, ViewSize);
+
+ AddThumbnail();
+ AddLyricsView();
+ }
+
+ private void AddThumbnail()
+ {
+ thumbView = new ImageView()
+ {
+ HeightResizePolicy = ResizePolicyType.FillToParent,
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ };
+ thumbView.SetBinding(ImageView.ResourceUrlProperty, "ThumbPath");
+ base.Add(thumbView);
+ }
+
+ private void AddLyricsView()
+ {
+ scrollView = new ScrollableBase()
+ {
+ Position2D = new Position2D(LyricsViewMargin, LyricsViewMargin),
+ Size2D = new Size2D(LyricsViewSize, LyricsViewSize),
+ ScrollingDirection = ScrollableBase.Direction.Vertical,
+ };
+ base.Add(scrollView);
+
+ lyricsLabel = new TextLabel()
+ {
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ BackgroundColor = UIColors.LyricsBackground,
+ TextColor = Color.White,
+ MultiLine = true,
+ LineWrapMode = LineWrapMode.Word,
+ PointSize = 25.0f,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ };
+ lyricsLabel.SetBinding(TextLabel.TextProperty, "Lyrics");
+ scrollView.Add(lyricsLabel);
+ }
+ }
+}
{
class PlayerView : View
{
- private const int LAYOUT_PADDING = 64;
- private const int ICON_SIZE = 48;
- private const int TOPBAR_SIZE = 120;
- private const int CONTROL_VIEW_WIDTH = 640;
- private const int CONTROL_VIEW_HEIGHT = 384;
- private const int CONTROL_VIEW_MARGIN = 315;
+ private const int LayoutPadding = 64;
+ private const int IconSize = 48;
+ private const int TopBarSize = 120;
+ private const int ControlViewWidth = 640;
+ private const int ControlViewHeight = 384;
+ private const int ControlViewMargin = 315;
+ private const int TitleLabelHeight = 48;
+ private const int ArtistLabelHeight = 36;
private View leftView;
private View rightView;
Button button = new Button(buttonStyle)
{
- Size2D = new Size2D(ICON_SIZE, ICON_SIZE),
+ Size2D = new Size2D(IconSize, IconSize),
Position2D = new Position2D(x, y),
};
return button;
private void AddTopButtons()
{
- backButton = CreatButton(Resources.GetImagePath() + "back_button.png", LAYOUT_PADDING, (TOPBAR_SIZE / 2 - ICON_SIZE / 2));
+ backButton = CreatButton(Resources.GetImagePath() + "back_button.png", LayoutPadding, (TopBarSize / 2 - IconSize / 2));
leftView.Add(backButton);
- moreButton = CreatButton(Resources.GetImagePath() + "more_button.png", Window.Instance.WindowSize.Width / 2 - LAYOUT_PADDING - ICON_SIZE, (TOPBAR_SIZE / 2 - ICON_SIZE / 2));
+ moreButton = CreatButton(Resources.GetImagePath() + "more_button.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, (TopBarSize / 2 - IconSize / 2));
rightView.Add(moreButton);
}
controlsView = new View()
{
BackgroundColor = Color.Transparent,
- Size2D = new Size2D(640, 384),
- Position2D = new Position2D((Window.Instance.WindowSize.Width / 4 - CONTROL_VIEW_WIDTH / 2), TOPBAR_SIZE + CONTROL_VIEW_MARGIN),
+ Size2D = new Size2D(ControlViewWidth, ControlViewHeight),
+ Position2D = new Position2D((Window.Instance.WindowSize.Width / 4 - ControlViewWidth / 2), TopBarSize + ControlViewMargin),
};
rightView.Add(controlsView);
}
{
titleLabel = new TextLabel()
{
- Size2D = new Size2D(640, 48),
+ Size2D = new Size2D(ControlViewWidth, TitleLabelHeight),
Position2D = new Position2D(0, 0),
PixelSize = 36,
FontFamily = "BreezeSans",
artistLabel = new TextLabel()
{
- Size2D = new Size2D(640, 36),
+ Size2D = new Size2D(ControlViewWidth, ArtistLabelHeight),
Position2D = new Position2D(0, 62),
PixelSize = 28,
FontFamily = "BreezeSans",
{
leftVolumeIcon = new ImageView(Resources.GetImagePath() + "left_sound_icon.png")
{
- Size2D = new Size2D(ICON_SIZE, ICON_SIZE),
+ Size2D = new Size2D(IconSize, IconSize),
Position2D = new Position2D(0, 336),
};
controlsView.Add(leftVolumeIcon);
rightVolumeIcon = new ImageView(Resources.GetImagePath() + "right_sound_icon.png")
{
- Size2D = new Size2D(ICON_SIZE, ICON_SIZE),
+ Size2D = new Size2D(IconSize, IconSize),
Position2D = new Position2D(592, 336),
};
controlsView.Add(rightVolumeIcon);
View actionButtonView = new View()
{
Size2D = new Size2D(224, 48),
- Position2D = new Position2D((Window.Instance.WindowSize.Width / 2 - 224 - LAYOUT_PADDING), 120),
+ Position2D = new Position2D((Window.Instance.WindowSize.Width / 2 - 224 - LayoutPadding), 120),
BackgroundColor = Color.Transparent,
};
rightView.Add(actionButtonView);
{\r
class TrackLayout : RecyclerViewItem\r
{\r
+ private static int Width = 1792;\r
+ private static int Height = 108;\r
+\r
+ private const int IconSize = 64;\r
+ private const int LayoutMargin = 16;\r
+ private const int LayoutPadding = 32;\r
+ private const int SeperatorHeight = 1;\r
+ private const int LeftPadding = 64;\r
+ private const int x = 0;\r
+\r
private View itemSeperator;\r
private TextLabel titleLabel;\r
private TextLabel subtitleLabel;\r
private ImageView icon;\r
\r
- private static int WIDTH = 1792;\r
- private static int HEIGHT = 108;\r
-\r
- private const int ICON_SIZE = 64;\r
- private const int MARGIN = 16;\r
- private const int PADDING = 32;\r
- private const int SEPERATOR_HEIGHT = 1;\r
- private const int LEFT_PADDING = 64;\r
- private const int X = 0;\r
-\r
public TrackLayout(int width = 1792, int height = 108) : base()\r
{\r
base.OnInitialize();\r
base.IsCreateByXaml = true;\r
- WIDTH = width;\r
- HEIGHT = height;\r
- WidthSpecification = WIDTH;\r
- HeightSpecification = HEIGHT;\r
+ Width = width;\r
+ Height = height;\r
+ WidthSpecification = Width;\r
+ HeightSpecification = Height;\r
\r
// to show the rounded rect of the bg\r
BackgroundColor = Color.Transparent;\r
\r
icon = new ImageView()\r
{\r
- WidthSpecification = ICON_SIZE,\r
- HeightSpecification = ICON_SIZE,\r
+ WidthSpecification = IconSize,\r
+ HeightSpecification = IconSize,\r
IsCreateByXaml = true,\r
- Position2D = new Position2D(X, ((HEIGHT / 2) - (ICON_SIZE / 2))),\r
+ Position2D = new Position2D(x, ((Height / 2) - (IconSize / 2))),\r
};\r
base.Add(icon);\r
\r
itemSeperator = new View()\r
{\r
- WidthSpecification = (WIDTH - (2 * LEFT_PADDING)),\r
- HeightSpecification = SEPERATOR_HEIGHT,\r
+ WidthSpecification = (Width - (2 * LeftPadding)),\r
+ HeightSpecification = SeperatorHeight,\r
ExcludeLayouting = true,\r
- Position2D = new Position2D(X, HEIGHT - SEPERATOR_HEIGHT),\r
+ Position2D = new Position2D(x, Height - SeperatorHeight),\r
BackgroundColor = UIColors.ItemSeperator,\r
};\r
base.Add(itemSeperator);\r
\r
titleLabel = new TextLabel()\r
{\r
- WidthSpecification = (WIDTH - (2 * LEFT_PADDING) - ICON_SIZE - PADDING),\r
+ WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
HeightSpecification = 40,\r
TextColor = Color.Blue,\r
PixelSize = 32,\r
FontFamily = "BreezeSans",\r
VerticalAlignment = VerticalAlignment.Center,\r
IsCreateByXaml = true,\r
- Position2D = new Position2D((X + ICON_SIZE + PADDING), MARGIN),\r
+ Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin),\r
};\r
base.Add(titleLabel);\r
\r
subtitleLabel = new TextLabel()\r
{\r
- WidthSpecification = (WIDTH - (2 * LEFT_PADDING) - ICON_SIZE - PADDING),\r
+ WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
HeightSpecification = 36,\r
TextColor = Color.Black,\r
PixelSize = 28,\r
FontFamily = "BreezeSans",\r
VerticalAlignment = VerticalAlignment.Center,\r
IsCreateByXaml = true,\r
- Position2D = new Position2D((X + ICON_SIZE + PADDING), MARGIN + 40)\r
+ Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin + 40)\r
};\r
base.Add(subtitleLabel);\r
IsCreateByXaml = true;\r