//播放特定位置的音频 public async void PlayMedia(int index) { mediaFilePlaying = mediaFileInfos[index]; mediaIndex = index; var stream = await mediaFilePlaying.mediaFile.OpenAsync(Windows.Storage.FileAccessMode.Read); MediaPlayer.SetSource(stream, mediaFilePlaying.mediaFile.ContentType); }
//播放当前音频 public async void PlayMedia() { if (mediaFilePlaying == null) { mediaFilePlaying = mediaFileInfos[0]; mediaIndex = 0; var stream = await mediaFilePlaying.mediaFile.OpenAsync(Windows.Storage.FileAccessMode.Read); MediaPlayer.SetSource(stream, mediaFilePlaying.mediaFile.ContentType); } Title.Text = mediaFilePlaying.name; }
//播放下一音频 public async void NextMediaAsync() { ++mediaIndex; if (mediaIndex >= mediaFileInfos.Count) { ; mediaIndex = 0; } mediaFilePlaying = mediaFileInfos[mediaIndex]; var stream = await mediaFilePlaying.mediaFile.OpenAsync(Windows.Storage.FileAccessMode.Read); MediaPlayer.SetSource(stream, mediaFilePlaying.mediaFile.ContentType); Title.Text = mediaFilePlaying.name; }