Hi I am not able to add the dependency service for the MPMoviePlayerController. Below is the code which I have written.
The code does not throw any error. I have checked the documentation for the MPMoviePlayerController and it has a line to add View
"View.AddSubview (moviePlayer.View);"
I think my dependency service should also have something similar to this. But I am not able to figure it out. Please help
Here is my code
Button play = new Button {
VerticalOptions = LayoutOptions.Center,
HorizontalOptions= LayoutOptions.Center,
Text = "Click to play Video!"
};
play.Clicked += async(sender, e) => {
DependencyService.Get<IPlayVideo>().playVid();
};
Interface
public interface IPlayVideo
{
void playVid();
}
}
The dependency service.
[assembly: Dependency (typeof (PlayVideo))]
namespace VideoL.iOS
{
public class PlayVideo : IPlayVideo
{
public void playVid()
{
MPMoviePlayerController moviePlayer;
try{
moviePlayer = new MPMoviePlayerController ();
moviePlayer.ContentUrl = new NSUrl ("sample.m4v");
moviePlayer.ShouldAutoplay = true;
moviePlayer.SetFullscreen (true,true);
moviePlayer.Play ();
}
catch(Exception ae){
}
}
}
}