public void BuildRenderers(VideoPlayer player)
        {
            var allocator = new DefaultAllocator(BufferSegmentSize);

            // Build the video and audio renderers.
            var bandwidthMeter = new DefaultBandwidthMeter(player.MainHandler, null);
            var dataSource = new DefaultUriDataSource(_context, bandwidthMeter, _userAgent);
            var sampleSource = new ExtractorSampleSource(_uri
                , dataSource
                , allocator
                , BufferSegmentCount*BufferSegmentSize);
            var videoRenderer = new MediaCodecVideoTrackRenderer(_context
                , sampleSource
                , MediaCodecSelector.Default
                , (int) VideoScalingMode.ScaleToFit
                , 5000
                , player.MainHandler
                , player
                , 50);
            var audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource
                , MediaCodecSelector.Default
                , null
                , true
                , player.MainHandler
                , player
                , AudioCapabilities.GetCapabilities(_context)
                , (int) Stream.Music);
            var textRenderer = new TextTrackRenderer(sampleSource
                , player
                , player.MainHandler.Looper);

            // Invoke the callback.
            var renderers = new TrackRenderer[VideoPlayer.RendererCount];
            renderers[VideoPlayer.TypeVideo] = videoRenderer;
            renderers[VideoPlayer.TypeAudio] = audioRenderer;
            renderers[VideoPlayer.TypeText] = textRenderer;
            player.OnRenderers(renderers, bandwidthMeter);
        }
 public void BuildRenderers(VideoPlayer player)
 {
     _currentAsyncBuilder = new AsyncRendererBuilder(_context, _userAgent, _url, _drmCallback, player);
     _currentAsyncBuilder.Init();
 }
 public AsyncRendererBuilder(Context context, string userAgent, string url, IMediaDrmCallback drmCallback, VideoPlayer player)
 {
     _context = context;
     _userAgent = userAgent;
     _drmCallback = drmCallback;
     _player = player;
     var parser = new MediaPresentationDescriptionParser();
     _manifestDataSource = new DefaultUriDataSource(context, userAgent);
     _manifestFetcher = new ManifestFetcher(url, _manifestDataSource, parser);
 }
 public AsyncRendererBuilder(Context context, string userAgent, string url, IMediaDrmCallback drmCallback, VideoPlayer player)
 {
     _context = context;
     _userAgent = userAgent;
     _drmCallback = drmCallback;
     _player = player;
     var parser = new SmoothStreamingManifestParser();
     _manifestFetcher = new ManifestFetcher(url, new DefaultHttpDataSource(userAgent, null), parser);
 }
 private void ReleasePlayer()
 {
     if (_player != null)
     {
         _debugViewHelper.Stop();
         _debugViewHelper = null;
         _playerPosition = _player.CurrentPosition;
         _player.Release();
         _player = null;
         _eventLogger.EndSession();
         _eventLogger = null;
     }
 }
 private void PreparePlayer(bool playWhenReady)
 {
     if (_player == null)
     {
         _player = new VideoPlayer(GetRendererBuilder());
         _player.AddListener(this);
         _player.SetCaptionListener(this);
         _player.SetMetadataListener(this);
         _player.SeekTo(_playerPosition);
         _playerNeedsPrepare = true;
         _mediaController.SetMediaPlayer(_player.PlayerControl);
         _mediaController.Enabled = true;
         _eventLogger = new EventLogger();
         _eventLogger.StartSession();
         _player.AddListener(_eventLogger);
         _player.SetInfoListener(_eventLogger);
         _player.SetInternalErrorListener(_eventLogger);
         _debugViewHelper = new DebugTextViewHelper(_player, _debugTextView);
         _debugViewHelper.Start();
     }
     if (_playerNeedsPrepare)
     {
         _player.Prepare();
         _playerNeedsPrepare = false;
         UpdateButtonVisibilities();
     }
     _player.Surface = _surfaceView.Holder.Surface;
     _player.PlayWhenReady = playWhenReady;
 }
 public AsyncRendererBuilder(Context context, string userAgent, string url, VideoPlayer player)
 {
     _context = context;
     _userAgent = userAgent;
     _url = url;
     _player = player;
     var parser = new HlsPlaylistParser();
     _playlistFetcher = new ManifestFetcher(url, new DefaultUriDataSource(context, userAgent),
         parser);
 }