Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Apr 13, 2019
1 parent dd9b74d commit c20bac2
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RepositoryType>git</RepositoryType>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<NeutralLanguage>en</NeutralLanguage>
<Version>0.5.0</Version>
<Version>0.5.1</Version>

<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);1591;1701;1702;1705;VSX1000</NoWarn>
Expand Down
6 changes: 3 additions & 3 deletions MediaManager.Forms/Platforms/Ios/VideoViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
namespace MediaManager.Forms.Platforms.iOS
{
[Preserve(AllMembers = true)]
public class VideoViewRenderer : ViewRenderer<VideoView, MediaManager.Platforms.Ios.Video.VideoView>
public class VideoViewRenderer : ViewRenderer<VideoView, MediaManager.Platforms.Ios.Video.VideoSurface>
{
private MediaManager.Platforms.Ios.Video.VideoView _videoView;
private MediaManager.Platforms.Ios.Video.VideoSurface _videoView;

public static void Init()
{
Expand All @@ -25,7 +25,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<VideoView> e)
base.OnElementChanged(e);
if (Control == null)
{
_videoView = new MediaManager.Platforms.Ios.Video.VideoView(Control);
_videoView = new MediaManager.Platforms.Ios.Video.VideoSurface(Control);
SetNativeControl(_videoView);
CrossMediaManager.Current.MediaPlayer.SetPlayerView(_videoView);
}
Expand Down
33 changes: 33 additions & 0 deletions MediaManager.Forms/Platforms/Mac/VideoViewRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using Foundation;
using MediaManager;
using MediaManager.Forms;
using MediaManager.Forms.Platforms.Mac;
using Xamarin.Forms;
using Xamarin.Forms.Platform.MacOS;

[assembly: ExportRenderer(typeof(MediaManager.Forms.VideoView), typeof(VideoViewRenderer))]
namespace MediaManager.Forms.Platforms.Mac
{
[Preserve(AllMembers = true)]
public class VideoViewRenderer : ViewRenderer<VideoView, MediaManager.Platforms.Mac.Video.VideoSurface>
{
private MediaManager.Platforms.Mac.Video.VideoSurface _videoView;

public static void Init()
{
var temp = DateTime.Now;
}

protected override void OnElementChanged(ElementChangedEventArgs<VideoView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
_videoView = new MediaManager.Platforms.Mac.Video.VideoSurface(Control);
SetNativeControl(_videoView);
CrossMediaManager.Current.MediaPlayer.SetPlayerView(_videoView);
}
}
}
}
4 changes: 2 additions & 2 deletions MediaManager/Platforms/Ios/Media/MediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace MediaManager.Platforms.Ios.Media
{
public class MediaPlayer : AppleMediaPlayer, IVideoPlayer<AVPlayer, VideoView>
public class MediaPlayer : AppleMediaPlayer, IVideoPlayer<AVPlayer, VideoSurface>
{
//TODO: Make possible to hook into
AVPlayerViewController aVPlayerViewController;

public VideoView PlayerView { get; set; }
public VideoSurface PlayerView { get; set; }

public override void Initialize()
{
Expand Down
6 changes: 3 additions & 3 deletions MediaManager/Platforms/Ios/Media/MediaPlayerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace MediaManager
{
public static partial class MediaPlayerExtensions
{
public static void SetPlayerView(this IMediaPlayer mediaPlayer, VideoView videoView)
public static void SetPlayerView(this IMediaPlayer mediaPlayer, VideoSurface videoView)
{
if (mediaPlayer is IVideoPlayer<AVPlayer, VideoView> videoPlayer)
if (mediaPlayer is IVideoPlayer<AVPlayer, VideoSurface> videoPlayer)
{
var layer = AVPlayerLayer.FromPlayer(videoPlayer.Player);
layer.Frame = videoView.Frame;
Expand All @@ -21,7 +21,7 @@ public static void SetPlayerView(this IMediaPlayer mediaPlayer, VideoView videoV
videoPlayer.PlayerView = videoView;
}
else
throw new ArgumentException($"MediaPlayer needs to be of type {nameof(IVideoPlayer<AVPlayer, VideoView>)} to use this extension", nameof(mediaPlayer));
throw new ArgumentException($"MediaPlayer needs to be of type {nameof(IVideoPlayer<AVPlayer, VideoSurface>)} to use this extension", nameof(mediaPlayer));
}
}
}
4 changes: 2 additions & 2 deletions MediaManager/Platforms/Ios/Video/VideoSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace MediaManager.Platforms.Ios.Video
{
public class VideoView : UIView, IVideoView
public class VideoSurface : UIView, IVideoView
{
private UIView _view;

public VideoView(UIView view)
public VideoSurface(UIView view)
{
this._view = view;
Frame = view.Frame;
Expand Down
26 changes: 26 additions & 0 deletions MediaManager/Platforms/Mac/Media/MediaPlayerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using AVFoundation;
using MediaManager.Platforms.Mac.Video;
using MediaManager.Video;

namespace MediaManager
{
public static partial class MediaPlayerExtensions
{
public static void SetPlayerView(this IMediaPlayer mediaPlayer, VideoSurface videoView)
{
if (mediaPlayer is IVideoPlayer<AVPlayer, VideoSurface> videoPlayer)
{
var layer = AVPlayerLayer.FromPlayer(videoPlayer.Player);
layer.Frame = videoView.Frame;
layer.VideoGravity = AVLayerVideoGravity.ResizeAspect;
videoView.Layer.AddSublayer(layer);
videoPlayer.PlayerView = videoView;
}
else
throw new ArgumentException($"MediaPlayer needs to be of type {nameof(IVideoPlayer<AVPlayer, VideoSurface>)} to use this extension", nameof(mediaPlayer));
}
}
}
31 changes: 31 additions & 0 deletions MediaManager/Platforms/Mac/Video/VideoSurface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using AppKit;
using AVFoundation;
using CoreGraphics;
using MediaManager.Video;

namespace MediaManager.Platforms.Mac.Video
{
public class VideoSurface : NSView, IVideoView
{
private NSView _view;

public VideoSurface(NSView view)
{
this._view = view;
Frame = view.Frame;
view.AddSubview(this);
}

#region IDisposable
public bool IsDisposed { get; private set; }
public VideoAspectMode VideoAspect { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }

protected override void Dispose(bool disposing)
{
IsDisposed = true;

base.Dispose(disposing);
}
#endregion
}
}
27 changes: 27 additions & 0 deletions MediaManager/Platforms/Tvos/Media/MediaPlayerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using AVFoundation;
using MediaManager.Platforms.Tvos.Video;
using MediaManager.Video;
using UIKit;

namespace MediaManager
{
public static partial class MediaPlayerExtensions
{
public static void SetPlayerView(this IMediaPlayer mediaPlayer, VideoSurface videoView)
{
if (mediaPlayer is IVideoPlayer<AVPlayer, VideoSurface> videoPlayer)
{
var layer = AVPlayerLayer.FromPlayer(videoPlayer.Player);
layer.Frame = videoView.Frame;
layer.VideoGravity = AVLayerVideoGravity.ResizeAspect;
videoView.Layer.AddSublayer(layer);
videoPlayer.PlayerView = videoView;
}
else
throw new ArgumentException($"MediaPlayer needs to be of type {nameof(IVideoPlayer<AVPlayer, VideoSurface>)} to use this extension", nameof(mediaPlayer));
}
}
}
31 changes: 31 additions & 0 deletions MediaManager/Platforms/Tvos/Video/VideoSurface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using AVFoundation;
using CoreGraphics;
using MediaManager.Video;
using UIKit;

namespace MediaManager.Platforms.Tvos.Video
{
public class VideoSurface : UIView, IVideoView
{
private UIView _view;

public VideoSurface(UIView view)
{
this._view = view;
Frame = view.Frame;
view.Add(this);
}

#region IDisposable
public bool IsDisposed { get; private set; }
public VideoAspectMode VideoAspect { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }

protected override void Dispose(bool disposing)
{
IsDisposed = true;

base.Dispose(disposing);
}
#endregion
}
}

0 comments on commit c20bac2

Please sign in to comment.