示例#1
0
        private void Play_On_Net_Button_Click(object sender, RoutedEventArgs e)
        {
            MyMediaPlayer.Source = MediaSource.CreateFromUri(new Uri("http://www.neu.edu.cn/indexsource/neusong.mp3"));

            MyMedia.SetMediaPlayer(MyMediaPlayer);
            MyMediaPlayer.Play();
        }
示例#2
0
        private async void loadButton_Click(object sender, RoutedEventArgs e)
        {
            StorageFile LoadFile = await Load();

            if (LoadFile != null)
            {
                var mediaSource = MediaSource.CreateFromStorageFile(LoadFile);
                MyMediaPlayer.Source = mediaSource;
                MyMedia.SetMediaPlayer(MyMediaPlayer);
                MyMediaPlayer.Play();
            }
        }
示例#3
0
        private async void OpenFileButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            picker.FileTypeFilter.Add(".mp3");
            picker.FileTypeFilter.Add(".mp4");

            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                // Application now has read/write access to the picked file
                var mediaSource = MediaSource.CreateFromStorageFile(file);
                MyMediaPlayer.Source = mediaSource;
                MyMedia.SetMediaPlayer(MyMediaPlayer);
                MyMediaPlayer.Play();
            }
        }