本文整理汇总了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);
};
}
示例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();
}
示例3: SetSourceAsync
public async Task SetSourceAsync(MediaElement mediaElement, StorageFile file)
{
if (file != null)
{
mediaElement.Stop();
mediaElement.SetPlaybackSource(MediaSource.CreateFromStorageFile(file));
}
}
示例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);
}
}
}
示例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();
}
示例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; });
}
示例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();
});
}
}