public void BuildRenderers(MvxVideoPlayer 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[MvxVideoPlayer.RendererCount];

            renderers[MvxVideoPlayer.TypeVideo] = videoRenderer;
            renderers[MvxVideoPlayer.TypeAudio] = audioRenderer;
            renderers[MvxVideoPlayer.TypeText]  = textRenderer;
            player.OnRenderers(renderers, bandwidthMeter);
        }
        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);
        }
        private void Play(string source)
        {
            Log.Debug(TAG, "StreamingBackgroundService.Play()");

            var focusResult = audioManager.RequestAudioFocus(this, Stream.Music, AudioFocus.Gain);
            Log.Debug(TAG, "StreamingBackgroundService.Play() RequestAudioFocus result: " + focusResult);
            if (focusResult == AudioFocusRequest.Granted)
            {
                if (mediaPlayer == null)
                {
                    mediaPlayer = ExoPlayerFactory.NewInstance(1);
                }

                RegisterReceiver(headphonesUnpluggedReceiver, new IntentFilter(AudioManager.ActionAudioBecomingNoisy));
                Log.Debug(TAG, "RegisterReceiver for headphones unplugged");

                String userAgent = ExoPlayerUtil.GetUserAgent (this, "ExoPlayerDemo");

                Android.Net.Uri soundString = Android.Net.Uri.Parse(source);
                var allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
                var dataSource = new DefaultUriDataSource(this, userAgent);
                ExtractorSampleSource sampleSource = new ExtractorSampleSource(soundString, dataSource, allocator,
                                                         BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
                audioRenderer = new MediaCodecAudioTrackRenderer (sampleSource, MediaCodecSelector.Default);

                mediaPlayer.Prepare(audioRenderer);
                mediaPlayer.PlayWhenReady = true;
                IsPlaying = true;
                AquireWifiLock();
                StartForeground();
            }
        }