protected override void OnElementChanged(ElementChangedEventArgs <VideoPlayerExo> e) { base.OnElementChanged(e); if (_player != null) { _player.Release(); } if (_player == null) { _player = ExoPlayerFactory.NewSimpleInstance(Context); _player.PlayWhenReady = true; _view = new SimpleExoPlayerView(Context); _view.Background = new GradientDrawable(GradientDrawable.Orientation.BottomTop, new int[] { Color.Transparent.ToAndroid(), Color.Transparent.ToAndroid() }); _view.ControllerAutoShow = false; _view.UseController = false; _player.RenderedFirstFrame += _player_RenderedFirstFrame; _player.VideoSizeChanged += _player_VideoSizeChanged; _view.Player = _player; url = e.NewElement.Source; SetNativeControl(_view); } Play(); }
public void Play(string url) { if (clicks % 2 == 0) { #region ExoPlayer var mediaUrl = url; var mediaUri = Android.Net.Uri.Parse(mediaUrl); Android.Content.Context context = Android.App.Application.Context; var userAgent = Util.GetUserAgent(context, "InstationPlayer"); var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent); var defaultDataSourceFactory = new DefaultDataSourceFactory(context, null, defaultHttpDataSourceFactory); var extractorMediaSource = new ExtractorMediaSource(mediaUri, defaultDataSourceFactory, new DefaultExtractorsFactory(), null, null); var defaultBandwidthMeter = new DefaultBandwidthMeter(); var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter); var defaultTrackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); exoPlayer = ExoPlayerFactory.NewSimpleInstance(context, defaultTrackSelector); exoPlayer.Prepare(extractorMediaSource); Console.WriteLine("Prepared"); exoPlayer.PlayWhenReady = true; Console.WriteLine("Started"); clicks++; #endregion } else if (clicks % 2 != 0) { exoPlayer.Stop(); Console.WriteLine("Paused"); clicks++; } }
public void playVideo(string url, string typestream) { var MyURL = url; var mediaUri = Android.Net.Uri.Parse(MyURL); var userAgent = Util.GetUserAgent(this, "Player"); var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent); var defaultDataSourceFactory = new DefaultDataSourceFactory(this, null, defaultHttpDataSourceFactory); if (typestream == "HLS") { playerView.UseController = false; extractorMediaSource = new HlsMediaSource.Factory(defaultDataSourceFactory).CreateMediaSource(mediaUri); } else if (typestream == "MP4") { extractorMediaSource = new ExtractorMediaSource(mediaUri, defaultDataSourceFactory, new DefaultExtractorsFactory(), null, null); } ConcatenatingMediaSource concatenatedSource = new ConcatenatingMediaSource(extractorMediaSource); var defaultBandwidthMeter = new DefaultBandwidthMeter(); var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter); var defaultTrackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); player = ExoPlayerFactory.NewSimpleInstance(this, defaultTrackSelector); player.Prepare(concatenatedSource); player.AddListener(new CustomListener()); playerView.Player = player; player.PlayWhenReady = true; }
protected override void OnElementChanged(ElementChangedEventArgs <ExtendedVideoPlayer> e) { base.OnElementChanged(e); string s = Element.Source; // // Will be invoked by the Xamarin.Forms page when the last is closed // Element.ReleaseAction = PlayerRelease; _exoSpot = new PlayerView(Context); // // Video will be expanded on full screen // _exoSpot.SetResizeMode(AspectRatioFrameLayout.ResizeModeFit); SetNativeControl(_exoSpot); // // Create a default TrackSelector // Handler mainHandler = new Handler(); IBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); AdaptiveTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); // // Create the player // _exoPlayer = ExoPlayerFactory.NewSimpleInstance(Context, trackSelector); _exoPlayer.AddListener(new ExtendedVideoPlayerEventListener(_exoPlayer)); _exoPlayer.PlayWhenReady = true; // // Attach player to the view // _exoSpot.Player = _exoPlayer; DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(Context, Util.GetUserAgent(Context, Context.GetString(Resource.String.application_name))); IMediaSource videoSource = new ExtractorMediaSource( Android.Net.Uri.Parse(Element.Source), new CacheableDataSource(Context, 100 * 1024 * 1024, 5 * 1024 * 1024), new DefaultExtractorsFactory(), null, null); // // Prepare the player with the source. // _exoPlayer.Prepare(videoSource); }
protected override void OnInitialize(ElementChangedEventArgs <VideoView> e) { base.OnInitialize(e); player = ExoPlayerFactory.NewSimpleInstance(Context); player.AddListener(this); Control.Player = player; ReportVideoState(VideoState.Configured); }
private void InitializePlayer() { ExoPlayer = ExoPlayerFactory.NewSimpleInstance(context, new DefaultTrackSelector()); VideoPlayer = new PlayerView(context) { Player = ExoPlayer }; }
public AudioPlayer() { _listener = new AudioPlayerEventListener(); _listener.PlayerStateChanged += _listener_PlayerStateChanged; _listener.LoadingChanged += _listener_LoadingChanged; _exoPlayer = ExoPlayerFactory.NewSimpleInstance(Application.Context, new DefaultTrackSelector()); _exoPlayer.AddListener(_listener); }
private void InitializePlayer() { _player = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector()); _player.PlayWhenReady = true; _playerView = new SimpleExoPlayerView(Context) { Player = _player }; SetNativeControl(_playerView); }
public void InitializePlayer() { var userAgent = Util.GetUserAgent(this, "Player"); var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent); var defaultBandwidthMeter = new DefaultBandwidthMeter(); var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter); var defaultTrackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); player = ExoPlayerFactory.NewSimpleInstance(this, defaultTrackSelector); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetStyle((int)DialogFragmentStyle.Normal, Resource.Style.ShootDialog); webclient = new OkHttpClient.Builder() .Cache((Activity.Application as BootleggerApp).FilesCache) .Build(); httpDataSourceFactory = new OkHttpDataSourceFactory(webclient, "BootleggerEditor"); extractorsFactory = new DefaultExtractorsFactory(); _audioPlayer = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector()); _audioPlayer.RenderedFirstFrame += _audioPlayer_RenderedFirstFrame; }
public RadioPlayer(Context context, string url) { _sourceUrl = url; #pragma warning disable 612, 618 var agent = WebSettings.GetDefaultUserAgent(context); var factory = new DefaultDataSourceFactory(context, agent); var extractorMediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), factory, new DefaultExtractorsFactory(), null, null); _exoPlayer = ExoPlayerFactory.NewSimpleInstance(context); _exoPlayer.Prepare(extractorMediaSource); #pragma warning restore 612, 618 }
private void InitializePlayer() { _player = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector()); _player.PlayWhenReady = true; _playerView = new PlayerView(Context); this.AddView(_playerView); _playerView.LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _playerView.UseController = false; _playerView.Player = _player; }
public MvxVideoPlayer(IRendererBuilder rendererBuilder) { _rendererBuilder = rendererBuilder; _player = ExoPlayerFactory.NewInstance(RendererCount, 1000, 5000); _player.AddListener(this); _playerControl = new PlayerControl(_player); _mainHandler = new Handler(); _listeners = new List <IListener>(); _lastReportedPlaybackState = StateIdle; _rendererBuildingState = RendererBuildingStateIdle; // Disable text initially. _player.SetSelectedTrack(TypeText, TrackDisabled); }
public void PlayVideo(string videoUrL, VideoObject videoObject, long resumePosition) { try { if (Player != null) { SetStopvideo(); Player?.Release(); Player = null; //GC Collecter GC.Collect(); } AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); var newParameters = new DefaultTrackSelector.ParametersBuilder() .SetMaxVideoSizeSd() .SetPreferredAudioLanguage("deu") .Build(); trackSelector.SetParameters(newParameters); Player = ExoPlayerFactory.NewSimpleInstance(ActivityContext, trackSelector); FullWidthSetting(); DefaultDataMediaFactory = new DefaultDataSourceFactory(ActivityContext, Util.GetUserAgent(ActivityContext, AppSettings.ApplicationName), BandwidthMeter); VideoSource = null; VideoSource = GetMediaSourceFromUrl(Uri.Parse(videoUrL), "normal"); SimpleExoPlayerView.Player = Player; Player.Prepare(VideoSource); Player.AddListener(PlayerListener); Player.PlayWhenReady = true; Player.AddVideoListener(this); bool haveResumePosition = ResumeWindow != C.IndexUnset; if (haveResumePosition) { Player.SeekTo(ResumeWindow, resumePosition); } } catch (Exception e) { Console.WriteLine(e); } }
public override void InitializePlayer() { var mainHandler = new Handler(); var trackSelector = new DefaultTrackSelector(mainHandler); trackSelector.AddListener(this); var loadControl = new DefaultLoadControl(); if (_mediaPlayer == null) { _mediaPlayer = ExoPlayerFactory.NewSimpleInstance(ApplicationContext, trackSelector, loadControl); _mediaPlayer.AddListener(this); } StatusChanged += (sender, args) => OnStatusChangedHandler(args); }
/// <summary> /// Plays the video contained in the URL at the given starting position. /// </summary> /// <param name="url">The URL.</param> /// <param name="position">The position.</param> private void PlayVideo(string url, long?position) { LoadingSpinnerView.Visibility = ViewStates.Visible; LoadingSpinnerView.Start(); // // Prepare the standard HTTP information for the source. // var mediaUri = global::Android.Net.Uri.Parse(url); var userAgent = Util.GetUserAgent(Activity, "Crex"); var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent); var defaultDataSourceFactory = new DefaultDataSourceFactory(Activity, null, defaultHttpDataSourceFactory); IMediaSource source; // // Determine if this is an HLS or MP4 stream. // if (mediaUri.Path.EndsWith(".m3u8", StringComparison.InvariantCultureIgnoreCase) || mediaUri.Path.EndsWith("/hsl", StringComparison.InvariantCultureIgnoreCase)) { using (var factory = new HlsMediaSource.Factory(defaultDataSourceFactory)) { source = factory.CreateMediaSource(mediaUri); } } else { using (var factory = new ExtractorMediaSource.Factory(defaultDataSourceFactory)) { source = factory.CreateMediaSource(mediaUri); } } // // Create the player and get it ready for playback. // AutoPlay = true; VideoPlayer = ExoPlayerFactory.NewSimpleInstance(Activity, new DefaultTrackSelector()); VideoPlayer.AddListener(this); PlayerView.Player = VideoPlayer; if (position.HasValue) { VideoPlayer.SeekTo(position.Value); } VideoPlayer.Prepare(source, !position.HasValue, false); }
private IMediaSource CreateMediaSourceWithAds(IMediaSource videoSource, Uri imAdsUri) { try { Player = ExoPlayerFactory.NewSimpleInstance(ActivityContext); SimpleExoPlayerView.Player = Player; if (ImaAdsLoader == null) { var imaSdkSettings = ImaSdkFactory.Instance.CreateImaSdkSettings(); imaSdkSettings.AutoPlayAdBreaks = true; imaSdkSettings.DebugMode = true; ImaAdsLoader = new ImaAdsLoader.Builder(ActivityContext) .SetImaSdkSettings(imaSdkSettings) .SetMediaLoadTimeoutMs(30 * 1000) .SetVastLoadTimeoutMs(30 * 1000) .BuildForAdTag(imAdsUri); // here is url for vast xml file ImaAdsLoader.SetPlayer(Player); IMediaSource mediaSourceWithAds = new AdsMediaSource( videoSource, new AdMediaSourceFactory(this), ImaAdsLoader, SimpleExoPlayerView); return(mediaSourceWithAds); } return(new AdsMediaSource(videoSource, new AdMediaSourceFactory(this), ImaAdsLoader, SimpleExoPlayerView)); } catch (ClassNotFoundException e) { Console.WriteLine(e.Message); // IMA extension not loaded. return(null); } catch (Exception e) { Console.WriteLine(e); return(null); } }
private void SetPlayer() { try { AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); trackSelector.SetParameters(new DefaultTrackSelector.ParametersBuilder().Build()); VideoPlayer = ExoPlayerFactory.NewSimpleInstance(MainContext, trackSelector); DefaultDataSourceFac = new DefaultDataSourceFactory(MainContext, Util.GetUserAgent(MainContext, AppSettings.ApplicationName), BandwidthMeter); VideoSurfaceView.UseController = true; VideoSurfaceView.Player = VideoPlayer; } catch (Exception e) { Console.WriteLine(e); } }
private void InitializePlayer() { try { if (Constant.Player == null) { AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); Constant.Player = ExoPlayerFactory.NewSimpleInstance(Constant.Context, trackSelector); PlayerListener = new PlayerEvents(this); Constant.Player.AddListener(PlayerListener); Constant.Player.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(C.UsageMedia).SetContentType(C.ContentTypeMusic).Build(), true); Constant.Player.SeekParameters = SeekParameters.Default; Constant.Player.AudioAttributes = AudioAttributes.Default; } } catch (Exception e) { Console.WriteLine(e); } }
private PlayerManager(IQueuePositionListener queuePositionListener, PlayerView localPlayerView, PlayerControlView castControlView, Context context, CastContext castContext) { this.queuePositionListener = queuePositionListener; this.localPlayerView = localPlayerView; this.castControlView = castControlView; mediaQueue = new List <DemoUtil.Sample>(); currentItemIndex = C.IndexUnset; concatenatingMediaSource = new ConcatenatingMediaSource(); DefaultTrackSelector trackSelector = new DefaultTrackSelector(BANDWIDTH_METER); IRenderersFactory renderersFactory = new DefaultRenderersFactory(context); exoPlayer = ExoPlayerFactory.NewSimpleInstance(renderersFactory, trackSelector); exoPlayer.AddListener(this); localPlayerView.Player = exoPlayer; castPlayer = new CastPlayer(castContext); castPlayer.AddListener(this); castPlayer.SetSessionAvailabilityListener(this); castControlView.Player = castPlayer; }
private void InitializePlayback(StreamingUri itemToPlay) { if (mediaStreams == null) { mediaStreams = JsonConvert.DeserializeObject <List <StreamingUri> >(Intent.GetStringExtra("mediaStreams")) .Where(a => a.StreamingUrl.OriginalString.Contains(".mp4")).ToList(); } if (player is null) { mediaSourceFactory = new DefaultDataSourceFactory(this, Util.GetUserAgent(this, Application.PackageName)); trackSelectorFactory = new AdaptiveTrackSelection.Factory(); var renderersFactory = new DefaultRenderersFactory(this); player = ExoPlayerFactory.NewSimpleInstance(this, renderersFactory, new DefaultTrackSelector(trackSelectorFactory)); playerView = FindViewById <PlayerView>(Resource.Id.playerView); playerView.Player = player; playerView.RequestFocus(); playerView.SetControllerVisibilityListener(this); linksSpinner = FindViewById <AppCompatSpinner>(Resource.Id.linksSpinner); player.PlayWhenReady = true; playerView.ControllerShowTimeoutMs = 3000; if (mediaStreams != null && mediaStreams.Count > 0) { var titles = new List <string>() { }; mediaStreams.ForEach(a => titles.Add(a.StreamingQuality + " - MP4")); linksSpinner.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, titles); linksSpinner.ItemSelected += LinksSpinner_ItemSelected; linksSpinner.SetSelection(0); } } if (itemToPlay != null) { player.Prepare(CreateMediaSource(itemToPlay)); playerView.KeepScreenOn = true; } }
public void PlayAudio(string url) { if (isPlaying) { Stop(); } current_url = url; var context = Android.App.Application.Context; var mediaUri = Android.Net.Uri.Parse(url); var userAgent = Util.GetUserAgent(context, "GlobalFM"); var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent); var defaultDataSourceFactory = new DefaultDataSourceFactory(context, null, defaultHttpDataSourceFactory); var extractorMediaSource = new ExtractorMediaSource(mediaUri, defaultDataSourceFactory, new DefaultExtractorsFactory(), null, null); var defaultBandwidthMeter = new DefaultBandwidthMeter(); var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter); var defaultTrackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); player = ExoPlayerFactory.NewSimpleInstance(context, defaultTrackSelector); player.Prepare(extractorMediaSource); player.PlayWhenReady = true; isPlaying = true; }
private void InitializePlayer() { trackSelector = new DefaultTrackSelector(); trackSelector.SetParameters(new DefaultTrackSelector.ParametersBuilder() .SetRendererDisabled(C.TrackTypeVideo, true) .Build() ); _player = ExoPlayerFactory.NewSimpleInstance(Context, trackSelector); _playerView = new PlayerView(Context) { Player = _player }; ((IVideoPlayerController)Element).Fullscreen = false; SetNativeControl(_playerView); SetBackgroundColor(Android.Graphics.Color.Black); _playerView.UseController = Element.AreTransportControlsEnabled; _player.PlayWhenReady = Element.AutoPlay; INITIAL_HEIGHT = (int)Element.HeightRequest; }
public void Init(Context context, Com.Google.Android.Exoplayer2.UI.PlayerView playerView) { // Create a default track selector. var bandwidthMeter = new DefaultBandwidthMeter(); var videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); // Create a player instance. player = ExoPlayerFactory.NewSimpleInstance(context, trackSelector); // Bind the player to the view. playerView.Player = (player); // This is the MediaSource representing the content media (i.e. not the ad). var contentUrl = url; //context.GetString (Resource.String.test_content_url); HlsMediaSource.Factory hlsfac = new HlsMediaSource.Factory(mediaDataSourceFactory); //var hlsMediaSource = hlsfac.CreateMediaSource (Uri.Parse(contentUrl)); var hlsMediaSource = new HlsMediaSource(Uri.Parse(contentUrl), mediaDataSourceFactory, null, null); //var contentMediaSource = //BuildMediaSource (Uri.Parse (contentUrl),""); // Compose the content media source into a new AdsMediaSource with both ads and content. var mediaSourceWithAds = hlsMediaSource; // new AdsMediaSource( // hlsMediaSource, // /* adMediaSourceFactory= */ this, // adsLoader, // playerView.getOverlayFrameLayout(), // /* eventHandler= */ null, // /* eventListener= */ null); // Prepare the player with the source. player.SeekTo(contentPosition); player.Prepare(hlsMediaSource); player.PlayWhenReady = (true); }
public void InitPlayer() { _context = CrossRxMediaPlayer.AppContext; // 1. Create a default TrackSelector Handler mainHandler = new Handler(); _defaultBandwidthMeter = new DefaultBandwidthMeter(); _adaptiveVideoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(_defaultBandwidthMeter); _trackSelector = new DefaultTrackSelector(_adaptiveVideoTrackSelectionFactory); // 2. Create a default LoadControl _defaultLoadControl = new DefaultLoadControl(); // 3. Create the player TheExoPlayer = ExoPlayerFactory.NewSimpleInstance(_context, _trackSelector, _defaultLoadControl); TheExoPlayer.AddListener(this); PlayerStatesSubject = new BehaviorSubject <PlayerState>(PlayerState.Idle); }
public override void InitializePlayer() { bool needNewPlayer = _mediaPlayer == null; if (needNewPlayer) { var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); var trackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); var eventLogger = new ExoPlayerEventLogger(trackSelector); var renderersFactory = new DefaultRenderersFactory(ApplicationContext); var loadControl = new DefaultLoadControl(); _mediaPlayer = ExoPlayerFactory.NewSimpleInstance(renderersFactory, trackSelector, loadControl); _mediaPlayer.AddListener(eventLogger); _mediaPlayer.AddListener(this); _mediaPlayer.SetAudioDebugListener(eventLogger); _mediaPlayer.SetMetadataOutput(eventLogger); } StatusChanged += (sender, args) => OnStatusChangedHandler(args); }
private void InitializePlayer() { try { if (selectedMedia.Status == 1) { btnAcceptReject.Text = "Reject"; btnAcceptReject.Background = Resources.GetDrawable(Resource.Drawable.Shape_Radius_Btn); btnAcceptReject.BackgroundTintList = Resources.GetColorStateList(Resource.Color.gnt_red); } else { btnAcceptReject.Text = "Accept"; btnAcceptReject.Background = Resources.GetDrawable(Resource.Drawable.Shape_Radius_Btn); btnAcceptReject.BackgroundTintList = Resources.GetColorStateList(Android.Resource.Color.HoloGreenLight); } AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); var newParameters = new DefaultTrackSelector.ParametersBuilder() .SetMaxVideoSizeSd() .Build(); trackSelector.SetParameters(newParameters); //DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder(); //builder.SetBufferDurationsMs(DefaultLoadControl.DefaultMinBufferMs, 60000, DefaultLoadControl.DefaultBufferForPlaybackMs, DefaultLoadControl.DefaultBufferForPlaybackAfterRebufferMs); //DefaultLoadControl loadControl = builder.CreateDefaultLoadControl(); // Player = ExoPlayerFactory.NewSimpleInstance(this, trackSelector); } catch (System.Exception) { } }
//private void txtHideComment_Click(object sender, EventArgs e) //{ // txtHideComment.Visibility = ViewStates.Gone; // FragmentTransaction ftvideo = SupportFragmentManager.BeginTransaction(); // ftvideo.AddToBackStack(null); // ftvideo.SetCustomAnimations(Resource.Animation.slide_up, Resource.Animation.slide_down); // ftvideo.Hide(CommentsFragment).Commit(); //} private void InitializePlayer() { try { AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); var newParameters = new DefaultTrackSelector.ParametersBuilder() .SetMaxVideoSizeSd() .Build(); trackSelector.SetParameters(newParameters); //DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder(); //builder.SetBufferDurationsMs(DefaultLoadControl.DefaultMinBufferMs, 60000, DefaultLoadControl.DefaultBufferForPlaybackMs, DefaultLoadControl.DefaultBufferForPlaybackAfterRebufferMs); //DefaultLoadControl loadControl = builder.CreateDefaultLoadControl(); // Player = ExoPlayerFactory.NewSimpleInstance(this, trackSelector); } catch (System.Exception) { } }
public void PlayVideo(string videoUrL, VideoObject videoObject, RestrictedVideoFragment restrictedVideoPlayerFragment, Activity activity) { try { //RestrictedVideoPlayerFragment = restrictedVideoPlayerFragment; //ActivityFragment = activity; if (videoObject != null) { VideoData = videoObject; ReleaseVideo(); bool vidMonit = ListUtils.MySettingsList?.UsrVMon == "on" && VideoData.Monetization == "1" && VideoData.Owner.VideoMon == "1"; if (ListUtils.ArrayListPlay.Count > 0) { ListUtils.ArrayListPlay.Remove(VideoData); } var isPro = ListUtils.MyChannelList.FirstOrDefault()?.IsPro ?? "0"; if (!AppSettings.AllowOfflineDownload || AppSettings.AllowDownloadProUser && isPro == "0") { DownloadIcon.Visibility = ViewStates.Gone; } MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand)); LoadingProgressBar.Visibility = ViewStates.Visible; Uri url; //Rent Or Sell if (!string.IsNullOrEmpty(VideoData.SellVideo) && VideoData.SellVideo != "0" || !string.IsNullOrEmpty(VideoData.RentPrice) && VideoData.RentPrice != "0" && AppSettings.RentVideosSystem) { if (!string.IsNullOrEmpty(VideoData.Demo) && VideoData.IsPurchased == "0") { if (!VideoData.Demo.Contains(Client.WebsiteUrl)) { VideoData.Demo = Client.WebsiteUrl + "/" + VideoData.Demo; } url = Uri.Parse(VideoData.Demo); ShowRestrictedVideo = true; } else if (VideoData.IsPurchased != "0") { url = Uri.Parse(!string.IsNullOrEmpty(videoUrL) ? videoUrL : VideoData.VideoLocation); } else { if (!string.IsNullOrEmpty(VideoData.SellVideo) && VideoData.SellVideo != "0") { ShowRestrictedVideoFragment(restrictedVideoPlayerFragment, activity, "purchaseVideo"); } else if (!string.IsNullOrEmpty(VideoData.RentPrice) && VideoData.RentPrice != "0" && AppSettings.RentVideosSystem) { ShowRestrictedVideoFragment(restrictedVideoPlayerFragment, activity, "RentVideo"); } return; } } else { url = Uri.Parse(!string.IsNullOrEmpty(videoUrL) ? videoUrL : VideoData.VideoLocation); } AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); var newParameters = new DefaultTrackSelector.ParametersBuilder() .SetMaxVideoSizeSd() .SetPreferredAudioLanguage("deu") .Build(); trackSelector.SetParameters(newParameters); Player = ExoPlayerFactory.NewSimpleInstance(ActivityContext, trackSelector); FullWidthSetting(); DefaultDataMediaFactory = new DefaultDataSourceFactory(ActivityContext, Util.GetUserAgent(ActivityContext, AppSettings.ApplicationName), BandwidthMeter); VideoSource = null; // Produces DataSource instances through which media data is loaded. VideoSource = GetMediaSourceFromUrl(url, "normal"); if (SimpleExoPlayerView == null) { Initialize(); } //Set Cache Media Load if (PlayerSettings.EnableOfflineMode) { VideoSource = CreateCacheMediaSource(VideoSource, url); if (VideoSource != null) { DownloadIcon.SetImageResource(Resource.Drawable.ic_checked_red); DownloadIcon.Tag = "Downloaded"; RunVideoWithAds(VideoSource, vidMonit); return; } } //Set Interactive Media Ads if (isPro == "0" && PlayerSettings.ShowInteractiveMediaAds && vidMonit) { VideoSource = CreateMediaSourceWithAds(VideoSource, PlayerSettings.ImAdsUri); } if (VideoSource == null) { VideoSource = GetMediaSourceFromUrl(url, "normal"); RunVideoWithAds(VideoSource, vidMonit); } else { RunVideoWithAds(VideoSource, vidMonit); } } } catch (Exception exception) { Console.WriteLine(exception); } }
public void PlayVideo(string videoUrL, GetMoviesObject.Movie videoObject) { try { if (videoObject != null) { VideoData = videoObject; VideoViewerActivity.GetInstance()?.TabVideosAbout?.LoadVideo_Data(videoObject); TabbedMainActivity.GetInstance()?.SetOnWakeLock(); ReleaseVideo(); MFullScreenIcon.SetImageDrawable(ActivityContext.GetDrawable(Resource.Drawable.ic_action_ic_fullscreen_expand)); Uri videoUrl = Uri.Parse(!string.IsNullOrEmpty(videoUrL) ? videoUrL : VideoData.Source); AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(); var trackSelector = new DefaultTrackSelector(trackSelectionFactory); trackSelector.SetParameters(new DefaultTrackSelector.ParametersBuilder().Build()); Player = ExoPlayerFactory.NewSimpleInstance(ActivityContext, trackSelector); DefaultDataMediaFactory = new DefaultDataSourceFactory(ActivityContext, Util.GetUserAgent(ActivityContext, AppSettings.ApplicationName), BandwidthMeter); // Produces DataSource instances through which media data is loaded. var defaultSource = GetMediaSourceFromUrl(videoUrl, "normal"); VideoSource = null; //Set Interactive Media Ads if (PlayerSettings.ShowInteractiveMediaAds) { VideoSource = CreateMediaSourceWithAds(defaultSource, PlayerSettings.ImAdsUri); } if (SimpleExoPlayerView == null) { Initialize(); } //Set Cache Media Load if (PlayerSettings.EnableOfflineMode) { VideoSource = VideoSource == null?CreateCacheMediaSource(defaultSource, videoUrl) : CreateCacheMediaSource(VideoSource, videoUrl); if (VideoSource != null) { SimpleExoPlayerView.Player = Player; Player.Prepare(VideoSource); Player.AddListener(PlayerListener); Player.PlayWhenReady = true; bool haveResumePosition = ResumeWindow != C.IndexUnset; if (haveResumePosition) { Player.SeekTo(ResumeWindow, ResumePosition); } return; } } if (VideoSource == null) { if (!string.IsNullOrEmpty(videoUrL)) { if (videoUrL.Contains("youtube") || videoUrL.Contains("Youtube") || videoUrL.Contains("youtu")) { //Task.Run(async () => //{ // var newurl = await VideoInfoRetriever.GetEmbededVideo(VideoData.source); // videoSource = CreateDefaultMediaSource(Android.Net.Uri.Parse(newurl)); //}); } else { VideoSource = GetMediaSourceFromUrl(Uri.Parse(videoUrL), "normal"); SimpleExoPlayerView.Player = Player; Player.Prepare(VideoSource); Player.AddListener(PlayerListener); Player.PlayWhenReady = true; bool haveResumePosition = ResumeWindow != C.IndexUnset; if (haveResumePosition) { Player.SeekTo(ResumeWindow, ResumePosition); } } } } else { SimpleExoPlayerView.Player = Player; Player.Prepare(VideoSource); Player.AddListener(PlayerListener); Player.PlayWhenReady = true; bool haveResumePosition = ResumeWindow != C.IndexUnset; if (haveResumePosition) { Player.SeekTo(ResumeWindow, ResumePosition); } } } } catch (Exception exception) { Console.WriteLine(exception); } }