2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using Tizen.Xamarin.Forms.Extension;
19 using TVMediaHub.Tizen.Utils;
20 using TVMediaHub.Tizen.ViewModels;
23 namespace TVMediaHub.Tizen.Views
26 /// A custom ContentPage for displaying the music player
28 public partial class MusicPlayer : RelativeLayout
30 private bool IsInitailized;
31 private Rectangle ShadowImageFocusedBounds;
32 private Rectangle ShadowImageNormalBounds;
34 private Rectangle AlbumImageFocusedBounds;
35 private Rectangle AlbumImageNormalBounds;
37 private Rectangle PausePlayButtonBounds;
39 private Rectangle TitleBounds;
40 private Rectangle ArtistBounds;
41 private Rectangle AlbumNameBounds;
44 /// Gets FocusArea for focus chain
46 public Button GetFocusArea()
48 return MusicPlayerFocusArea;
56 BindingContext = MusicPlayerViewModelLocator.ViewModel;
57 IsInitailized = false;
58 InitializeComponent();
62 private void MusicPlayerFocusAreaFocused(object sender, FocusEventArgs e)
64 MusicPlayerShadowImage.LayoutTo(ShadowImageFocusedBounds);
65 MusicPlayerAlbumArt.LayoutTo(AlbumImageFocusedBounds);
68 private void MusicPlayerFocusAreaUnfocused(object sender, FocusEventArgs e)
70 MusicPlayerShadowImage.LayoutTo(ShadowImageNormalBounds);
71 MusicPlayerAlbumArt.LayoutTo(AlbumImageNormalBounds);
74 private void InitializeSize()
76 WidthRequest = SizeUtils.GetWidthSize(546);
77 HeightRequest = SizeUtils.GetHeightSize(546);
78 Margin = new Thickness(SizeUtils.GetWidthSize(-14), SizeUtils.GetHeightSize(-14), 0, 0);
81 MusicPlayerShadowImage.BorderTop = SizeUtils.GetHeightSize(67);
82 MusicPlayerShadowImage.BorderBottom = SizeUtils.GetHeightSize(67);
83 MusicPlayerShadowImage.BorderLeft = SizeUtils.GetWidthSize(67);
84 MusicPlayerShadowImage.BorderRight = SizeUtils.GetWidthSize(67);
86 ShadowImageFocusedBounds = new Rectangle(0, 0, SizeUtils.GetWidthSize(546), SizeUtils.GetHeightSize(546));
87 ShadowImageNormalBounds = new Rectangle(SizeUtils.GetWidthSize(6), SizeUtils.GetHeightSize(6), SizeUtils.GetWidthSize(532), SizeUtils.GetHeightSize(532));
89 AlbumImageFocusedBounds = new Rectangle(SizeUtils.GetWidthSize(64), SizeUtils.GetHeightSize(64), SizeUtils.GetWidthSize(418), SizeUtils.GetHeightSize(418));
90 AlbumImageNormalBounds = new Rectangle(SizeUtils.GetWidthSize(70), SizeUtils.GetHeightSize(70), SizeUtils.GetWidthSize(406), SizeUtils.GetHeightSize(406));
92 PausePlayButtonBounds = new Rectangle(SizeUtils.GetWidthSize(223), SizeUtils.GetHeightSize(223), SizeUtils.GetWidthSize(100), SizeUtils.GetHeightSize(100));
94 TitleBounds = new Rectangle(SizeUtils.GetWidthSize(72), SizeUtils.GetHeightSize(498), SizeUtils.GetWidthSize(406), SizeUtils.GetHeightSize(32));
95 ArtistBounds = new Rectangle(SizeUtils.GetWidthSize(72), SizeUtils.GetHeightSize(542), SizeUtils.GetWidthSize(418), SizeUtils.GetHeightSize(28));
96 AlbumNameBounds = new Rectangle(SizeUtils.GetWidthSize(72), SizeUtils.GetHeightSize(572), SizeUtils.GetWidthSize(418), SizeUtils.GetHeightSize(28));
98 MusicPlayerTitle.FontSize = SizeUtils.GetFontSize(28);
100 MusicPlayerArtist.FontSize = SizeUtils.GetFontSize(24);
101 MusicPlayerArtist.Opacity = 0.5;
103 MusicPlayerAlbum.FontSize = SizeUtils.GetFontSize(24);
104 MusicPlayerAlbum.Opacity = 0.25;
107 protected override void LayoutChildren(double x, double y, double width, double height)
109 if (IsInitailized == false)
111 base.LayoutChildren(x, y, width, height);
112 MusicPlayerAlbumArt.Layout(AlbumImageNormalBounds);
113 MusicPlayerTitle.Layout(TitleBounds);
114 MusicPlayerArtist.Layout(ArtistBounds);
115 MusicPlayerAlbum.Layout(AlbumNameBounds);
116 MusicPlayerShadowImage.Layout(ShadowImageNormalBounds);
117 MusicPlayerPausePlayButton.Layout(PausePlayButtonBounds);
118 MusicPlayerFocusArea.Layout(PausePlayButtonBounds);
119 IsInitailized = true;