【问题标题】:How to create an audio Playlist in C# , Windows 8 App如何在 C#、Windows 8 应用程序中创建音频播放列表
【发布时间】:2014-09-13 03:41:51
【问题描述】:
private async void Set_Up_Media_Player()
{
    var Location = Package.Current.InstalledLocation;
    var Folder = await Location.GetFolderAsync("Music");
    this._Start = await Folder.GetFileAsync("start.wav");
    this._Loop = await Folder.GetFileAsync("loop.wav");
    this._Stream = await _Start.OpenAsync(FileAccessMode.Read);

    _Music = new MediaElement() { AutoPlay = true, IsLooping = false };
    _Music.SetSource(_Stream, _Start.ContentType);
    _Music.MediaEnded += Music_MediaEnded;

    this._Stream = await _Loop.OpenAsync(FileAccessMode.Read);
}

void Music_MediaEnded(object sender, RoutedEventArgs e)
{
    Music.SetSource(this._Stream, this._Loop.ContentType);
    Music.IsLooping = true;
}

我正在尝试获取 MediaElement _Music 首先播放 _Start 歌曲,然后过渡到第二首 _Loop 歌曲。我尝试添加一个事件处理程序Music_MediaEnded,但_Start 歌曲结束并且该事件永远不会被调用。

如何创建播放列表,以便 MediaElement 自动过渡到下一首歌曲?

【问题讨论】:

  • _Music 和 _Start 是如何工作的?

标签: c# xaml windows-8.1 mediaelement playlist


【解决方案1】:

当媒体在处理程序中结束时,将 MediaElement 的 AutoPlay 属性设置为 true。 即,在设置新的源写入后

Music.AutoPlay=true;

【讨论】:

  • 所以在Music_MediaEnded(...)之后SetSource(..)我会设置Musice.AutoPlay = true;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-10
  • 1970-01-01
  • 2010-12-19
  • 1970-01-01
  • 2012-10-11
  • 1970-01-01
相关资源
最近更新 更多