Nimish Saxena

Nimish Saxena

  • 1.2k
  • 597
  • 83.6k

Black screen showing approx 3 seconds before play video.

Nov 26 2020 11:05 PM
<local:VideoPlayer x:Name="videoplayer_ctrl" Source="{Binding videosource}" AutoPlay="{Binding autoplay}" AreTransportControlsEnabled="{Binding controlsenabled}" />
 
C# Code-
 
protected override void OnElementChanged(ElementChangedEventArgs<VideoPlayer> args)
{
base.OnElementChanged(args);
if (args.NewElement != null)
{
if (Control == null)
{
// Save the VideoView for future reference
videoView = new VideoView(Context);
// Put the VideoView in a RelativeLayout
AWR relativeLayout = new AWR(Context);
relativeLayout.AddView(videoView);
// Center the VideoView in the RelativeLayout
var layoutParams = new AWR.LayoutParams(Convert.ToInt32(DeviceDisplay.MainDisplayInfo.Width), Convert.ToInt32(DeviceDisplay.MainDisplayInfo.Height));
layoutParams.AddRule(LayoutRules.AlignParentTop);
layoutParams.AddRule(LayoutRules.AlignParentBottom);
layoutParams.AddRule(LayoutRules.AlignParentLeft);
layoutParams.AddRule(LayoutRules.AlignParentRight);
videoView.LayoutParameters = layoutParams;
// Handle a VideoView event
videoView.Prepared += OnVideoViewPrepared;
SetNativeControl(relativeLayout);
}
SetAreTransportControlsEnabled();
PlayVideo();
args.NewElement.UpdateStatus += OnUpdateStatus;
args.NewElement.PlayRequested += OnPlayRequested;
args.NewElement.PauseRequested += OnPauseRequested;
args.NewElement.StopRequested += OnStopRequested;
}
if (args.OldElement != null)
{
args.OldElement.UpdateStatus -= OnUpdateStatus;
args.OldElement.PlayRequested -= OnPlayRequested;
args.OldElement.PauseRequested -= OnPauseRequested;
args.OldElement.StopRequested -= OnStopRequested;
}
}

Answers (1)