当前位置: 首页>>代码示例>>C#>>正文


C# MediaElement.Stop方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Controls.MediaElement.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# MediaElement.Stop方法的具体用法?C# MediaElement.Stop怎么用?C# MediaElement.Stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Controls.MediaElement的用法示例。


在下文中一共展示了MediaElement.Stop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReactiveViewModel

        /// <summary>
        /// A view model class for the ReactiveRequest Scenario.
        /// The ViewModel takes a UI MediaElement in the contructor to wire up commands and events to simplify the sample.
        /// Decoupling the MediaElement from the ViewModel would require addtional MVVM infrastucture.
        /// </summary>
        public ReactiveViewModel(MediaElement mediaElement)
        {

            /// The ProtectionManager provides communication between the player and PlayReady DRM. 
            /// The helper class will configure the protection manager for PlayReady and assign an
            /// event handler for Service requests.
            this.ProtectionManager = PlayReadyHelpers.InitializeProtectionManager(ServiceRequested);
            mediaElement.ProtectionManager = this.ProtectionManager;
            /// The PlayReadyInfoViewModel is used in this sample app to show PlayReadyStatistics such as 
            /// SecurityLevel and hardware support in the UI.
            PlayReadyInfo = new PlayReadyInfoViewModel();
            PlayReadyInfo.RefreshStatics();

            /// Reactive license acqusition will happen automatically when setting the source of 
            /// a MediaElement to protected content. 
            CmdPlayMovie = new RelayCommand( () => { mediaElement.Source = new Uri(moviePath); SetPlaybackEnabled(true); });
            /// The licenseUrl in the sample is set to return a non-peristent license. When there is a 
            /// hard Stop() on the playback, a new license will be requested on Play(). 
            CmdStopMovie = new RelayCommand(() => { mediaElement.Stop(); SetPlaybackEnabled(false); });

            mediaElement.CurrentStateChanged += (s, a) => {
                ViewModelBase.Log("Media State::" + mediaElement.CurrentState);
            };

            mediaElement.MediaFailed += (s, a) => {
                ViewModelBase.Log("Err::" + a.ErrorMessage);
            };
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:33,代码来源:ReactiveViewModel.cs

示例2: ProactiveViewModel

        /// <summary>
        /// A view model class for the IndivReactive Scenario.
        /// </summary>
        public ProactiveViewModel(MediaElement mediaElement)
        {
            /// The ProtectionManager provides communication between the player and PlayReady DRM. 
            /// The helper class will configure the protection manager for PlayReady and assign an
            /// event handler for Service requests.
            this.ProtectionManager = PlayReadyHelpers.InitializeProtectionManager(ServiceRequested);
            mediaElement.ProtectionManager = this.ProtectionManager;
            /// The PlayReadyInfoViewModel is used in this sample app to show PlayReadyStatistics such as 
            /// SecurityLevel and hardware support within the UI.
            PlayReadyInfo = new PlayReadyInfoViewModel();
            PlayReadyInfo.RefreshStatics();            

            mediaElement.CurrentStateChanged += (s, a) => {
                ViewModelBase.Log("Media State::" + mediaElement.CurrentState);
            };

            mediaElement.MediaFailed += (s, a) => {
                ViewModelBase.Log("Media Failed::" + a.ErrorMessage);
            };

            /// Proactive license acqusition will ensure a license is available
            /// prior to playback
            CmdGetLicense = new RelayCommand(() => { GetLicense(new Guid(this.KeyId)); }, () => { return PlayReadyHelpers.IsIndividualized; });

            /// Play is enabled once a license is available
            CmdPlayMovie = new RelayCommand(() => { mediaElement.Source = new Uri(moviePath); SetPlaybackEnabled(true); }, 
                                            () => IsLicenseAvailable(new Guid(KeyId)));
            CmdStopMovie = new RelayCommand(() => { mediaElement.Stop(); SetPlaybackEnabled(false); }, 
                                            () => IsLicenseAvailable(new Guid(KeyId))); 

            /// Proactive individualization will ensure PlayReady have been configured
            /// to begin making license requests
            IndividualizeIfNeeded();
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:37,代码来源:ProactiveViewModel.cs

示例3: SetSourceAsync

 public async Task SetSourceAsync(MediaElement mediaElement, StorageFile file)
 {
     if (file != null)
     {
         mediaElement.Stop();
         mediaElement.SetPlaybackSource(MediaSource.CreateFromStorageFile(file));
     }
 }
开发者ID:AlexZayats,项目名称:N7.MediaPlayer,代码行数:8,代码来源:DefaultSourceProvider.cs

示例4: SetSourceAsync

        public async Task SetSourceAsync(MediaElement mediaElement, StorageFile file)
        {
            if (file != null)
            {
                mediaElement.Stop();

                var readStream = await file.OpenAsync(FileAccessMode.Read);
                var ffmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromStream(readStream, false, false);
                var mss = ffmpegMSS.GetMediaStreamSource();

                if (mss != null)
                {
                    mediaElement.SetMediaStreamSource(mss);
                }
            }
        }
开发者ID:AlexZayats,项目名称:N7.MediaPlayer,代码行数:16,代码来源:FFmpegSourceProvider.cs

示例5: _Speak

        private static async void _Speak(string text)
        {
            MediaElement mediaElement = new MediaElement();
            SpeechSynthesizer synth = new SpeechSynthesizer();


            foreach (VoiceInformation voice in SpeechSynthesizer.AllVoices)
            {
                Debug.WriteLine(voice.DisplayName + ", " + voice.Description);
            }

            // Initialize a new instance of the SpeechSynthesizer. 
            SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(text);

            // Send the stream to the media object. 
            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            mediaElement.Stop();
            synth.Dispose();
        }
开发者ID:tyeth,项目名称:Christmas-List,代码行数:21,代码来源:TextToSpeech.cs

示例6: HardwareDRMViewModel

        /// <summary>
        /// A view model class for the IndivReactive Scenario.
        /// </summary>
        public HardwareDRMViewModel(MediaElement mediaElement)
        {
            this.ProtectionManager = PlayReadyHelpers.InitializeProtectionManager(ServiceRequested);
            mediaElement.ProtectionManager = this.ProtectionManager;
            PlayReadyInfo = new PlayReadyInfoViewModel();
            PlayReadyInfo.RefreshStatics();

            mediaElement.CurrentStateChanged += (s, a) => {
                ViewModelBase.Log("Media State::" + mediaElement.CurrentState);
            };

            mediaElement.MediaFailed += (s, a) => {
                ViewModelBase.Log("Media Failed::" + a.ErrorMessage);
            };

            CmdPlayMovie    = new RelayCommand(() => { mediaElement.Source = new Uri(moviePath); SetPlaybackEnabled(true); },
                                               () => { return modeSelected && PlayReadyHelpers.IsIndividualized; });
            CmdStopMovie    = new RelayCommand(() => { mediaElement.Stop(); SetPlaybackEnabled(false); }); 
            CmdUseHardware  = new RelayCommand(() => { ConfigureHardwareDRM(mediaElement); }, 
                                               () => { return !modeSelected;  });
            CmdUseSoftware  = new RelayCommand(() => { ConfigureSoftwareDRM(mediaElement); }, 
                                               () => { return !modeSelected; });

        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:27,代码来源:HardwareDRMViewModel.cs

示例7: SecureStopViewModel

        /// <summary>
        /// A view model class for the IndivReactive Scenario.
        /// </summary>
        public SecureStopViewModel(MediaElement mediaElement)
        {
            this.ProtectionManager = PlayReadyHelpers.InitializeProtectionManager(ServiceRequested);
            mediaElement.ProtectionManager = this.ProtectionManager;

            licenseSession = PlayReadyHelpers.createLicenseSession();
            licenseSession.ConfigureMediaProtectionManager(mediaElement.ProtectionManager);

            PlayReadyInfo = new PlayReadyInfoViewModel();
            PlayReadyInfo.RefreshStatics();

            CmdPlayMovie = new RelayCommand(
                                    () => { mediaElement.Source = new Uri(moviePath); SetPlaybackEnabled(true); },
                                    () => publisherCert != null);

            CmdStopMovie = new RelayCommand(() => { mediaElement.Stop();}, 
                                            () => publisherCert != null);

            CmdGetPublisherCert = new RelayCommand(() => 
                                            {
                                                GetPublisherCert(publisherID, (cert) =>
                                                {
                                                    CmdPlayMovie.RaiseCanExecuteChanged();
                                                    CmdStopMovie.RaiseCanExecuteChanged();
                                                    CmdRenewLicense.RaiseCanExecuteChanged();
                                                });
                                            });

            CmdRenewLicense = new RelayCommand(() => RenewActiveLicense(), 
                                               () => publisherCert != null);

            mediaElement.CurrentStateChanged += (s, a) =>
            {
                ViewModelBase.Log("Media State::" + mediaElement.CurrentState);

                switch (mediaElement.CurrentState)
                {
                    case MediaElementState.Closed:
                        SendSecureStopRecords();
                        activePlayReadyHeader = null;
                        SetPlaybackEnabled(false);
                        // renewing the licenseSession for subsequent Plays since the 
                        // session is stopped
                        licenseSession = PlayReadyHelpers.createLicenseSession();
                        licenseSession.ConfigureMediaProtectionManager(mediaElement.ProtectionManager);
                        break;
                    default:
                        break;
                }

            };

            mediaElement.MediaFailed += (s, a) =>
            {
                ViewModelBase.Log("Err::" + a.ErrorMessage);
            };

            var localSettings = ApplicationData.Current.LocalSettings;
            ApplicationDataContainer container;
            localSettings.Containers.TryGetValue("PublisherCerts", out container);
            if (container != null && container.Values.ContainsKey(publisherID))
            {
                publisherCert = (byte[])container.Values[publisherID];
            }

            try
            {
                var securityVersion = PlayReadyStatics.PlayReadySecurityVersion;
                SendSecureStopRecords();
            }
            catch {
                PlayReadyHelpers.ProactiveIndividualization(() =>
                {
                    PlayReadyInfo.RefreshStatics();
                });
            }
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:80,代码来源:SecureStopViewModel.cs


注:本文中的Windows.UI.Xaml.Controls.MediaElement.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。