public void SetupRenderer(uint foregroundProcessId, IMediaSource source) { if (_mediaElement != null) { Action fn = (() => { _mediaElement.SetMediaStreamSource(source); }); _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new DispatchedHandler(fn)); } }
public void SetupRenderer(uint foregroundProcessId, IMediaSource source, Windows.Foundation.Size videoControlSize) { if (_mediaElement != null) { Action fn = (() => { _mediaElement.SetMediaStreamSource(source); }); var asyncOp = _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new DispatchedHandler(fn)); _isSetup = true; } }
public MediaTransformation(IMediaSource source, string format) { #region Preconditions if (source == null) throw new ArgumentNullException(nameof(source)); if (format == null) throw new ArgumentNullException(nameof(format)); #endregion Source = source; Format = format; this.width = source.Width; this.height = source.Height; }
private IMediaSource CreateCacheMediaSource(IMediaSource videoSource, Uri videoUrL) { try { if (PlayerSettings.EnableOfflineMode) { videoSource = GetMediaSourceFromUrl(videoUrL, "normal"); return(videoSource); } else { return(null); } } catch (Exception exception) { Console.WriteLine(exception); return(null); } }
public IMediaSource CreateCacheMediaSource(IMediaSource videoSource, Android.Net.Uri videoUrL) { try { if (Player_Settings.EnableOfflineMode) { //Set the video for offline mode if (!string.IsNullOrEmpty(Videodata.id)) { string file = VideoDownloadAsyncControler.GetDownloadedDiskVideoUri(Videodata.id); SimpleCache cache = new SimpleCache(ActivityContext.CacheDir, new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 10)); CacheDataSourceFactory cacheDataSource = new CacheDataSourceFactory(cache, DefaultDatamediaFactory); if (file != null) { videoUrL = Android.Net.Uri.Parse(file); videoSource = new ExtractorMediaSource(videoUrL, cacheDataSource, new DefaultExtractorsFactory(), mainHandler, eventLogger); return(videoSource); } else { return(null); } } else { return(null); } } else { return(null); } } catch (Exception exception) { Crashes.TrackError(exception); return(null); } }
private void ListAdapter_OnPreview(Music obj) { listAdapter.UpdatePlaying(obj); currentPreview = obj; _audioPlayer.PlayWhenReady = false; mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(obj.url), httpDataSourceFactory, extractorsFactory, null, null); try { _audioPlayer.Prepare(mediaSource); _audioPlayer.PlayWhenReady = true; } catch (Exception e) { LoginFuncs.ShowError(Context.ApplicationContext, e); } Bootlegger.BootleggerClient.LogUserAction("MusicPreview", new KeyValuePair <string, string>("music", obj.url), new KeyValuePair <string, string>("eventid", Bootlegger.BootleggerClient.CurrentEvent.id)); }
private static IPlaySource Create(PlaybillItemEntity entity, IMediaSource mediaSource) { var range = new PlayRange(TimeSpan.FromSeconds(entity.MarkerIn), TimeSpan.FromSeconds(entity.MarkerDuration)); CGItemCollection cgItems = null; if (entity.CGContents != null) { cgItems = CGItemCollection.FromXml(entity.CGContents); } if (cgItems == null) { return(new PlaySource(mediaSource, range)); } else { return(new PlaySource(mediaSource, range, cgItems)); } }
private IMediaSource BuildMediaSource(android.Net.Uri uri, string overrideExtension) { int type = Utils.InferContentType(uri, overrideExtension); IMediaSource src = null; switch (type) { case C.TypeDash: src = new DashMediaSource.Factory(new DefaultDashChunkSource.Factory(mediaDataSourceFactory), BuildDataSourceFactory(false)) .SetManifestParser(new FilteringManifestParser(new DashManifestParser(), GetOfflineStreamKeys(uri))) .CreateMediaSource(uri); break; case C.TypeSs: src = new SsMediaSource.Factory(new DefaultSsChunkSource.Factory(mediaDataSourceFactory), BuildDataSourceFactory(false)) .SetManifestParser(new FilteringManifestParser(new SsManifestParser(), GetOfflineStreamKeys(uri))) .CreateMediaSource(uri); break; case C.TypeHls: src = new HlsMediaSource.Factory(mediaDataSourceFactory) .SetPlaylistParserFactory(new FilteringManifestParser(new HlsPlaylistParser(), GetOfflineStreamKeys(uri))) .CreateMediaSource(uri); break; case C.TypeOther: src = new ExtractorMediaSource.Factory(mediaDataSourceFactory).CreateMediaSource(uri); break; default: throw new IllegalStateException("Unsupported type: " + type); } //Todo: implement IAnalyticsListener src.AddEventListener(mainHandler, eventLogger); return(src); }
private IMediaSource CreateMediaSource(StreamingUri link) { Android.Net.Uri uri = Android.Net.Uri.Parse(link.StreamingUrl.OriginalString); IMediaSource source = null; if (link.StreamingUrl.OriginalString.Contains(".mpd")) { source = new DashMediaSource.Factory(new DefaultDashChunkSource.Factory(mediaSourceFactory), mediaSourceFactory) .SetManifestParser(new FilteringManifestParser(new DashManifestParser(), new List <StreamKey>())) .CreateMediaSource(uri); } if (link.StreamingUrl.OriginalString.Contains(".m3u8")) { source = new HlsMediaSource.Factory(mediaSourceFactory) .SetPlaylistParserFactory(new DefaultHlsPlaylistParserFactory(new List <StreamKey>())) .CreateMediaSource(uri); } if (link.StreamingUrl.OriginalString.Contains(".mp4")) { source = new ExtractorMediaSource.Factory(mediaSourceFactory).CreateMediaSource(uri); } return(source); }
//public TimeSpan? NativeDuration //{ // get // { // return this.MediaSource.NativeDuration; // } //} public MarkableMediaSource(IMediaSource mediaSource, PlayRange playRange) { if (mediaSource == null) { throw new ArgumentNullException("mediaSource"); } var adjustedPlayRange = mediaSource.Adjust(playRange); // 包含对playRange有效性的验证 //MarkableMediaSource markable = mediaSource as MarkableMediaSource; //if (markable!=null) //{ // this.MediaSource = markable.MediaSource; //} //else //{ // this.MediaSource = mediaSource; //} this.MediaSource = mediaSource; this.PlayRange = adjustedPlayRange; }
public T ToEntity <T>(IMediaSource mediaSource) where T : IMediaSourceEntity { IMediaSourceEntity result = null; var fileMediaSource = mediaSource as FileMediaSource; if (fileMediaSource != null) { MediaFileEntity entity = new MediaFileEntity(); entity.Id = fileMediaSource.Id; entity.AudioGain = fileMediaSource.AudioGain; entity.FileName = fileMediaSource.FileName; entity.Title = fileMediaSource.Title; //entity.OriginalFileName=fileMediaSource. //entity.MediaFileCategory=fileMediaSource.me entity.Duration = fileMediaSource.Duration.Value.TotalSeconds; //entity.MarkerIn=fileMediaSource.m result = entity; return((T)result); } else { var channelSource = mediaSource as ChannelMediaSource; if (channelSource != null) { var entity = new ChannelInfo(); entity.Id = channelSource.Id; entity.Title = channelSource.Title; //entity.Special result = entity; return((T)result); } else { throw new ArgumentException(); } } }
public void SetupRenderer(uint foregroundProcessId, IMediaSource source, Windows.Foundation.Size videoControlSize) { _renderer.SetupRenderer(foregroundProcessId, source, videoControlSize); _isSetup = true; }
private bool IsMLSource(IMediaSource mediaSource) { return(mediaSource is IFileMediaSource); }
public MediaPreviewItem(IMediaSource source) { MediaSource = source; }
public void SetService(IMediaSource source) { _auth = source.Auth; VideoServiceSettings settings = VideoSettings.GetServiceSettings(source.Id); txtUsername.Text = settings.Username; ckBoxSavePassword.Checked = !_auth.PasswordRequired(settings.Username); ckBoxSavePassword.Text = _auth.LoginSavePasswordText; lblEmailExample.Text = _auth.LoginExampleText; lblUsername.Text = _auth.LoginUsernameLabel; lblPassword.Text = _auth.LoginPasswordLabel; pictureBoxLogo.Image = _auth.LoginLogo; if (pictureBoxLogo.Image != null) pictureBoxLogo.Size = pictureBoxLogo.Image.Size; else pictureBoxLogo.Size = new Size(0, 0); RefreshLayout(); }
private void SetPlayAudio() { try { if (Constant.Player == null) { return; } try { if (Constant.Player.PlayWhenReady) { Constant.Player.Stop(); Constant.Player.Release(); } Constant.Player = null; InitializePlayer(); //GC Collector GC.Collect(); } catch (Exception e) { Console.WriteLine(e); } IsReset = true; Item = Constant.ArrayListPlay[Constant.PlayPos]; if (Item == null) { return; } ChangeText(); Uri mediaUri; if (Item.AudioLocation.Contains("stream") && Item.AudioLocationOriginal.Contains("stream")) { mediaUri = Uri.Parse(Item.AudioLocationOriginal); } else if (!string.IsNullOrEmpty(Item.AudioLocation) && Item.AudioLocation.Contains("http")) { if (Item.IsPurchased != null && Item.IsOwner != null && (Item.Price == 0 || Item.IsOwner.Value || Item.IsPurchased.Value)) { mediaUri = Uri.Parse(Item.AudioLocation); } else if (Item.Price != 0 && !string.IsNullOrEmpty(Item.DemoTrack)) { if (!Item.DemoTrack.Contains(Client.WebsiteUrl)) { Item.DemoTrack = Client.WebsiteUrl + "/" + Item.DemoTrack; } mediaUri = Uri.Parse(Item.DemoTrack); } else { mediaUri = Uri.Parse(Item.AudioLocation); } } else if (!string.IsNullOrEmpty(Item.AudioLocation) && (Item.AudioLocation.Contains("file://") || Item.AudioLocation.Contains("content://") || Item.AudioLocation.Contains("storage") || Item.AudioLocation.Contains("/data/user/0/"))) { mediaUri = Uri.Parse(Item.AudioLocation); } else { mediaUri = Uri.Parse(Item.AudioLocation); } PlayerSource = null; PlayerSource = GetMediaSourceFromUrl(mediaUri, "normal"); Constant.Player?.Prepare(PlayerSource); Constant.Player?.AddListener(PlayerListener); OnPrepared(); } catch (Exception e) { Console.WriteLine(e); } }
/// <inheritdoc /> public void Update(IMediaSource mediaSource) { if (collector.IsAttached) { collector.Detach(); // remove media specific data RemoveAdditionalData(MediaData); MediaData = null; } if (mediaSource != null) { // add media specific data MediaData = Analytics.GetAdditionalData(mediaSource as DependencyObject); AddAdditionalData(MediaData); collector.Attach(playerMonitor, AdaptiveMonitor, EnvironmentMonitor, EdgeServerMonitor); } }
public virtual void Update(IMediaSource mediaSource) { Debug.WriteLine("MediaElementWrapperStreamingMediaPlugin.Update()"); }
public MediaCreateContext(MediaContentContext context, IMediaSource source) { ContentContext = context; Source = source; Cancel = false; }
private void RunVideoWithAds(IMediaSource videoSource, bool showAds) { try { var isPro = ListUtils.MyChannelList.FirstOrDefault()?.IsPro ?? "0"; if (isPro == "0" && ListUtils.AdsVideoList.Count > 0 && Methods.CheckConnectivity() && showAds) { Random rand = new Random(); var playPos = rand.Next(ListUtils.AdsVideoList.Count - 1 + 1); DataAdsVideo = ListUtils.AdsVideoList[playPos]; var type = Methods.AttachmentFiles.Check_FileExtension(DataAdsVideo?.Media); if (type == "Video" && DataAdsVideo != null) { //AppSettings.ShowButtonSkip = DataAdsVideo var adVideoSource = GetMediaSourceFromUrl(Uri.Parse(DataAdsVideo.Media), "Ads"); if (adVideoSource != null) { ListUtils.AdsVideoList.Remove(DataAdsVideo); // Plays the first video, then the second video. ConcatenatingMediaSource concatenatedSource = new ConcatenatingMediaSource(adVideoSource, videoSource); SimpleExoPlayerView.Player = Player; Player.Prepare(concatenatedSource); Player.AddListener(PlayerListener); Player.PlayWhenReady = true; Player.AddVideoListener(this); ExoTopLayout.Visibility = ViewStates.Gone; ExoEventButton.Visibility = ViewStates.Invisible; BtnSkipIntro.Visibility = ViewStates.Visible; ExoTopAds.Visibility = ViewStates.Visible; BtnSkipIntro.Text = AppSettings.ShowButtonSkip.ToString(); BtnSkipIntro.Enabled = false; RunTimer(); } else { SimpleExoPlayerView.Player = Player; Player.Prepare(videoSource); Player.AddListener(PlayerListener); Player.AddVideoListener(this); Player.PlayWhenReady = true; ExoTopLayout.Visibility = ViewStates.Visible; ExoEventButton.Visibility = ViewStates.Visible; BtnSkipIntro.Visibility = ViewStates.Gone; ExoTopAds.Visibility = ViewStates.Gone; } } else { SimpleExoPlayerView.Player = Player; Player.Prepare(videoSource); Player.AddListener(PlayerListener); Player.PlayWhenReady = true; Player.AddVideoListener(this); ExoTopLayout.Visibility = ViewStates.Visible; ExoEventButton.Visibility = ViewStates.Visible; BtnSkipIntro.Visibility = ViewStates.Gone; ExoTopAds.Visibility = ViewStates.Gone; } } else { SimpleExoPlayerView.Player = Player; Player.Prepare(videoSource); Player.AddListener(PlayerListener); Player.AddVideoListener(this); Player.PlayWhenReady = true; ExoTopLayout.Visibility = ViewStates.Visible; ExoEventButton.Visibility = ViewStates.Visible; BtnSkipIntro.Visibility = ViewStates.Gone; ExoTopAds.Visibility = ViewStates.Gone; } bool haveResumePosition = ResumeWindow != C.IndexUnset; if (haveResumePosition) { Player.SeekTo(ResumeWindow, ResumePosition); } } catch (Exception e) { Console.WriteLine(e); } }
/// <summary> /// Detaches the given SourceStream from the ClientSession /// </summary> /// <param name="source">The SourceStream to detach</param> /// <param name="session">The session to detach from</param> internal void RemoveSource(IMediaSource source) { if (source is RtpSource) { RtpSource rtpSource = source as RtpSource; if (rtpSource.RtpClient != null) { //For each TransportContext in the RtpClient foreach (RtpClient.TransportContext tc in rtpSource.RtpClient.GetTransportContexts()) Attached.Remove(tc); //Attach events //rtpSource.RtpClient.RtcpPacketReceieved -= OnSourceRtcpPacketRecieved; rtpSource.RtpClient.RtpPacketReceieved -= OnSourceRtpPacketRecieved; rtpSource.RtpClient.RtpFrameChanged -= OnSourceFrameChanged; } } Playing.Remove(source.Id); }
public void SetupRenderer(uint foregroundProcessId, IMediaSource source) { _renderer.SetupRenderer(foregroundProcessId, source); }
public virtual void Update(IMediaSource mediaSource) { Debug.WriteLine("MediaElementWrapperStreamingMediaPlugin.Update()"); }
void IPlugin.Update(IMediaSource mediaSource) { CurrentMediaSource = mediaSource; OnUpdate(); IsEnabled = mediaSource == null ? false : GetIsEnabled((DependencyObject)mediaSource); }
public void Update(IMediaSource mediaSource) { Debug.WriteLine("StreamingMediaPlugin.Update()"); }
/// <inheritdoc /> public void Update(IMediaSource mediaSource) { // do nothing }
public MediaSourceContext(IMediaSource source) { _source = source; }
public void Update(IMediaSource mediaSource) { Debug.WriteLine("StreamingMediaPlugin.Update()"); }
public static void SetCustomMediaStream(DependencyObject obj, IMediaSource value) { obj.SetValue(CustomMediaStreamProperty, value); }
public MediaSourceViewModel(IMediaSource source) { Source = source; Selected = false; }
internal static extern void LoadMediaSource(IMediaSource IMediaSourceHandler);
// Internal methods private void InitializePlayer() { if (player == null) { Intent intent = Intent; string action = intent.Action; android.Net.Uri[] uris; string[] extensions; if (ACTION_VIEW.Equals(action)) { uris = new android.Net.Uri[] { intent.Data }; extensions = new string[] { intent.GetStringExtra(EXTENSION_EXTRA) }; } else if (ACTION_VIEW_LIST.Equals(action)) { string[] uristrings = intent.GetStringArrayExtra(URI_LIST_EXTRA); uris = new android.Net.Uri[uristrings.Length]; for (int i = 0; i < uristrings.Length; i++) { uris[i] = android.Net.Uri.Parse(uristrings[i]); } extensions = intent.GetStringArrayExtra(EXTENSION_LIST_EXTRA); if (extensions == null) { extensions = new string[uristrings.Length]; } } else { ShowToast(GetString(Resource.String.unexpected_intent_action, action)); Finish(); return; } if (Utils.MaybeRequestReadExternalStoragePermission(this, uris)) { // The player will be reinitialized if the permission is granted. return; } DefaultDrmSessionManager drmSessionManager = null; if (intent.HasExtra(DRM_SCHEME_EXTRA) || intent.HasExtra(DRM_SCHEME_UUID_EXTRA)) { string drmLicenseUrl = intent.GetStringExtra(DRM_LICENSE_URL_EXTRA); string[] keyRequestPropertiesArray = intent.GetStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES_EXTRA); bool multiSession = intent.GetBooleanExtra(DRM_MULTI_SESSION_EXTRA, false); int errorstringId = Resource.String.error_drm_unknown; if (Utils.SdkInt < 18) { errorstringId = Resource.String.error_drm_not_supported; } else { try { string drmSchemeExtra = intent.HasExtra(DRM_SCHEME_EXTRA) ? DRM_SCHEME_EXTRA : DRM_SCHEME_UUID_EXTRA; UUID drmSchemeUuid = Utils.GetDrmUuid(intent.GetStringExtra(drmSchemeExtra)); if (drmSchemeUuid == null) { errorstringId = Resource.String.error_drm_unsupported_scheme; } else { drmSessionManager = BuildDrmSessionManagerV18( drmSchemeUuid, drmLicenseUrl, keyRequestPropertiesArray, multiSession); } } catch (UnsupportedDrmException e) { errorstringId = e.Reason == UnsupportedDrmException.ReasonUnsupportedScheme ? Resource.String.error_drm_unsupported_scheme : Resource.String.error_drm_unknown; } } if (drmSessionManager == null) { ShowToast(errorstringId); Finish(); return; } } ITrackSelectionFactory trackSelectionFactory; string abrAlgorithm = intent.GetStringExtra(ABR_ALGORITHM_EXTRA); if (abrAlgorithm == null || ABR_ALGORITHM_DEFAULT.Equals(abrAlgorithm)) { trackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); } else if (ABR_ALGORITHM_RANDOM.Equals(abrAlgorithm)) { trackSelectionFactory = new RandomTrackSelection.Factory(); } else { ShowToast(Resource.String.error_unrecognized_abr_algorithm); Finish(); return; } bool preferExtensionDecoders = intent.GetBooleanExtra(PREFER_EXTENSION_DECODERS_EXTRA, false); int extensionRendererMode = ((DemoApplication)Application).UseExtensionRenderers() ? (preferExtensionDecoders ? DefaultRenderersFactory.ExtensionRendererModePrefer : DefaultRenderersFactory.ExtensionRendererModeOn) : DefaultRenderersFactory.ExtensionRendererModeOff; DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this, extensionRendererMode); trackSelector = new DefaultTrackSelector(trackSelectionFactory); trackSelector.SetParameters(trackSelectorParameters); lastSeenTrackGroupArray = null; player = ExoPlayerFactory.NewSimpleInstance(renderersFactory, trackSelector, drmSessionManager); eventLogger = new EventLogger(trackSelector); player.AddListener(new PlayerEventListener(this)); player.PlayWhenReady = startAutoPlay; player.AddListener(eventLogger); // Cannot implement the AnalyticsListener because the binding doesn't work. //Todo: implement IAnalyticsListener //player.AddAnalyticsListener(eventLogger); player.AddAudioDebugListener(eventLogger); player.AddVideoDebugListener(eventLogger); player.AddMetadataOutput(eventLogger); //end Todo playerView.Player = player; playerView.SetPlaybackPreparer(this); debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.Start(); IMediaSource[] mediaSources = new IMediaSource[uris.Length]; for (int i = 0; i < uris.Length; i++) { mediaSources[i] = BuildMediaSource(uris[i], extensions[i]); } mediaSource = mediaSources.Length == 1 ? mediaSources[0] : new ConcatenatingMediaSource(mediaSources); string adTagUristring = intent.GetStringExtra(AD_TAG_URI_EXTRA); if (adTagUristring != null) { android.Net.Uri adTagUri = android.Net.Uri.Parse(adTagUristring); if (!adTagUri.Equals(loadedAdTagUri)) { ReleaseAdsLoader(); loadedAdTagUri = adTagUri; } IMediaSource adsMediaSource = CreateAdsMediaSource(mediaSource, android.Net.Uri.Parse(adTagUristring)); if (adsMediaSource != null) { mediaSource = adsMediaSource; } else { ShowToast(Resource.String.ima_not_loaded); } } else { ReleaseAdsLoader(); } } bool haveStartPosition = startWindow != C.IndexUnset; if (haveStartPosition) { player.SeekTo(startWindow, startPosition); } player.Prepare(mediaSource, !haveStartPosition, false); UpdateButtonVisibilities(); }
private IList <PlayItemEntity> ToEntities(PlaybillEntity billEntity, IPlayItemCollection playItemCollection, IMediaSource replaceAutoPadding) { List <PlayItemEntity> result = new List <PlayItemEntity>(); for (int i = 0; i < playItemCollection.Count; i++) { result.Add(playItemCollection[i].ToEntity(billEntity, replaceAutoPadding)); //result.Add(ToEntity(billEntity, playItemCollection[i])); } return(result); }
public void PlayVideo(bool isEndOfList, Holders.VideoAdapterViewHolder holderVideoPlayer = null, PostsObject item = null) { try { if (VideoPlayer == null) { SetPlayer(); } int targetPosition; if (!isEndOfList) { var startPosition = ((LinearLayoutManager)GetLayoutManager()).FindFirstVisibleItemPosition(); var endPosition = ((LinearLayoutManager)GetLayoutManager()).FindLastVisibleItemPosition(); if (endPosition - startPosition > 1) { endPosition = startPosition + 1; } if (startPosition < 0 || endPosition < 0) { return; } if (startPosition != endPosition) { var startPositionVideoHeight = GetVisibleVideoSurfaceHeight(startPosition); var endPositionVideoHeight = GetVisibleVideoSurfaceHeight(endPosition); targetPosition = startPositionVideoHeight > endPositionVideoHeight ? startPosition : endPosition; } else { targetPosition = startPosition; } } else { targetPosition = GetAdapter().ItemCount - 1; } if (targetPosition == PlayPosition) { return; } // set the position of the list-item that is to be played PlayPosition = targetPosition; if (VideoSurfaceView == null) { return; } VideoSurfaceView.Visibility = ViewStates.Invisible; RemoveVideoView(VideoSurfaceView); var currentPosition = targetPosition - ((LinearLayoutManager)GetLayoutManager()).FindFirstVisibleItemPosition(); var child = GetChildAt(currentPosition); if (child == null) { return; } dynamic holder; if (holderVideoPlayer != null) { holder = holderVideoPlayer; targetPosition = holderVideoPlayer.LayoutPosition; } else { Holders.VideoAdapterViewHolder holderChild = (Holders.VideoAdapterViewHolder)child.Tag; if (holderChild == null) { PlayPosition = -1; return; } else { targetPosition = holderChild.LayoutPosition; holder = holderChild; } } if (!(holder is Holders.VideoAdapterViewHolder holderVideo)) { return; } MediaContainerLayout = holderVideo.MediaContainerLayout; Thumbnail = holderVideo.VideoImage; ViewHolderParent = holderVideo.ItemView; PlayControl = holderVideo.PlayControl; if (!IsVideoViewAdded) { AddVideoView(); } holderVideo.VideoProgressBar.Visibility = ViewStates.Visible; VideoSurfaceView.Player = VideoPlayer; var controlView = VideoSurfaceView.FindViewById <PlayerControlView>(Resource.Id.exo_controller); Uri videoUrl = Uri.Parse(item != null ? item.MediaSet[0].File : NativeFeedAdapter.PixelNewsFeedList[targetPosition].MediaSet[0].File); //>> Old Code //===================== Exo Player ======================== var lis = new ExoPlayerRecyclerEvent(controlView, this, holderVideo); IMediaSource videoSource = GetMediaSourceFromUrl(videoUrl, "normal"); var dataSpec = new DataSpec(videoUrl); //0, 1000 * 1024, null if (Cache == null) { CacheVideosFiles(videoUrl); } //Cache = new SimpleCache(new Java.IO.File(MainContext.FilesDir, "media"), new NoOpCacheEvictor()); if (CacheDataSourceFactory == null) { CacheDataSourceFactory = new CacheDataSourceFactory(Cache, DefaultDataSourceFac); } var counters = new CacheUtil.CachingCounters(); CacheUtil.GetCached(dataSpec, Cache, counters); if (counters.ContentLength == counters.TotalCachedBytes()) { videoSource = new ExtractorMediaSource.Factory(CacheDataSourceFactory).CreateMediaSource(videoUrl); } else if (counters.TotalCachedBytes() == 0) { videoSource = new ExtractorMediaSource.Factory(CacheDataSourceFactory).CreateMediaSource(videoUrl); // not cached at all Task.Run(() => { try { var cacheDataSource = new CacheDataSource(Cache, CacheDataSourceFactory.CreateDataSource()); CacheUtil.Cache(dataSpec, Cache, cacheDataSource, counters, new AtomicBoolean()); double downloadPercentage = counters.TotalCachedBytes() * 100d / counters.ContentLength; Console.WriteLine(downloadPercentage); } catch (Exception e) { Console.WriteLine(e); } }); } else { // partially cached videoSource = new ExtractorMediaSource.Factory(CacheDataSourceFactory).CreateMediaSource(videoUrl); } lis.mFullScreenButton.SetOnClickListener(new NewClicker(lis.mFullScreenButton, videoUrl.ToString(), this)); VideoPlayer.Prepare(videoSource); VideoPlayer.AddListener(lis); VideoPlayer.PlayWhenReady = true; } catch (Exception e) { Console.WriteLine(e); } }
void IPlugin.Update(IMediaSource mediaSource) { // do nothing }
void IPlugin.Update(IMediaSource mediaSource) { }
/// <summary> /// Updates the media source on the player. This is called internally when a new playlist item is selected. /// </summary> /// <param name="mediaPlayer">The MediaPlayer to load the media source (playlist item) into.</param> /// <param name="oldMediaSource">The old media source (this is usually a PlaylistItem object).</param> /// <param name="newMediaSource">The new media source (this is usually a PlaylistItem object).</param> public static void UpdateMediaSource(MediaPlayer mediaPlayer, IMediaSource oldMediaSource, IMediaSource newMediaSource) { if (oldMediaSource != null) { #if SILVERLIGHT mediaPlayer.LicenseAcquirer = new LicenseAcquirer(); #else mediaPlayer.ProtectionManager = null; mediaPlayer.Stereo3DVideoPackingMode = Stereo3DVideoPackingMode.None; mediaPlayer.Stereo3DVideoRenderMode = Stereo3DVideoRenderMode.Mono; #endif mediaPlayer.VisualMarkers.Clear(); mediaPlayer.AvailableAudioStreams.Clear(); mediaPlayer.AvailableCaptions.Clear(); mediaPlayer.PosterSource = null; mediaPlayer.Close(); } foreach (var plugin in mediaPlayer.Plugins) { plugin.Update(newMediaSource); } if (newMediaSource != null) { var playlistItem = newMediaSource as PlaylistItem; #if SILVERLIGHT mediaPlayer.LicenseAcquirer = newMediaSource.LicenseAcquirer ?? new LicenseAcquirer(); #else mediaPlayer.ProtectionManager = newMediaSource.ProtectionManager; mediaPlayer.Stereo3DVideoPackingMode = newMediaSource.Stereo3DVideoPackingMode; mediaPlayer.Stereo3DVideoRenderMode = newMediaSource.Stereo3DVideoRenderMode; #endif mediaPlayer.PosterSource = newMediaSource.PosterSource; mediaPlayer.AutoLoad = newMediaSource.AutoLoad; mediaPlayer.AutoPlay = newMediaSource.AutoPlay; mediaPlayer.StartupPosition = newMediaSource.StartupPosition; mediaPlayer.VisualMarkers.Clear(); foreach (var marker in newMediaSource.VisualMarkers) { mediaPlayer.VisualMarkers.Add(marker); } mediaPlayer.AvailableAudioStreams.Clear(); foreach (var audioStream in newMediaSource.AvailableAudioStreams) { mediaPlayer.AvailableAudioStreams.Add(audioStream); } mediaPlayer.SelectedCaption = null; mediaPlayer.AvailableCaptions.Clear(); foreach (var caption in newMediaSource.AvailableCaptions) { mediaPlayer.AvailableCaptions.Add(caption); } if (newMediaSource.Source != null) { mediaPlayer.Source = newMediaSource.Source; } #if !SILVERLIGHT else if (playlistItem != null && playlistItem.SourceStream != null) { mediaPlayer.SetSource(playlistItem.SourceStream, playlistItem.MimeType); } #if !WINDOWS80 else if (playlistItem != null && playlistItem.MediaStreamSource != null) { mediaPlayer.SetMediaStreamSource(playlistItem.MediaStreamSource); } #endif #else else if (playlistItem != null && playlistItem.SourceStream != null) { mediaPlayer.SetSource(playlistItem.SourceStream); } else if (playlistItem != null && playlistItem.MediaStreamSource != null) { mediaPlayer.SetSource(playlistItem.MediaStreamSource); } #endif else { mediaPlayer.Source = null; } } }
// Internal methods private void initializePlayer() { Intent intent = Intent; bool needNewPlayer = player == null; if (needNewPlayer) { var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); trackSelectionHelper = new TrackSelectionHelper(trackSelector, adaptiveTrackSelectionFactory); lastSeenTrackGroupArray = null; eventLogger = new EventLogger(trackSelector); var drmSchemeUuid = intent.HasExtra(DRM_SCHEME_UUID_EXTRA) ? UUID.FromString(intent.GetStringExtra(DRM_SCHEME_UUID_EXTRA)) : null; IDrmSessionManager drmSessionManager = null; if (drmSchemeUuid != null) { var drmLicenseUrl = intent.GetStringExtra(DRM_LICENSE_URL); var keyRequestPropertiesArray = intent.GetStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES); int errorStringId = Resource.String.error_drm_unknown; if (Util.Util.SdkInt < 18) { errorStringId = Resource.String.error_drm_not_supported; } else { try { drmSessionManager = BuildDrmSessionManagerV18(drmSchemeUuid, drmLicenseUrl, keyRequestPropertiesArray); } catch (UnsupportedDrmException e) { errorStringId = e.Reason == UnsupportedDrmException.ReasonUnsupportedScheme ? Resource.String.error_drm_unsupported_scheme : Resource.String.error_drm_unknown; } } if (drmSessionManager == null) { ShowToast(errorStringId); return; } } var preferExtensionDecoders = intent.GetBooleanExtra(PREFER_EXTENSION_DECODERS, false); var extensionRendererMode = ((DemoApplication)Application).UseExtensionRenderers() ? (preferExtensionDecoders ? DefaultRenderersFactory.ExtensionRendererModePrefer : DefaultRenderersFactory.ExtensionRendererModeOn) : DefaultRenderersFactory.ExtensionRendererModeOff; var renderersFactory = new DefaultRenderersFactory(this, drmSessionManager, extensionRendererMode); player = ExoPlayerFactory.NewSimpleInstance(renderersFactory, trackSelector); player.AddListener(this); player.AddListener(eventLogger); player.SetAudioDebugListener(eventLogger); player.SetVideoDebugListener(eventLogger); player.SetMetadataOutput(eventLogger); simpleExoPlayerView.Player = player; player.PlayWhenReady = shouldAutoPlay; debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.Start(); } var action = intent.Action; Uri[] uris; string[] extensions; if (ACTION_VIEW.Equals(action)) { uris = new Uri[] { intent.Data }; extensions = new string[] { intent.GetStringExtra(EXTENSION_EXTRA) }; } else if (ACTION_VIEW_LIST.Equals(action)) { var uriStrings = intent.GetStringArrayExtra(URI_LIST_EXTRA); uris = new Uri[uriStrings.Length]; for (int i = 0; i < uriStrings.Length; i++) { uris[i] = Uri.Parse(uriStrings[i]); } extensions = intent.GetStringArrayExtra(EXTENSION_LIST_EXTRA); if (extensions == null) { extensions = new string[uriStrings.Length]; } } else { ShowToast(GetString(Resource.String.unexpected_intent_action, action)); return; } if (Util.Util.MaybeRequestReadExternalStoragePermission(this, uris)) { // The player will be reinitialized if the permission is granted. return; } var mediaSources = new IMediaSource[uris.Length]; for (var i = 0; i < uris.Length; i++) { mediaSources[i] = BuildMediaSource(uris[i], extensions[i]); } var mediaSource = mediaSources.Length == 1 ? mediaSources[0] : new ConcatenatingMediaSource(mediaSources); var adTagUriString = intent.GetStringExtra(AD_TAG_URI_EXTRA); if (adTagUriString != null) { Uri adTagUri = Uri.Parse(adTagUriString); if (!adTagUri.Equals(loadedAdTagUri)) { ReleaseAdsLoader(); loadedAdTagUri = adTagUri; } try { mediaSource = CreateAdsMediaSource(mediaSource, Uri.Parse(adTagUriString)); } catch (System.Exception) { ShowToast(Resource.String.ima_not_loaded); } } else { ReleaseAdsLoader(); } bool haveResumePosition = resumeWindow != C.IndexUnset; if (haveResumePosition) { player.SeekTo(resumeWindow, resumePosition); } player.Prepare(mediaSource, !haveResumePosition, false); inErrorState = false; UpdateButtonVisibilities(); }
public void MediaSource(IMediaSource mediaSource) { mediaElement.MediaSource = mediaSource; }
public void SetMediaSource(IMediaSource source) { throw new NotImplementedException(); }
public CachingMediaSource WithSource(IMediaSource inner) { _inner = inner; return this; }
void IPlugin.Update(IMediaSource mediaSource) { }
public MediaTransformation(IMediaSource source, MediaOrientation orientation, string format) : this(source, format) { Transform(orientation.GetTransforms()); }
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(DefaultTrackSelector.Parameters.GetDefaults(ActivityContext), trackSelectionFactory); trackSelector.SetParameters(new DefaultTrackSelector.ParametersBuilder(ActivityContext)); Player = new SimpleExoPlayer.Builder(ActivityContext).Build(); // Produces DataSource instances through which media data is loaded. var defaultSource = GetMediaSourceFromUrl(videoUrl, videoUrl?.Path?.Split('.').Last(), "normal", IDrmSessionManager.DummyDrmSessionManager); 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.Factory.StartNew(async () => //{ // var newurl = await VideoInfoRetriever.GetEmbededVideo(VideoData.source); // videoSource = CreateDefaultMediaSource(Android.Net.Uri.Parse(newurl)); //}); } else { VideoSource = GetMediaSourceFromUrl(Uri.Parse(videoUrL), videoUrL?.Split('.').Last(), "normal", IDrmSessionManager.DummyDrmSessionManager); 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) { Methods.DisplayReportResultTrack(exception); } }
void SetSource() { isPrepared = false; bool hasSetSource = false; DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory("1"); DefaultSsChunkSource.Factory ssChunkFactory = new DefaultSsChunkSource.Factory(httpDataSourceFactory); Handler emptyHandler = new Handler(); IMediaSource videoSource = null; if (Element.Source is HLSVideoSource) { string uri = (Element.Source as HLSVideoSource).Uri; if (!string.IsNullOrWhiteSpace(uri)) { //videoView.SetVideoURI(Android.Net.Uri.Parse(uri)); videoSource = new HlsMediaSource(Android.Net.Uri.Parse(uri), httpDataSourceFactory, emptyHandler, null); hasSetSource = true; } } else if (Element.Source is UriVideoSource) { string uri = (Element.Source as UriVideoSource).Uri; if (!string.IsNullOrWhiteSpace(uri)) { //videoView.SetVideoURI(Android.Net.Uri.Parse(uri)); var dataSourceFactory = new DefaultDataSourceFactory(Context, Util.GetUserAgent(Context, "Multimedia")); videoSource = new ExtractorMediaSource(Android.Net.Uri.Parse(uri), dataSourceFactory, new DefaultExtractorsFactory(), emptyHandler, null); hasSetSource = true; } } else if (Element.Source is FileVideoSource) { string filename = (Element.Source as FileVideoSource).File; if (!string.IsNullOrWhiteSpace(filename)) { DataSpec dataSpec = new DataSpec(Android.Net.Uri.FromFile(new Java.IO.File(filename))); FileDataSource fileDataSource = new FileDataSource(); try { fileDataSource.Open(dataSpec); } catch (FileDataSource.FileDataSourceException e) { e.PrintStackTrace(); } // videoView.SetVideoPath(filename); IDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this.Context, "CloudMusic"); videoSource = new ExtractorMediaSource(fileDataSource.Uri, dataSourceFactory, new DefaultExtractorsFactory(), emptyHandler, null); hasSetSource = true; } } else if (Element.Source is ResourceVideoSource) { string package = Context.PackageName; string path = (Element.Source as ResourceVideoSource).Path; if (!string.IsNullOrWhiteSpace(path)) { string filename = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); string uri = "android.resource://" + package + "/raw/" + filename; //videoView.SetVideoURI(Android.Net.Uri.Parse(uri)); videoSource = new SsMediaSource(Android.Net.Uri.Parse(uri), httpDataSourceFactory, ssChunkFactory, emptyHandler, null); hasSetSource = true; } } if (videoSource != null) { ExoPlayer.Prepare(videoSource); } if (hasSetSource && Element.AutoPlay) { ExoPlayer.PlayWhenReady = true; // videoView.Start(); } }
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 Action <RTCIceCandidate> sendLocalCandidate = null; // new Function, private void _createPeerConnection() { if (this.pc != null) { throw new Exception("the peer connection is already initialized"); } Messenger.Broadcast(SympleLog.LogDebug, "symple:webrtc: create peer connection: " + this.rtcConfig); this.pc = new RTCPeerConnection(this.rtcConfig); Messenger.Broadcast(SympleLog.LogDebug, "symple:webrtc: created this.pc"); pc.OnIceCandidate += (RTCPeerConnectionIceEvent iceEvent) => { if (iceEvent.Candidate != null) { Messenger.Broadcast(SympleLog.LogDebug, "symple:webrtc: candidate gathered: " + iceEvent.Candidate); if (sendLocalCandidate != null) { this.sendLocalCandidate(iceEvent.Candidate); } } else { Messenger.Broadcast(SympleLog.LogInfo, "symple:webrtc: candidate gathering complete"); } }; pc.OnAddStream += (MediaStreamEvent mediaStreamEvent) => { //string objectURL = createObjectURL(mediaStreamEvent.Stream); Messenger.Broadcast(SympleLog.LogInfo, "symple:webrtc: remote stream added"); // Set the state to playing once candidates have completed gathering. // This is the best we can do until ICE onstatechange is implemented. this.setState("playing"); // ====== here we would play the video element ====== Messenger.Broadcast(SympleLog.LogDebug, "symple:webrtc: remote stream added, should play it now (TODO)"); MediaVideoTrack peerVideoTrack = mediaStreamEvent.Stream.GetVideoTracks().FirstOrDefault(); if (peerVideoTrack != null) { IMediaSource mediaSource = GetMedia().CreateMediaSource(peerVideoTrack, RemotePeerVideoTrackId); Messenger.Broadcast(SympleLog.LogInfo, "Created video source for remote peer video"); Messenger.Broadcast(SympleLog.CreatedMediaSource, mediaSource); } else { Messenger.Broadcast(SympleLog.LogError, "ERROR: Received remote media stream, but there was no video track"); } // store the active stream this.activeStream = mediaStreamEvent.Stream; }; pc.OnRemoveStream += (MediaStreamEvent mediaStreamEvent) => { Messenger.Broadcast(SympleLog.LogInfo, "symple:webrtc: remote stream removed: " + mediaStreamEvent); //this.video.stop(); //this.video.src = ""; }; // NOTE: The following state events are still very unreliable. // Hopefully when the spec is complete this will change, but until then // we need to 'guess' the state. // this.pc.onconnecting = function(event) { Symple.log('symple:webrtc: onconnecting:', event); }; // this.pc.onopen = function(event) { Symple.log('symple:webrtc: onopen:', event); }; // this.pc.onicechange = function(event) { Symple.log('symple:webrtc: onicechange :', event); }; // this.pc.onstatechange = function(event) { Symple.log('symple:webrtc: onstatechange :', event); }; }
/// <inheritdoc /> public void Update(IMediaSource mediaSource) { }
public static PlaybillItemEntity ToEntity(PlaybillEntity billEntity, IPlaybillItem billItem, IMediaSource replaceAutoPadding) { var dtoItem = new PlaybillItemEntity(); dtoItem.Id = billItem.Id; dtoItem.Playbill = billEntity; dtoItem.StartTime = billItem.StartTime; dtoItem.MarkerIn = billItem.PlayRange.StartPosition.TotalSeconds; dtoItem.ScheduleMode = billItem.ScheduleMode; dtoItem.MarkerDuration = billItem.PlayRange.Duration.TotalSeconds; //_dtoItem.SegmentId = this.SegmentId; if (billItem.MediaSource.Category != MediaSourceCategory.Null) { dtoItem.MediaSourceId = billItem.MediaSource.Id; } else { dtoItem.MediaSourceTitle = billItem.MediaSource.Title; dtoItem.MediaSourceDuration = billItem.MediaSource.Duration.Value.TotalSeconds; } var autoBillItem = billItem as AutoPlaybillItem; if (autoBillItem != null) { if (autoBillItem.IsAutoPadding && replaceAutoPadding != null) { // TODO: 替换自动垫片。 dtoItem.MediaSourceId = replaceAutoPadding.Id; //dtoItem.IsAutoPadding = autoBillItem.IsAutoPadding; } } var fileMediaSource = billItem.MediaSource as IFileMediaSource; if (fileMediaSource != null) { dtoItem.AudioGain = fileMediaSource.AudioGain; } if (billItem.CGItems != null) { dtoItem.CGContents = CGItemCollection.ToXml(billItem.CGItems); } return(dtoItem); }
public MediaSourceDecorator(IMediaSource source) { this.mediaSource = source; OnVideoData = this.mediaSource.OnVideoData; OnAudioData = this.mediaSource.OnAudioData; }
public static PlayItemEntity ToEntity(this IPlayItem playItem, PlaybillEntity billEntity, IMediaSource replaceAutoPadding) { var dtoItem = new PlayItemEntity(); dtoItem.Id = playItem.Id; dtoItem.StartTime = playItem.StartTime; dtoItem.PlayDuration = playItem.CalculatedPlayDuration.TotalSeconds; dtoItem.MarkerIn = playItem.PlayRange.StartPosition.TotalSeconds; dtoItem.MarkerDuration = playItem.PlayRange.Duration.TotalSeconds; dtoItem.PlaybillItem = ToEntity(billEntity, playItem.PlaybillItem, replaceAutoPadding); //.ToEntity(); return(dtoItem); }