本文整理汇总了C#中Windows.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Windows.Stop方法的具体用法?C# Windows.Stop怎么用?C# Windows.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows
的用法示例。
在下文中一共展示了Windows.Stop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayStation
public async void PlayStation(Station s, Windows.UI.Xaml.Controls.MediaElement me, bool navigate = true)
{
if (s == null) return;
if (!NetworkCostController.IsConnectedToInternet) //makes sure Hanasu is connected to the internet.
{
Crystal.Services.ServiceManager.Resolve<Crystal.Services.IMessageBoxService>()
.ShowMessage(
LocalizationManager.GetLocalizedValue("InternetConnectionHeader"),
LocalizationManager.GetLocalizedValue("NoInternetConnectionMsg"));
return;
}
if (NetworkCostController.CurrentNetworkingBehavior == NetworkingBehavior.Opt_In) //if the user is roaming and/or over the data limit, notify them
{
Crystal.Services.ServiceManager.Resolve<Crystal.Services.IMessageBoxService>()
.ShowMessage(
LocalizationManager.GetLocalizedValue("DataConstraintsHeader"),
LocalizationManager.GetLocalizedValue("StreamingDisabled2Msg"));
return;
}
// Reset things things are ready to be played.
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
{
SetMediaElement(ref me);
CurrentStation = s;
CurrentStationSongData = null;
CurrentStationStreamedUri = null;
});
StorageFile albumFile = await GetStationAlbumFromCache(); //Grab the current station's logo from the cache.
if (albumFile != null)
MediaControl.AlbumArt = new Uri("ms-appdata:///local/Hanasu/" + albumFile.DisplayName); //Set the logo in the media control.
MediaControl.ArtistName = CurrentStation.Title; //set the station's name
MediaControl.IsPlaying = true;
try
{
if (me.CurrentState == MediaElementState.Playing || me.CurrentState == MediaElementState.Opening || me.CurrentState == MediaElementState.Buffering)
{
me.Pause();
await Task.Delay(1000);
me.Stop();
}
Uri finalUri = new Uri(s.StreamUrl, UriKind.Absolute);
if (await Hanasu.Core.Preprocessor.PreprocessorService.CheckIfPreprocessingIsNeeded(finalUri, s.PreprocessorFormat))
finalUri = await Hanasu.Core.Preprocessor.PreprocessorService.GetProcessor(finalUri, s.PreprocessorFormat).Process(finalUri);
CurrentStationStreamedUri = finalUri;
//if (CurrentStation.ServerType.ToLower() == "shoutcast")
//{
// var str = await ShoutcastService.GetShoutcastStream(finalUri);
// mediaElement.SetSource(str, str.Content_Type);
// mediaElement.Play();
//}
//else
//{
//finalUri = new Uri(finalUri.ToString() + ";stream.nsv", UriKind.Absolute);
try
{
System.Threading.CancellationTokenSource cts = new System.Threading.CancellationTokenSource();
var openTask = mediaElement.OpenAsync(finalUri, cts.Token);
var timeoutTask = Task.Delay(10000); //Wait for a connection for 10 seconds.
var successful = await Task.WhenAny(openTask, timeoutTask);
if (successful == timeoutTask)
{
//timeout. inform the user and back out.
IsPlaying = false;
Crystal.Services.ServiceManager.Resolve<Crystal.Services.IMessageBoxService>()
.ShowMessage(
LocalizationManager.GetLocalizedValue("StreamingErrorHeader"),
LocalizationManager.GetLocalizedValue("StreamingConnectionTimeoutMsg"));
cts.Cancel();
cts.Dispose();
ResetStationInfo();
return;
}
}
catch (Exception ex)
{
if (ex is TaskCanceledException) return;
//.........这里部分代码省略.........