public void EnsureMediaExtensionManager() { if (mediaExtensionMgr == null) { mediaExtensionMgr = new Windows.Media.MediaExtensionManager(); mediaExtensionMgr.RegisterSchemeHandler("Microsoft.Samples.SimpleCommunication.StspSchemeHandler", "stsp:"); } }
void RegisterPlugins() { if (MediaManager == null) { MediaManager = new Windows.Media.MediaExtensionManager(); } if (AdaptiveSrcManager == null) { AdaptiveSrcManager = AdaptiveSourceManager.GetDefault(); } PropertySet ssps = new PropertySet(); ssps["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = AdaptiveSrcManager; MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", ssps); MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", ssps); MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "text/xml", ssps); MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "application/vnd.ms-sstr+xml", ssps); MediaManager.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", ssps); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { mediaExtensionMgr = new Windows.Media.MediaExtensionManager(); mediaExtensionMgr.RegisterSchemeHandler("Microsoft.Samples.SimpleCommunication.StspSchemeHandler", "stsp:"); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } ListenerManager.Instance.Start(); }
/// <summary> /// Method: Initialize /// Initialize the cache /// Parameter: container is a string defining the folder name where the cache will be stored on disk under folder /// \Users\<UserName>\AppData\Local\Packages\<PackageID>\LocalState /// Parameter: bDownloadToGo if true DownloadToGo scenario (offline playback), if false ProgressiveDownload scenario /// Parameter: maxDownloadSession maximum number of simultaneous download sessions /// Parameter: maxDownloadSession maximum number of simultaneous download sessions /// Parameter: maxMemoryBufferSizePerSession maximum buffer size per session, when the size if over this value, the chunks will be saved on disk and freed from memory. /// Parameter: maxDownloadedAssets maximum number of asset on disk /// Parameter: maxError maximum number of http error while downloading the chunks associated with an asset. When this value is reached the download thread will be cancelled /// Parameter: bAutoStartDownload if true after a resume the cache will start automatically the download /// </summary> public IAsyncOperation<bool> Initialize(string container, uint maxDownloadSession, ulong maxMemoryBufferSizePerSession, uint maxDownloadedAssets, uint maxError, bool bAutoStartDownload) { return Task.Run<bool>(async () => { if (ManifestCacheList != null) Uninitialize(); Container = container; MaxError = maxError; MaxMemoryBufferSizePerSession = maxMemoryBufferSizePerSession; MaxDownloadSessions = maxDownloadSession; MaxDownloadedAssets = maxDownloadedAssets; AutoStartDownload = bAutoStartDownload; // SMOOTH // Init Adaptative Manager AdaptiveSrcManager = AdaptiveSourceManager.GetDefault(); AdaptiveSrcManager.SetDownloaderPlugin(this); AdaptiveSrcManager.AdaptiveSourceOpenedEvent += AdaptiveSrcManager_AdaptiveSourceOpenedEvent; AdaptiveSrcManager.AdaptiveSourceClosedEvent += AdaptiveSrcManager_AdaptiveSourceClosedEvent; // SMOOTH // Init SMOOTH Manager SmoothStreamingManager = Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager.GetDefault() as Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager; Extension = new Windows.Media.MediaExtensionManager(); if ((SmoothStreamingManager != null) && (Extension != null)) { Windows.Foundation.Collections.PropertySet ssps = new Windows.Foundation.Collections.PropertySet(); ssps["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = SmoothStreamingManager; Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", ssps); Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", ssps); Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "text/xml", ssps); Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "application/vnd.ms-sstr+xml", ssps); Extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", ssps); Extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstrs:", ssps); SmoothStreamingManager.ManifestReadyEvent += SmoothStreamingManager_ManifestReadyEvent; SmoothStreamingManager.SetDownloaderPlugin(this); } if (diskCache == null) { diskCache = new DiskCache(); if (diskCache != null) { bool bResult = false; bResult = await diskCache.Initialize(Container); if (bResult != true) { System.Diagnostics.Debug.WriteLine("Can't initialize DiskCache"); return false; } } } if (ManifestCacheList == null) ManifestCacheList = new ConcurrentDictionary<Uri, ManifestCache>(); if (ManifestCacheList != null) IsInitialized = true; return IsInitialized; }).AsAsyncOperation<bool>(); }
/// <summary> /// This method Register the Smooth Streaming component . /// </summary> public bool RegisterSmoothStreaming() { bool bResult = false; // Smooth Streaming initialization // Init SMOOTH Manager if(smoothStreamingManager != null) { smoothStreamingManager.ManifestReadyEvent -= SmoothStreamingManager_ManifestReadyEvent; smoothStreamingManager.AdaptiveSourceStatusUpdatedEvent -= SmoothStreamingManager_AdaptiveSourceStatusUpdatedEvent; smoothStreamingManager = null; } smoothStreamingManager = Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager.GetDefault() as Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager; extension = new Windows.Media.MediaExtensionManager(); if ((smoothStreamingManager != null) && (extension != null)) { PropertySet ssps = new PropertySet(); ssps["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = smoothStreamingManager; extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", ssps); extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", ssps); extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "text/xml", ssps); extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "application/vnd.ms-sstr+xml", ssps); extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", ssps); extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstrs:", ssps); smoothStreamingManager.ManifestReadyEvent += SmoothStreamingManager_ManifestReadyEvent; smoothStreamingManager.AdaptiveSourceStatusUpdatedEvent += SmoothStreamingManager_AdaptiveSourceStatusUpdatedEvent; bResult = true; } return bResult; }