I'm trying to use VideoView from LibVLCSharp for Mac to create a custom renderer in Xamarin.Forms to play a video in Xamarin.Forms mac application. So far I only get audio but no video.
this is my VideoPlayerRenderer for mac implementation
[assembly: ExportRenderer(typeof(Player.VideoPlayer), typeof(Player.Mac.VideoPlayerRenderer))]
namespace Player.Mac {
public class VideoPlayerRenderer : ViewRenderer<VideoPlayer, LibVLCSharp.Platforms.Mac.VideoView> {
LibVLCSharp.Platforms.Mac.VideoView video_view;
public VideoPlayerRenderer() {
}
protected override void OnElementChanged (ElementChangedEventArgs<VideoPlayer> e) {
base.OnElementChanged (e);
if(e.OldElement != null) {
}
if(e.NewElement != null) {
if(Control == null) {
video_view = new LibVLCSharp.Platforms.Mac.VideoView();
video_view.MediaPlayer = e.NewElement.get_media_player();
SetNativeControl(video_view);
}
}
}
}
}
and the VideoPlayer Xamarin.Forms View
public class VideoPlayer : View {
LibVLC lib_vlc;
MediaPlayer media_player;
public VideoPlayer() {
}
public void init(LibVLC lib_vlc, MediaPlayer media_player) {
this.lib_vlc = lib_vlc;
this.media_player = media_player;
}
public void play() {
this.media_player.Play();
}
public MediaPlayer get_media_player() {
return this.media_player;
}
}
I've tried the same method on UWP and there i get no audio nor video. So i'm wondering if this is going in the wrong direction, and if so, how are you supposed to go about using LibVLCSharp for mac/uwp?
question from:
https://stackoverflow.com/questions/65873518/custom-renderer-for-libvlcsharp-videoview-in-mac-and-uwp-xamarin-forms 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…