Beispiel #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new FileOpenPicker();

            dlg.FileTypeFilter.Add(".ape");
            dlg.FileTypeFilter.Add(".flac");
            dlg.FileTypeFilter.Add(".ogg");
            dlg.FileTypeFilter.Add(".m4a");
            dlg.FileTypeFilter.Add(".aac");
            dlg.FileTypeFilter.Add(".alac");
            dlg.FileTypeFilter.Add(".dff");
            dlg.FileTypeFilter.Add(".dsf");
            dlg.FileTypeFilter.Add(".tak");
            var file = await dlg.PickSingleFileAsync();

            if (file != null)
            {
                me.SetPlaybackSource(MediaSource.CreateFromStorageFile(file));
                var metadataProvider = await MediaMetadataProvider.CreateFromStream(await file.OpenReadAsync(), file.Path, false);

                metadataProvider.Album.ToString();
            }
        }
Beispiel #2
0
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //playerClient = new BackgroundMediaPlayerClient(typeof(BackgroundMediaPlayerHandler));
            //playerClient.MessageReceived += PlayerClient_MessageReceived;

            //foreach (var fileName in fileNames)
            //{
            //    var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fileNames[2]));
            //    var stream = await file.OpenReadAsync();
            //    var metadataProvider = await MediaMetadataProvider.CreateFromStream(stream, false);
            //    var pics = metadataProvider.Pictures;
            //}
            var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fileNames[0]));

            var stream = await file.OpenReadAsync();

            var metadataProvider = await MediaMetadataProvider.CreateFromStream(stream, false);

            var pics = metadataProvider.Pictures;

            if (pics.Any())
            {
                var image = new BitmapImage();
                await image.SetSourceAsync((new MemoryStream(pics[0].Data)).AsRandomAccessStream());

                img_Video.Source = image;
            }
            var str = metadataProvider.Lyrics.ToString();

            var mediaSource = await MediaSource.CreateFromStream(stream, file.Path);

            streamSource = new EffectMediaStreamSource(mediaSource);
            var equalizer = new EqualizerEffectTransform();

            equalizer.AddOrUpdateFilter(31, 18, 2.0f);
            equalizer.AddOrUpdateFilter(62, 18, 2.0f);
            equalizer.AddOrUpdateFilter(125, 18, 2.0f);
            equalizer.AddOrUpdateFilter(250, 18, 2.0f);
            equalizer.AddOrUpdateFilter(500, 18, 2.0f);
            equalizer.AddOrUpdateFilter(1000, 18, 2.0f);
            equalizer.AddOrUpdateFilter(2000, 18, 2.0f);
            equalizer.AddOrUpdateFilter(4000, 18, 2.0f);
            equalizer.AddOrUpdateFilter(8000, 18, 2.0f);
            equalizer.AddOrUpdateFilter(16000, 18, 2.0f);
            streamSource.AddTransform(equalizer);
            Media.SetMediaStreamSource(streamSource.Source);
            //GC.Collect();
            //GC.WaitForPendingFinalizers();
            //GC.Collect();
            //Debug.WriteLine($"Before: {GC.GetTotalMemory(true)} Bytes.");
            //for (int i = 0; i < 200; i++)
            //{
            //    foreach (var fileName in fileNames)
            //    {
            //        var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fileName));
            //        var stream = await file.OpenReadAsync();
            //        var mediaSource = await MediaSource.CreateFromStream(stream, fileName);
            //        Debug.WriteLine($"Title: {mediaSource.Title}");
            //        Debug.WriteLine($"Album: {mediaSource.Album}");
            //        Debug.WriteLine($"Artist: {mediaSource.Artist}");
            //        Debug.WriteLine($"AlbumArtist: {mediaSource.AlbumArtist}");
            //        Debug.WriteLine($"Duration: {mediaSource.Duration}");
            //        Debug.WriteLine($"Lyrics: {mediaSource.Lyrics}");
            //    }
            //}
            //GC.Collect();
            //GC.WaitForPendingFinalizers();
            //GC.Collect();
            //Debug.WriteLine($"After: {GC.GetTotalMemory(true)} Bytes.");

            //var meta = await MediaMetadataProvider.CreateFromStream(stream, false);
            //Debug.WriteLine($"Title: {meta.Title}");
            //Debug.WriteLine($"Album: {meta.Album}");
            //Debug.WriteLine($"Artist: {meta.Artist}");
            //Debug.WriteLine($"AlbumArtist: {meta.AlbumArtist}");
            //Debug.WriteLine($"Duration: {meta.Duration}");
            //Debug.WriteLine($"Lyrics: {meta.Lyrics}");
            //var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fileName));
            //var stream = await file.OpenReadAsync();
            //var mediaSource = await MediaSource.CreateFromStream(stream, fileName);
            //videoPresenter = new VideoPresenter();
            //videoPresenter.SetMediaSource(mediaSource);
            //img_Video.Source = videoPresenter.ImageSource;

            //videoPresenter.Play();
        }