-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
159 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
MediaManager/Platforms/Tvos/Media/MediaPlayerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |