-using Tizen.NUI;\r
-using Tizen.NUI.Components;\r
-using Tizen.NUI.BaseComponents;\r
-using Tizen.NUI.Binding;\r
-using MusicPlayer.Common;\r
-using MusicPlayer.ViewModels;\r
-using MusicPlayer.Views.Utils;\r
-using System.Collections.Generic;\r
-using MusicPlayer.Core;\r
-\r
-namespace MusicPlayer.Views\r
-{\r
- class MiniPlayer : View\r
- {\r
- private const int SliderHeight = 38;\r
- private ImageView thumbnail;\r
- private View trackInfo;\r
- private View trackTextView;\r
- private TextLabel titleLabel;\r
- private TextLabel artistLabel;\r
-\r
- private View controlsView;\r
- private View sliderView;\r
- private MultiStateButton playButton;\r
- private Button prevButton;\r
- private Button nextButton;\r
- private Slider playbackSlider;\r
- private TextLabel currentTime;\r
- private TextLabel totalTime;\r
- private View baseView;\r
- private readonly PlayerViewModel viewModel;\r
-\r
- public MiniPlayer(PlayerViewModel viewModel) : base()\r
- {\r
- this.viewModel = viewModel;\r
- BindingContext = viewModel.playerModel;\r
- StyleName = "MiniPlayer";\r
- ThemeChangeSensitive = true;\r
- WidthSpecification = LayoutParamPolicies.MatchParent;\r
- HeightSpecification = (DeviceInfo.IsPortrait ? 170 : 124).SpToPx();\r
-\r
- Layout = new LinearLayout()\r
- {\r
- LinearOrientation = LinearLayout.Orientation.Vertical,\r
- };\r
- AddSeparatorLine();\r
- baseView = new View()\r
- {\r
- WidthSpecification = LayoutParamPolicies.MatchParent,\r
- HeightSpecification = 123.SpToPx(),\r
- BackgroundColor = Color.Transparent,\r
- Layout = new LinearLayout()\r
- {\r
- LinearOrientation = LinearLayout.Orientation.Horizontal,\r
- VerticalAlignment = VerticalAlignment.Center,\r
- },\r
- Padding = new Extents(64, 64, 24, 19).SpToPx(),\r
- };\r
- if(DeviceInfo.IsPortrait)\r
- {\r
- baseView.Padding = new Extents(33, 33, 24, 8).SpToPx();\r
- baseView.HeightSpecification = 108.SpToPx();\r
- }\r
- Add(baseView);\r
- AddTrackDetails();\r
- AddControlElements();\r
- AddSliderElements();\r
- }\r
-\r
- private void AddSeparatorLine()\r
- {\r
- View separator = new View()\r
- {\r
- WidthSpecification = LayoutParamPolicies.MatchParent,\r
- HeightSpecification = 1.SpToPx(),\r
- StyleName = "InputLine",\r
- };\r
- Add(separator);\r
- }\r
-\r
- private void AddTrackDetails()\r
- {\r
- trackInfo = new View()\r
- {\r
- Layout = new LinearLayout()\r
- {\r
- LinearOrientation = LinearLayout.Orientation.Horizontal,\r
- },\r
- BackgroundColor = Color.Transparent,\r
- };\r
- trackInfo.WidthSpecification = (DeviceInfo.IsPortrait ? 536 : 622).SpToPx();\r
- trackInfo.HeightSpecification = 76.SpToPx();\r
- baseView.Add(trackInfo);\r
- AddThumbnail();\r
- AddTrackTextLabels();\r
- }\r
-\r
- private void AddTrackTextLabels()\r
- {\r
- trackTextView = new View()\r
- {\r
- BackgroundColor = Color.Transparent,\r
- Layout = new LinearLayout()\r
- {\r
- LinearOrientation = LinearLayout.Orientation.Vertical,\r
- },\r
- HeightSpecification = 76.SpToPx(),\r
- };\r
- if(DeviceInfo.IsPortrait)\r
- {\r
- trackTextView.WidthSpecification = 436.SpToPx();\r
- trackTextView.Margin = new Extents(24, 0, 0, 0);\r
- }\r
- else\r
- {\r
- trackTextView.WidthSpecification = 516.SpToPx();\r
- trackTextView.Margin = new Extents(30, 0, 0, 0);\r
- }\r
- trackInfo.Add(trackTextView);\r
- AddTrackName();\r
- AddArtistName();\r
- }\r
-\r
- private void AddThumbnail()\r
- {\r
- thumbnail = new ImageView()\r
- {\r
- BackgroundColor = UIColors.HEXEEEFF1,\r
- Size2D = new Size2D(76, 76).SpToPx(),\r
- };\r
- thumbnail.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");\r
- thumbnail.TouchEvent += (object source, TouchEventArgs e) =>\r
- {\r
- PlaybackHelper.Instance.ShowPlayer();\r
- return true;\r
- };\r
- trackInfo.Add(thumbnail);\r
- }\r
-\r
- private void AddTrackName()\r
- {\r
- titleLabel = new TextLabel()\r
- {\r
- StyleName = "TitleText",\r
- ThemeChangeSensitive = true,\r
- WidthSpecification = LayoutParamPolicies.MatchParent,\r
- HeightSpecification = 48.SpToPx(),\r
- PixelSize = 36.SpToPx(),\r
- FontFamily = "BreezeSans",\r
- HorizontalAlignment = HorizontalAlignment.Begin,\r
- VerticalAlignment = VerticalAlignment.Center,\r
- Ellipsis = true,\r
- };\r
- titleLabel.SetBinding(TextLabel.TextProperty, "TrackName");\r
- trackTextView.Add(titleLabel);\r
- }\r
-\r
- private void AddArtistName()\r
- {\r
- artistLabel = new TextLabel()\r
- {\r
- StyleName = "TitleText",\r
- ThemeChangeSensitive = true,\r
- WidthSpecification = LayoutParamPolicies.MatchParent,\r
- HeightSpecification = 28.SpToPx(),\r
- PixelSize = 22.SpToPx(),\r
- FontFamily = "BreezeSans",\r
- HorizontalAlignment = HorizontalAlignment.Begin,\r
- VerticalAlignment = VerticalAlignment.Center,\r
- Ellipsis = true,\r
- };\r
- artistLabel.SetBinding(TextLabel.TextProperty, "TrackArtist");\r
- trackTextView.Add(artistLabel);\r
- }\r
- private void AddControlElements()\r
- {\r
- controlsView = new View()\r
- {\r
- WidthSpecification = 304.SpToPx(),\r
- Layout = new LinearLayout()\r
- {\r
- LinearOrientation = LinearLayout.Orientation.Horizontal,\r
- HorizontalAlignment = HorizontalAlignment.Begin,\r
- VerticalAlignment = VerticalAlignment.Center,\r
- CellPadding = new Size2D(80, 0).SpToPx(),\r
- },\r
- Margin = new Extents(120, 120, 0, 0).SpToPx(),\r
- BackgroundColor = Color.Transparent,\r
- };\r
- baseView.Add(controlsView);\r
- AddPreviousButton();\r
- AddPlayButton();\r
- AddNextButton();\r
- }\r
-\r
- private void AddPreviousButton()\r
- {\r
- prevButton = new Button("PrevButton")\r
- {\r
- ThemeChangeSensitive = true,\r
- };\r
- prevButton.Clicked += (object sender, ClickedEventArgs e) =>\r
- {\r
- viewModel.PrevButtonClicked();\r
- };\r
- prevButton.BindingContext = viewModel;\r
- prevButton.SetBinding(IsEnabledProperty, "HasPreviousTrack");\r
- controlsView.Add(prevButton);\r
- }\r
-\r
- private void AddPlayButton()\r
- {\r
- playButton = new MultiStateButton()\r
- {\r
- Size2D = new Size2D(48, 48).SpToPx(),\r
- BackgroundColor = Color.Transparent,\r
- IconResources = new Dictionary<ThemeType, Dictionary<string, StringSelector>>()\r
- {\r
- {\r
- ThemeType.Light,\r
- new Dictionary<string, StringSelector>()\r
- {\r
- {\r
- "Play",\r
- new StringSelector()\r
- {\r
- Normal = Resources.GetImagePath() + "light/play.png",\r
- Pressed = Resources.GetImagePath() + "play_pressed.png",\r
- Disabled = Resources.GetImagePath() + "play_disabled.png",\r
- }\r
- },\r
- {\r
- "Pause",\r
- new StringSelector()\r
- {\r
- Normal = Resources.GetImagePath() + "light/pause.png",\r
- Pressed = Resources.GetImagePath() + "pause_pressed.png",\r
- Disabled = Resources.GetImagePath() + "pause_disabled.png",\r
- }\r
- },\r
- }\r
- },\r
- {\r
- ThemeType.Dark,\r
- new Dictionary<string, StringSelector>()\r
- {\r
- {\r
- "Play",\r
- new StringSelector()\r
- {\r
- Normal = Resources.GetImagePath() + "dark/play.png",\r
- Pressed = Resources.GetImagePath() + "play_pressed.png",\r
- Disabled = Resources.GetImagePath() + "play_disabled.png",\r
- }\r
- },\r
- {\r
- "Pause",\r
- new StringSelector()\r
- {\r
- Normal = Resources.GetImagePath() + "dark/pause.png",\r
- Pressed = Resources.GetImagePath() + "pause_pressed.png",\r
- Disabled = Resources.GetImagePath() + "pause_disabled.png",\r
- }\r
- },\r
- }\r
- }\r
- },\r
- };\r
- playButton.BindingContext = viewModel;\r
- playButton.SetBinding(MultiStateButton.CustomStateProperty, "PlayButtonState");\r
- controlsView.Add(playButton);\r
- playButton.Clicked += (object sender, ClickedEventArgs e) =>\r
- {\r
- viewModel.PlayingStatusChanged();\r
- };\r
- }\r
-\r
- private void AddNextButton()\r
- {\r
- nextButton = new Button("NextButton")\r
- {\r
- ThemeChangeSensitive = true,\r
- };\r
- nextButton.Clicked += (object sender, ClickedEventArgs e) =>\r
- {\r
- viewModel.NextButtonClicked();\r
- };\r
- nextButton.BindingContext = viewModel;\r
- nextButton.SetBinding(IsEnabledProperty, "HasNextTrack");\r
- controlsView.Add(nextButton);\r
- }\r
-\r
- private void AddSliderElements()\r
- {\r
- AddPlaybackSlider();\r
- AddCurrentTimeLabel();\r
- AddTotalTimeLabel();\r
- sliderView = new View();\r
- sliderView.BackgroundColor = Color.Transparent;\r
- sliderView.WidthResizePolicy = ResizePolicyType.FillToParent;\r
- if (DeviceInfo.IsPortrait)\r
- {\r
- sliderView.Layout = new LinearLayout()\r
- {\r
- LinearOrientation = LinearLayout.Orientation.Horizontal,\r
- VerticalAlignment = VerticalAlignment.Center,\r
- Padding = new Extents(33, 33, 0, 8).SpToPx(),\r
- };\r
- sliderView.SizeHeight = 61.SpToPx();\r
- base.Add(sliderView);\r
- currentTime.WidthSpecification = 72.SpToPx();\r
- sliderView.Add(currentTime);\r
- playbackSlider.WidthSpecification = 872.SpToPx();\r
- sliderView.Add(playbackSlider);\r
- totalTime.WidthSpecification = 72.SpToPx();\r
- sliderView.Add(totalTime);\r
- }\r
- else\r
- {\r
- sliderView.SizeHeight = 24.SpToPx();\r
- baseView.Add(playbackSlider);\r
- sliderView.Layout = new RelativeLayout();\r
- sliderView.Position2D = new Position2D(0, SliderHeight).SpToPx();\r
- playbackSlider.Add(sliderView);\r
- sliderView.Add(currentTime);\r
- RelativeLayout.SetHorizontalAlignment(currentTime, RelativeLayout.Alignment.Start);\r
- sliderView.Add(totalTime);\r
- RelativeLayout.SetHorizontalAlignment(totalTime, RelativeLayout.Alignment.End);\r
- }\r
- }\r
-\r
- private void AddPlaybackSliderEventHandler()\r
- {\r
- playbackSlider.SlidingStarted += (object sender, SliderSlidingStartedEventArgs e) =>\r
- {\r
- viewModel.StopPlaybackTimer();\r
- };\r
- playbackSlider.ValueChanged += (object sender, SliderValueChangedEventArgs e) =>\r
- {\r
- viewModel.SetElapsedTime(e.CurrentValue);\r
- };\r
- playbackSlider.SlidingFinished += (object sender, SliderSlidingFinishedEventArgs e) =>\r
- {\r
- viewModel.UpdatePlayerPosition(e.CurrentValue);\r
- };\r
- }\r
-\r
- private void AddPlaybackSlider()\r
- {\r
- playbackSlider = new Slider("Slider")\r
- {\r
- ThemeChangeSensitive = true,\r
- MinValue = 0.0f,\r
- MaxValue = 1.0f,\r
- WidthSpecification = 626.SpToPx(),\r
- HeightSpecification = SliderHeight.SpToPx(),\r
- ThumbSize = new Tizen.NUI.Size(30, 30).SpToPx(),\r
- Direction = Slider.DirectionType.Horizontal,\r
- };\r
- playbackSlider.SetBinding(Slider.CurrentValueProperty, "ElapsedTime");\r
- AddPlaybackSliderEventHandler();\r
- }\r
-\r
- private void AddCurrentTimeLabel()\r
- {\r
- currentTime = new TextLabel()\r
- {\r
- StyleName = "TitleText",\r
- ThemeChangeSensitive = true,\r
- Size2D = new Size2D(180, 24).SpToPx(),\r
- PixelSize = 18.SpToPx(),\r
- FontFamily = "BreezeSans",\r
- Text = "00::00:00",\r
- HorizontalAlignment = HorizontalAlignment.Begin,\r
- };\r
- currentTime.SetBinding(TextLabel.TextProperty, "PlayingTime");\r
- }\r
-\r
- private void AddTotalTimeLabel()\r
- {\r
- totalTime = new TextLabel()\r
- {\r
- StyleName = "TitleText",\r
- ThemeChangeSensitive = true,\r
- Size2D = new Size2D(180, 24).SpToPx(),\r
- PixelSize = 18.SpToPx(),\r
- FontFamily = "BreezeSans",\r
- HorizontalAlignment = HorizontalAlignment.End,\r
- Text = "59:59:59",\r
- };\r
- totalTime.SetBinding(TextLabel.TextProperty, "TrackLength");\r
- }\r
-\r
- public void ShowView()\r
- {\r
- Show();\r
- }\r
-\r
- public void HideView()\r
- {\r
- Hide();\r
- }\r
- }\r
-}\r
+using Tizen.NUI;
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using MusicPlayer.Common;
+using MusicPlayer.ViewModels;
+using MusicPlayer.Views.Utils;
+using System.Collections.Generic;
+using MusicPlayer.Core;
+
+namespace MusicPlayer.Views
+{
+ class MiniPlayer : View
+ {
+ private const int SliderHeight = 38;
+ private ImageView thumbnail;
+ private View trackInfo;
+ private View trackTextView;
+ private TextLabel titleLabel;
+ private TextLabel artistLabel;
+
+ private View controlsView;
+ private View sliderView;
+ private MultiStateButton playButton;
+ private Button prevButton;
+ private Button nextButton;
+ private Slider playbackSlider;
+ private TextLabel currentTime;
+ private TextLabel totalTime;
+ private View baseView;
+ private readonly PlayerViewModel viewModel;
+
+ public MiniPlayer(PlayerViewModel viewModel) : base()
+ {
+ this.viewModel = viewModel;
+ BindingContext = viewModel.playerModel;
+ StyleName = "MiniPlayer";
+ ThemeChangeSensitive = true;
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = (DeviceInfo.IsPortrait ? 170 : 124).SpToPx();
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ };
+ AddSeparatorLine();
+ baseView = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 123.SpToPx(),
+ BackgroundColor = Color.Transparent,
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ VerticalAlignment = VerticalAlignment.Center,
+ },
+ Padding = new Extents(64, 64, 24, 19).SpToPx(),
+ };
+ if(DeviceInfo.IsPortrait)
+ {
+ baseView.Padding = new Extents(33, 33, 24, 8).SpToPx();
+ baseView.HeightSpecification = 108.SpToPx();
+ }
+ Add(baseView);
+ AddTrackDetails();
+ AddControlElements();
+ AddSliderElements();
+ }
+
+ private void AddSeparatorLine()
+ {
+ View separator = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 1.SpToPx(),
+ StyleName = "InputLine",
+ };
+ Add(separator);
+ }
+
+ private void AddTrackDetails()
+ {
+ trackInfo = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ },
+ BackgroundColor = Color.Transparent,
+ };
+ trackInfo.WidthSpecification = (DeviceInfo.IsPortrait ? 536 : 622).SpToPx();
+ trackInfo.HeightSpecification = 76.SpToPx();
+ baseView.Add(trackInfo);
+ AddThumbnail();
+ AddTrackTextLabels();
+ }
+
+ private void AddTrackTextLabels()
+ {
+ trackTextView = new View()
+ {
+ BackgroundColor = Color.Transparent,
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
+ HeightSpecification = 76.SpToPx(),
+ };
+ if(DeviceInfo.IsPortrait)
+ {
+ trackTextView.WidthSpecification = 436.SpToPx();
+ trackTextView.Margin = new Extents(24, 0, 0, 0);
+ }
+ else
+ {
+ trackTextView.WidthSpecification = 516.SpToPx();
+ trackTextView.Margin = new Extents(30, 0, 0, 0);
+ }
+ trackInfo.Add(trackTextView);
+ AddTrackName();
+ AddArtistName();
+ }
+
+ private void AddThumbnail()
+ {
+ thumbnail = new ImageView()
+ {
+ BackgroundColor = UIColors.HEXEEEFF1,
+ Size2D = new Size2D(76, 76).SpToPx(),
+ };
+ trackInfo.Add(thumbnail);
+ thumbnail.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");
+ thumbnail.TouchEvent += (object source, TouchEventArgs e) =>
+ {
+ PlaybackHelper.Instance.ShowPlayer();
+ return true;
+ };
+ }
+
+ private void AddTrackName()
+ {
+ titleLabel = new TextLabel()
+ {
+ StyleName = "TitleText",
+ ThemeChangeSensitive = true,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 48.SpToPx(),
+ PixelSize = 36.SpToPx(),
+ FontFamily = "BreezeSans",
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ VerticalAlignment = VerticalAlignment.Center,
+ Ellipsis = true,
+ };
+ trackTextView.Add(titleLabel);
+ titleLabel.SetBinding(TextLabel.TextProperty, "TrackName");
+ }
+
+ private void AddArtistName()
+ {
+ artistLabel = new TextLabel()
+ {
+ StyleName = "TitleText",
+ ThemeChangeSensitive = true,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 28.SpToPx(),
+ PixelSize = 22.SpToPx(),
+ FontFamily = "BreezeSans",
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ VerticalAlignment = VerticalAlignment.Center,
+ Ellipsis = true,
+ };
+ trackTextView.Add(artistLabel);
+ artistLabel.SetBinding(TextLabel.TextProperty, "TrackArtist");
+ }
+ private void AddControlElements()
+ {
+ controlsView = new View()
+ {
+ WidthSpecification = 304.SpToPx(),
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(80, 0).SpToPx(),
+ },
+ Margin = new Extents(120, 120, 0, 0).SpToPx(),
+ BackgroundColor = Color.Transparent,
+ };
+ baseView.Add(controlsView);
+ AddPreviousButton();
+ AddPlayButton();
+ AddNextButton();
+ }
+
+ private void AddPreviousButton()
+ {
+ prevButton = new Button("PrevButton")
+ {
+ ThemeChangeSensitive = true,
+ };
+ prevButton.Clicked += (object sender, ClickedEventArgs e) =>
+ {
+ viewModel.PrevButtonClicked();
+ };
+ controlsView.Add(prevButton);
+ prevButton.BindingContext = viewModel;
+ prevButton.SetBinding(IsEnabledProperty, "HasPreviousTrack");
+ }
+
+ private void AddPlayButton()
+ {
+ playButton = new MultiStateButton()
+ {
+ Size2D = new Size2D(48, 48).SpToPx(),
+ BackgroundColor = Color.Transparent,
+ IconResources = new Dictionary<ThemeType, Dictionary<string, StringSelector>>()
+ {
+ {
+ ThemeType.Light,
+ new Dictionary<string, StringSelector>()
+ {
+ {
+ "Play",
+ new StringSelector()
+ {
+ Normal = Resources.GetImagePath() + "light/play.png",
+ Pressed = Resources.GetImagePath() + "play_pressed.png",
+ Disabled = Resources.GetImagePath() + "play_disabled.png",
+ }
+ },
+ {
+ "Pause",
+ new StringSelector()
+ {
+ Normal = Resources.GetImagePath() + "light/pause.png",
+ Pressed = Resources.GetImagePath() + "pause_pressed.png",
+ Disabled = Resources.GetImagePath() + "pause_disabled.png",
+ }
+ },
+ }
+ },
+ {
+ ThemeType.Dark,
+ new Dictionary<string, StringSelector>()
+ {
+ {
+ "Play",
+ new StringSelector()
+ {
+ Normal = Resources.GetImagePath() + "dark/play.png",
+ Pressed = Resources.GetImagePath() + "play_pressed.png",
+ Disabled = Resources.GetImagePath() + "play_disabled.png",
+ }
+ },
+ {
+ "Pause",
+ new StringSelector()
+ {
+ Normal = Resources.GetImagePath() + "dark/pause.png",
+ Pressed = Resources.GetImagePath() + "pause_pressed.png",
+ Disabled = Resources.GetImagePath() + "pause_disabled.png",
+ }
+ },
+ }
+ }
+ },
+ };
+ controlsView.Add(playButton);
+ playButton.BindingContext = viewModel;
+ playButton.SetBinding(MultiStateButton.CustomStateProperty, "PlayButtonState");
+ playButton.Clicked += (object sender, ClickedEventArgs e) =>
+ {
+ viewModel.PlayingStatusChanged();
+ };
+ }
+
+ private void AddNextButton()
+ {
+ nextButton = new Button("NextButton")
+ {
+ ThemeChangeSensitive = true,
+ };
+ nextButton.Clicked += (object sender, ClickedEventArgs e) =>
+ {
+ viewModel.NextButtonClicked();
+ };
+ controlsView.Add(nextButton);
+ nextButton.BindingContext = viewModel;
+ nextButton.SetBinding(IsEnabledProperty, "HasNextTrack");
+ }
+
+ private void AddSliderElements()
+ {
+ AddPlaybackSlider();
+ AddCurrentTimeLabel();
+ AddTotalTimeLabel();
+ sliderView = new View();
+ sliderView.BackgroundColor = Color.Transparent;
+ sliderView.WidthResizePolicy = ResizePolicyType.FillToParent;
+ if (DeviceInfo.IsPortrait)
+ {
+ sliderView.Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ VerticalAlignment = VerticalAlignment.Center,
+ Padding = new Extents(33, 33, 0, 8).SpToPx(),
+ };
+ sliderView.SizeHeight = 61.SpToPx();
+ base.Add(sliderView);
+ currentTime.WidthSpecification = 72.SpToPx();
+ sliderView.Add(currentTime);
+ playbackSlider.WidthSpecification = 872.SpToPx();
+ sliderView.Add(playbackSlider);
+ totalTime.WidthSpecification = 72.SpToPx();
+ sliderView.Add(totalTime);
+ }
+ else
+ {
+ sliderView.SizeHeight = 24.SpToPx();
+ baseView.Add(playbackSlider);
+ sliderView.Layout = new RelativeLayout();
+ sliderView.Position2D = new Position2D(0, SliderHeight).SpToPx();
+ playbackSlider.Add(sliderView);
+ sliderView.Add(currentTime);
+ RelativeLayout.SetHorizontalAlignment(currentTime, RelativeLayout.Alignment.Start);
+ sliderView.Add(totalTime);
+ RelativeLayout.SetHorizontalAlignment(totalTime, RelativeLayout.Alignment.End);
+ }
+ }
+
+ private void AddPlaybackSliderEventHandler()
+ {
+ playbackSlider.SlidingStarted += (object sender, SliderSlidingStartedEventArgs e) =>
+ {
+ viewModel.StopPlaybackTimer();
+ };
+ playbackSlider.ValueChanged += (object sender, SliderValueChangedEventArgs e) =>
+ {
+ viewModel.SetElapsedTime(e.CurrentValue);
+ };
+ playbackSlider.SlidingFinished += (object sender, SliderSlidingFinishedEventArgs e) =>
+ {
+ viewModel.UpdatePlayerPosition(e.CurrentValue);
+ };
+ }
+
+ private void AddPlaybackSlider()
+ {
+ playbackSlider = new Slider("Slider")
+ {
+ ThemeChangeSensitive = true,
+ MinValue = 0.0f,
+ MaxValue = 1.0f,
+ WidthSpecification = 626.SpToPx(),
+ HeightSpecification = SliderHeight.SpToPx(),
+ ThumbSize = new Tizen.NUI.Size(30, 30).SpToPx(),
+ Direction = Slider.DirectionType.Horizontal,
+ };
+ playbackSlider.SetBinding(Slider.CurrentValueProperty, "ElapsedTime");
+ AddPlaybackSliderEventHandler();
+ }
+
+ private void AddCurrentTimeLabel()
+ {
+ currentTime = new TextLabel()
+ {
+ StyleName = "TitleText",
+ ThemeChangeSensitive = true,
+ Size2D = new Size2D(180, 24).SpToPx(),
+ PixelSize = 18.SpToPx(),
+ FontFamily = "BreezeSans",
+ Text = "00::00:00",
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ };
+ currentTime.SetBinding(TextLabel.TextProperty, "PlayingTime");
+ }
+
+ private void AddTotalTimeLabel()
+ {
+ totalTime = new TextLabel()
+ {
+ StyleName = "TitleText",
+ ThemeChangeSensitive = true,
+ Size2D = new Size2D(180, 24).SpToPx(),
+ PixelSize = 18.SpToPx(),
+ FontFamily = "BreezeSans",
+ HorizontalAlignment = HorizontalAlignment.End,
+ Text = "59:59:59",
+ };
+ totalTime.SetBinding(TextLabel.TextProperty, "TrackLength");
+ }
+
+ public void ShowView()
+ {
+ Show();
+ }
+
+ public void HideView()
+ {
+ Hide();
+ }
+ }
+}