Merge pull request #170 from rina6350-you/EmbeddingControl_st2
author최원영/Common Platform Lab(SR)/Staff Engineer/삼성전자 <wy80.choi@samsung.com>
Thu, 26 Mar 2020 09:14:08 +0000 (18:14 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 26 Mar 2020 09:14:08 +0000 (18:14 +0900)
Support the EmbeddingControls of MediaPlayer

src/XSF/Tizen.Wearable.CircularUI.Forms/EmbeddingControls.xaml [deleted file]
src/XSF/Tizen.Wearable.CircularUI.Forms/EmbeddingControls.xaml.cs [deleted file]
src/XSF/Tizen.Wearable.CircularUI.Forms/MediaPlayer.cs
src/XSF/XSF.csproj

diff --git a/src/XSF/Tizen.Wearable.CircularUI.Forms/EmbeddingControls.xaml b/src/XSF/Tizen.Wearable.CircularUI.Forms/EmbeddingControls.xaml
deleted file mode 100644 (file)
index 60b7b80..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
-            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
-            xmlns:local="clr-namespace:Tizen.Wearable.CircularUI.Forms"
-            x:Class="Tizen.Wearable.CircularUI.Forms.EmbeddingControls">
-    <ContentView.Resources>
-        <ResourceDictionary>
-            <local:ProgressToBoundTextConverter x:Key="progressToBound"/>
-            <local:MillisecondToTextConverter x:Key="millisecondToText"/>
-        </ResourceDictionary>
-    </ContentView.Resources>
-    <ContentView.Content>
-        <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
-            <StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
-                <StackLayout VerticalOptions="FillAndExpand"></StackLayout>
-                <StackLayout Margin="20" VerticalOptions="End" HorizontalOptions="FillAndExpand" BackgroundColor="#50000000">
-                    <AbsoluteLayout HorizontalOptions="FillAndExpand" HeightRequest="23" BackgroundColor="#80000000">
-                        <BoxView Color="#4286f4" AbsoluteLayout.LayoutBounds="{Binding Progress, Converter={StaticResource progressToBound}}" AbsoluteLayout.LayoutFlags="SizeProportional"></BoxView>
-                        <Label Margin="80, 0, 0, 0" Text="{Binding Position, Converter={StaticResource millisecondToText}}" FontSize="Micro" HorizontalTextAlignment="Start" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" />
-                        <Label Margin="0, 0, 80, 0" Text="{Binding Duration, Converter={StaticResource millisecondToText}}" FontSize="Micro" HorizontalTextAlignment="End" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" />
-                    </AbsoluteLayout>
-                </StackLayout>
-            </StackLayout>
-            <Image x:Name="PlayImage" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0.5, 0.5, 0.25, 0.25" IsVisible="False">
-                <Image.GestureRecognizers>
-                    <TapGestureRecognizer Command="{Binding StartCommand}"/>
-                </Image.GestureRecognizers>
-            </Image>
-            <Image x:Name="PauseImage" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0.5, 0.5, 0.25, 0.25" IsVisible="False">
-                <Image.GestureRecognizers>
-                    <TapGestureRecognizer Command="{Binding StartCommand}"/>
-                </Image.GestureRecognizers>
-            </Image>
-            <Label FontSize="Large"
-                HorizontalTextAlignment="Center"
-                Text="{Binding BufferingProgress, StringFormat='{}{0:0%}'}"
-                TextColor="#eeeeeeee"
-                AbsoluteLayout.LayoutFlags="All"
-                AbsoluteLayout.LayoutBounds="0.5, 0.5, .25, .25"
-                IsVisible="{Binding IsBuffering}"/>
-        </AbsoluteLayout>
-    </ContentView.Content>
-</ContentView>
\ No newline at end of file
diff --git a/src/XSF/Tizen.Wearable.CircularUI.Forms/EmbeddingControls.xaml.cs b/src/XSF/Tizen.Wearable.CircularUI.Forms/EmbeddingControls.xaml.cs
deleted file mode 100644 (file)
index 5d73e61..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Threading.Tasks;
-using Xamarin.Forms;
-using Xamarin.Forms.Xaml;
-
-namespace Tizen.Wearable.CircularUI.Forms
-{
-       /// <summary>
-       /// A built-in media controls.
-       /// </summary>
-       [XamlCompilation(XamlCompilationOptions.Compile)]
-       partial class EmbeddingControls : ContentView
-       {
-               /// <summary>
-               /// Internal use only, initializes a new instance of the EmbeddingControls.
-               /// </summary>
-               public EmbeddingControls()
-               {
-                       InitializeComponent();
-                       PlayImage.Source = ImageSource.FromResource("XSF.Resources.img_button_play.png", GetType().Assembly);
-                       PauseImage.Source = ImageSource.FromResource("XSF.Resources.img_button_pause.png", GetType().Assembly);
-               }
-
-               protected override void OnBindingContextChanged()
-               {
-                       base.OnBindingContextChanged();
-                       if (BindingContext is MediaPlayer player)
-                       {
-                               player.PlaybackPaused += OnPlaybackStateChanged;
-                               player.PlaybackStarted += OnPlaybackStateChanged;
-                               player.PlaybackStopped += OnPlaybackStateChanged;
-                       }
-               }
-
-               async void OnPlaybackStateChanged(object sender, EventArgs e)
-               {
-                       if (BindingContext is MediaPlayer player)
-                       {
-                               if (player.State == PlaybackState.Playing)
-                               {
-                                       var unused = PlayImage.FadeTo(0, 100);
-                                       await PlayImage.ScaleTo(3.0, 300);
-                                       PlayImage.IsVisible = false;
-                                       PlayImage.Scale = 1.0;
-
-                                       PauseImage.IsVisible = true;
-                                       unused = PauseImage.FadeTo(1, 50);
-                               }
-                               else
-                               {
-                                       var unused = PauseImage.FadeTo(0, 100);
-                                       await PauseImage.ScaleTo(3.0, 300);
-                                       PauseImage.IsVisible = false;
-                                       PauseImage.Scale = 1.0;
-
-                                       PlayImage.IsVisible = true;
-                                       unused = PlayImage.FadeTo(1, 50);
-                               }
-                       }
-               }
-       }
-}
\ No newline at end of file
index fad7717..9cc02b1 100644 (file)
@@ -22,6 +22,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using Xamarin.Forms;
 using Xamarin.Forms.Internals;
+using Xamarin.Forms.Platform.Tizen.Native;
 
 namespace Tizen.Wearable.CircularUI.Forms
 {
@@ -117,13 +118,13 @@ namespace Tizen.Wearable.CircularUI.Forms
                        _impl.AutoStop = true;
 
                        _controlsAlwaysVisible = false;
-                       //_controls = new Lazy<View>(() =>
-                       //{
-                       //    return new EmbeddingControls
-                       //    {
-                       //        BindingContext = this
-                       //    };
-                       //});
+                       _controls = new Lazy<View>(() =>
+                       {
+                               return new EmbeddingControls
+                               {
+                                       BindingContext = this
+                               };
+                       });
                }
 
                /// <summary>
index 88b3da5..49d1c22 100644 (file)
@@ -9,18 +9,6 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Compile Remove="Tizen.Wearable.CircularUI.Forms\EmbeddingControls.xaml.cs" />
-  </ItemGroup>
-
-  <ItemGroup>
-    <EmbeddedResource Remove="Tizen.Wearable.CircularUI.Forms\EmbeddingControls.xaml" />
-  </ItemGroup>
-
-  <ItemGroup>
-    <None Remove="Tizen.Wearable.CircularUI.Forms\EmbeddingControls.xaml" />
-  </ItemGroup>
-
-  <ItemGroup>
     <PackageReference Include="Tizen.NET" Version="6.0.0.14995" />
   </ItemGroup>