我正在为Android和iOS开发Xamarin应用程序。我正在尝试使用Android版本的Videoview和Media控制器控件播放实时流HLS URL。
我可以在以下网址下运行: https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8
但是我无法播放客户端提供的HLS实时流网址。我想念什么吗?否则我必须找到新的代码或软件包。
播放视频的代码:
private void InitVideoView()
{
_videoView = new VideoView(Context);
_videoView.Holder.SetKeepScreenOn(true);
_videoView.Prepared += videoView_Prepared;
_videoView.Error += videoView_Error;
_videoView.Completion += videoView_Completion;
_videoView.Info += videoView_Info;
_videoView.SetOnPreparedListener(this);
var lv = new RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
lv.AddRule(LayoutRules.CenterInParent);
_videoView.LayoutParameters = lv;
Control.AddView(_videoView);
//Org.Apache.Http.Conn.Ssl.SSLSocketFactory.AllowAllHostnameVerifier
}
public void OnPrepared(Android.Media.MediaPlayer _mediaPlayer)
{
//Console.WriteLine($"OnPrepared: {Status}");
_mediaPlayer.SetVolume(0f, 0f);
_videoView.Visibility = ViewStates.Visible;
_prepared = true;
Play();
}
private void InitMediaController()
{
mediaController = new MyMediaController(Context, false);
mediaController.VisibilityChange += MediaController_VisibilityChange;
mediaController.SetAnchorView(_videoView);
//_videoView.SetMediaController(mediaController);
_videoView.SetMediaController(null);
}