本文整理汇总了C#中MediaPlayer.Play方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Play方法的具体用法?C# MediaPlayer.Play怎么用?C# MediaPlayer.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Play方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTests
public static void RunTests() {
var player = new MediaPlayer();
player.Play();
player.Pause();
player.Stop();
player.AllSongs.TrackNames.PrintCollection();
}
示例2: MediaPlayer_MediaOpened
/// <summary>
/// Fired when MediaPlayer is ready to play the track
/// </summary>
void MediaPlayer_MediaOpened(MediaPlayer sender, object args)
{
// wait for media to be ready
sender.Play();
Debug.WriteLine("New Track" + this.CurrentTrackName);
TrackChanged.Invoke(this, CurrentTrackName);
}
示例3: Scenario8_Loaded
private void Scenario8_Loaded(object sender, RoutedEventArgs e)
{
mediaPlayer = new MediaPlayer();
mediaPlayer.Source = MediaSource.CreateFromUri(rootPage.CaptionedMediaUri);
mediaPlayer.Play();
// Bind to the element in the Loaded event after the layout
// pass has run and sized elements
BindMediaPlayerToUIElement(mediaPlayer, mediaPlayerButton);
}
示例4: HandleMediaPlayerMediaOpened
void HandleMediaPlayerMediaOpened(MediaPlayer sender, object args)
{
if (isFirstOpen)
{
isFirstOpen = false;
double percentage = ApplicationSettings.GetSettingsValue<double>(ApplicationSettings.CURRENT_TRACK_PERCENTAGE, 0.0);
ApplicationSettings.PutSettingsValue(ApplicationSettings.CURRENT_TRACK_PERCENTAGE, 0.0);
if (percentage > 0)
{
Logger.Current.Init(LogType.PlayAction);
Logger.Current.Log(new CallerInfo(), LogLevel.Info, "Length Total {0}", mediaPlayer.NaturalDuration.Ticks);
mediaPlayer.Position = TimeSpan.FromTicks((long)(mediaPlayer.NaturalDuration.Ticks * percentage));
}
}
int trackId = ApplicationSettings.GetSettingsValue<int>(ApplicationSettings.CURRENT_PLAYQUEUE_POSITION, 0);
Logger.Current.Init(LogType.PlayAction);
Logger.Current.Log(new CallerInfo(), LogLevel.Info, "Trying to play row {0}", trackId);
playingTrack = TrackInfo.TrackInfoFromRowId(trackId);
TrackChanged.Invoke(this, playingTrack);
if (playAfterOpen)
{
sender.Play();
}
else
{
playAfterOpen = true;
}
}
示例5: MediaPlayer_MediaOpened
/// <summary>
/// Fired when MediaPlayer is ready to play the track
/// </summary>
void MediaPlayer_MediaOpened(MediaPlayer sender, object args)
{
// wait for media to be ready
sender.Play();
TrackChanged.Invoke(this, null);
}
示例6: MediaPlayer_MediaOpened
private void MediaPlayer_MediaOpened(MediaPlayer sender, object args)
{
logger.LogMessage("BackgroundAudio: File opened - start playing.");
sender.Volume = 0; // Will be set to 1 in MediaPlayer_CurrentStateChanged handler
sender.Play();
smtc.PlaybackStatus = MediaPlaybackStatus.Playing;
smtc.DisplayUpdater.Type = MediaPlaybackType.Music;
smtc.DisplayUpdater.MusicProperties.Title = playlist.CurrentTrack?.Name ?? string.Empty;
smtc.DisplayUpdater.MusicProperties.Artist = playlist.CurrentTrack?.Artist ?? string.Empty;
smtc.DisplayUpdater.MusicProperties.AlbumArtist = playlist.CurrentTrack?.AlbumArtist ?? string.Empty;
smtc.DisplayUpdater.Update();
}
示例7: MediaPlayerOnMediaOpened
void MediaPlayerOnMediaOpened(MediaPlayer sender, object args)
{
Debug.WriteLine("MediaPlayerManager.MediaPlayerOnMediaOpened()");
if (_position.HasValue)
{
if (sender.CanSeek)
sender.Position = _position.Value;
_position = null;
}
sender.Play();
if (null == _closePlaybackCompleted)
FireTrackChanged();
}
示例8: _mediaPlayer_MediaOpened
void _mediaPlayer_MediaOpened(MediaPlayer sender, object args)
{
sender.Play();
TrackChanged?.Invoke(this, CurrentTrack);
}
示例9: Main
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Lazy Instantiation *****\n");
// No allocation of AllTracks object here!
MediaPlayer myPlayer = new MediaPlayer();
myPlayer.Play();
// Allocation of AllTracks happens when you call GetAllTracks().
MediaPlayer yourPlayer = new MediaPlayer();
AllTracks yourMusic = yourPlayer.GetAllTracks();
Console.ReadLine();
}
示例10: MediaPlayer_MediaOpened
/// <summary>
/// Fired when MediaPlayer is ready to play the track
/// </summary>
private void MediaPlayer_MediaOpened(MediaPlayer sender, object args)
{
_retryCount = 0;
// wait for media to be ready
sender.Play();
if (CurrentTrack == null) return;
if (TrackChanged != null)
OnTrackChanged(CurrentTrack.SongId);
OnTrackChanged();
}
示例11: Run
public void Run()
{
this.Children.Add(loading = new Loading() { Z = 999999 });
loading.Show();
this.Width = Application.Current.Host.Content.ActualWidth;
this.Height = Application.Current.Host.Content.ActualHeight;
this.Children.Add(music = new MediaPlayer() { Loop = true, Uri = "Login" }); music.Play();
this.Children.Add(head = new EntityObject() { Source = GlobalMethod.GetImage("UI/LoginBack.jpg", UriType.Project), Stretch = Stretch.Fill, IsVisible = false, Z = 6, });
this.Children.Add(backgroundFirst = new LoginBackground());
this.Children.Add(backgroundSecond = new LoginBackground());
this.Children.Add(foot = new EntityObject() { Source = GlobalMethod.GetImage("UI/LoginBack.jpg", UriType.Project), Stretch = Stretch.Fill, IsVisible = false, Z = 6, });
LoginBackground.Interval = 110000;
backgroundFirst.Run(BackgourndIndex.First, 0, -(Application.Current.IsRunningOutOfBrowser ? 2172 : backgroundFirst.RealWidth));
backgroundSecond.Run(BackgourndIndex.Second, backgroundSecond.RealWidth - 1, -(Application.Current.IsRunningOutOfBrowser ? 2172 : backgroundFirst.RealWidth));
//下载动画信息包
ParallelDownloader downloader = new ParallelDownloader();
downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(animationInfo_OpenReadCompleted);
downloader.OpenReadAsync(GlobalMethod.WebPath("Animation/Info.xml"), DownloadPriority.Highest, null, false, 0);
}