Add MediaView 65/118765/2
authorKangho Hur <kangho.hur@samsung.com>
Tue, 14 Mar 2017 04:09:59 +0000 (13:09 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Tue, 14 Mar 2017 04:38:57 +0000 (13:38 +0900)
- This is implementation of RFC-23.

Change-Id: I50806076c51d985ded378c986aa67e7d629c8fad

Tizen.Xamarin.Forms.Extension.Renderer/MediaViewRenderer.cs [new file with mode: 0644]
Tizen.Xamarin.Forms.Extension.Renderer/Tizen.Xamarin.Forms.Extension.Renderer.csproj [changed mode: 0755->0644]
Tizen.Xamarin.Forms.Extension.Renderer/Tizen.Xamarin.Forms.Extension.Renderer.project.json
Tizen.Xamarin.Forms.Extension/IMediaViewController.cs [new file with mode: 0644]
Tizen.Xamarin.Forms.Extension/MediaView.cs [new file with mode: 0644]
Tizen.Xamarin.Forms.Extension/Tizen.Xamarin.Forms.Extension.csproj [changed mode: 0755->0644]

diff --git a/Tizen.Xamarin.Forms.Extension.Renderer/MediaViewRenderer.cs b/Tizen.Xamarin.Forms.Extension.Renderer/MediaViewRenderer.cs
new file mode 100644 (file)
index 0000000..78fcf8b
--- /dev/null
@@ -0,0 +1,45 @@
+using Xamarin.Forms.Platform.Tizen;
+using Tizen.Xamarin.Forms.Extension;
+using Tizen.Xamarin.Forms.Extension.Renderer;
+
+using TMediaView = Tizen.Multimedia.MediaView;
+using TForms = Xamarin.Forms.Platform.Tizen.Forms;
+
+[assembly: ExportRenderer(typeof(MediaView), typeof(MediaViewRenderer))]
+namespace Tizen.Xamarin.Forms.Extension.Renderer
+{
+       public class MediaViewRenderer : VisualElementRenderer<MediaView>
+       {
+               TMediaView _control;
+
+               public MediaViewRenderer()
+               {
+               }
+
+               protected override void OnElementChanged(ElementChangedEventArgs<MediaView> e)
+               {
+                       if (_control == null)
+                       {
+                               _control = new TMediaView(TForms.Context.MainWindow);
+                               SetNativeControl(_control);
+                       }
+                       if (e.OldElement != null)
+                       {
+                               _control.Resized -= NatvieViewResized;
+                       }
+                       if (e.NewElement != null)
+                       {
+                               _control.Resized += NatvieViewResized;
+                               Element.NativeView = _control;
+                               IMediaViewController mediaView = Element as IMediaViewController;
+                               mediaView?.SendNativeViewCreated();
+                       }
+                       base.OnElementChanged(e);
+               }
+
+               void NatvieViewResized(object sender, System.EventArgs e)
+               {
+                       ((IMediaViewController)Element).NativeSizeChanged();
+               }
+       }
+}
old mode 100755 (executable)
new mode 100644 (file)
index 97b46a6..31dca40
@@ -37,6 +37,7 @@
   </PropertyGroup>\r
   <ItemGroup>\r
     <Compile Include="ColorPickerViewRenderer.cs" />\r
+    <Compile Include="MediaViewRenderer.cs" />\r
     <Compile Include="BackgroundRenderer.cs" />\r
     <Compile Include="Cells\DoubleLabelCellRenderer.cs" />\r
     <Compile Include="Cells\GridViewCellRenderer.cs" />\r
index db2186e..0e4c6ac 100644 (file)
@@ -1,8 +1,9 @@
 {\r
   "dependencies": {\r
-    "ElmSharp": "1.1.0-beta-010",\r
+    "ElmSharp": "1.1.0-beta-013",\r
     "NETStandard.Library": "1.6.0",\r
-    "Tizen.Applications": "1.0.3",\r
+    "Tizen.Applications": "1.2.5",\r
+    "Tizen.Multimedia": "1.0.41",\r
     "Xamarin.Forms": "2.3.3.175",\r
     "Xamarin.Forms.Platform.Tizen": "2.3.4-r192-001"\r
   },\r
@@ -11,4 +12,4 @@
       "imports": "portable-net45+win8+wpa81+wp8"\r
     }\r
   }\r
-}
\ No newline at end of file
+}
diff --git a/Tizen.Xamarin.Forms.Extension/IMediaViewController.cs b/Tizen.Xamarin.Forms.Extension/IMediaViewController.cs
new file mode 100644 (file)
index 0000000..d3cdfc5
--- /dev/null
@@ -0,0 +1,16 @@
+using Xamarin.Forms;
+
+namespace Tizen.Xamarin.Forms.Extension
+{
+       /// <summary>
+       /// This interface is for internal use by platform renderers.
+       /// </summary>
+       public interface IMediaViewController : IViewController
+       {
+               /// <summary>
+               /// For internal use by platform renderers.
+               /// </summary>
+               void SendNativeViewCreated();
+               
+       }
+}
diff --git a/Tizen.Xamarin.Forms.Extension/MediaView.cs b/Tizen.Xamarin.Forms.Extension/MediaView.cs
new file mode 100644 (file)
index 0000000..a04c783
--- /dev/null
@@ -0,0 +1,35 @@
+using System;
+using Xamarin.Forms;
+
+namespace Tizen.Xamarin.Forms.Extension
+{
+       /// <summary>
+       ///  The MediaView class provides a View of Media being played by Player or Camera.
+       /// </summary>
+       /// <example>
+       /// <code>
+       /// MediaView mediaView = new MediaView();
+       /// Tizen.Multimedia.Camera camera = new Tizen.Multimedia.Camera(Tizen.Multimedia.CameraDevice.Rear);
+       /// camera.SetDisplay(Tizen.Multimedia.CameraDisplayType.Evas, (Tizen.Multimedia.MediaView) mediaView.NativeView);
+       /// </code>
+       /// </example>
+       public class MediaView : View, IMediaViewController
+    {
+               internal static readonly BindablePropertyKey NativeViewPropertyKey = BindableProperty.CreateReadOnly("NativeView", typeof(object), typeof(MediaView), default(object));
+
+               public static readonly BindableProperty NativeViewProperty = NativeViewPropertyKey.BindableProperty;
+
+               public object NativeView
+               {
+                       get { return GetValue(NativeViewProperty); }
+                       internal set { SetValue(NativeViewPropertyKey, value); }
+               }
+
+               public event EventHandler NativeViewCreated;
+
+               void IMediaViewController.SendNativeViewCreated()
+               {
+                       NativeViewCreated?.Invoke(this, EventArgs.Empty);
+               }
+       }
+}
old mode 100755 (executable)
new mode 100644 (file)
index e11d819..9b16e5c
@@ -55,6 +55,8 @@
   <ItemGroup>\r
     <Compile Include="ColorChangedEventArgs.cs" />\r
     <Compile Include="ColorPickerView.cs" />\r
+    <Compile Include="IMediaViewController.cs" />\r
+    <Compile Include="MediaView.cs" />\r
     <Compile Include="Background.cs" />\r
     <Compile Include="BackgroundOptions.cs" />\r
     <Compile Include="Cells\GridViewCell.cs" />\r
   <Target Name="AfterBuild">
   </Target>
   -->\r
-</Project>
+</Project>
\ No newline at end of file