コード例 #1
0
        //播放特定位置的音频
        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);
        }
コード例 #2
0
        //播放当前音频
        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;
        }
コード例 #3
0
        //播放下一音频
        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;
        }