private async Task LoadFile(StorageFile file)
        {
            if (isCanceled)
            {
                return;
            }

            if (Utilities.IsSupportedFileType(file.FileType))
            {
                StorageItemContentProperties fileProperties = file.Properties;

                MusicProperties musicProperties = await fileProperties.GetMusicPropertiesAsync();

                IDictionary <string, object> artistProperties = await fileProperties.RetrievePropertiesAsync(RealMusicProperties);

                object artists = null;
                artistProperties.TryGetValue("System.Music.Artist", out artists);

                string[] artistsAsArray = DebugHelper.CastAndAssert <string[]>(artists);

                string artistName = string.Empty;

                if (artistsAsArray != null && artistsAsArray.Length > 0)
                {
                    artistName = artistsAsArray[0];
                }

                if (this.TrackScanned != null)
                {
                    this.TrackScanned(this, new TrackScannedEventArgs(new StorageProviderSong(file.Path, musicProperties, artistName)));
                }
            }
        }
예제 #2
0
        private async Task <Dictionary <string, string> > GetProperties(StorageFile temporaryFile, CancellationToken cancellationToken)
        {
            StorageItemContentProperties properties = temporaryFile.Properties;
            MusicProperties musicProperties         = await properties.GetMusicPropertiesAsync();

            VideoProperties videoProperties = await properties.GetVideoPropertiesAsync();

            BasicProperties basicProperties = await temporaryFile.GetBasicPropertiesAsync();

            CancelTask(cancellationToken);

            Dictionary <string, string> tempDictionary = new Dictionary <string, string>();

            tempDictionary["Display Name"]        = temporaryFile.DisplayName;
            tempDictionary["File Type"]           = temporaryFile.FileType;
            tempDictionary["Current Folder Path"] = temporaryFile.FolderRelativeId;
            tempDictionary["Size"]           = string.Format("{0:0.00}", (Convert.ToDouble(basicProperties.Size) / 1048576d)) + " Mb";
            tempDictionary["Creation Date"]  = temporaryFile.DateCreated.ToString();
            tempDictionary["Modified Date"]  = basicProperties.DateModified.ToString();
            tempDictionary["Audio Bit Rate"] = musicProperties.Bitrate + " bps";
            tempDictionary["Length"]         = videoProperties.Duration.ToString("hh\\:mm\\:ss");
            tempDictionary["Frame Width"]    = videoProperties.Width + "";
            tempDictionary["Frame Height"]   = videoProperties.Height + "";
            tempDictionary["Orientation"]    = videoProperties.Orientation + "";
            tempDictionary["Total Bit Rate"] = videoProperties.Bitrate + " bps";

            CancelTask(cancellationToken);

            return(tempDictionary);
        }
예제 #3
0
        private async void Rename(Tag mytag)
        {
            CurrentSong = SongList.SelectedItem as Song;

            using (SQLiteConnection db = new SQLiteConnection(App.DB_PATH))
            {
                string import_name;
                var    temp_format_id = db.Find <MusicFormat>(c => c.Id == CurrentSong.FormatId);
                import_name = CurrentSong.Path + CurrentSong.NameSong + "." + temp_format_id.NameFormat;

                Main_folder = await Windows.Storage.AccessCache.StorageApplicationPermissions
                              .FutureAccessList.GetFolderAsync("Audio");

                StorageFile music_files = await Main_folder.GetFileAsync(import_name);

                var fileProperties = await music_files.Properties.GetMusicPropertiesAsync();

                //*Нормально не изменяет артиста
                StorageItemContentProperties rfileProperties = music_files.Properties;
                MusicProperties musicFileProperties          = await rfileProperties.GetMusicPropertiesAsync();

                string[] contributingArtistsKey = { "System.Music.Artist" };
                IDictionary <string, object> contributingArtistsProperty =
                    await musicFileProperties.RetrievePropertiesAsync(contributingArtistsKey);

                string[] contributingArtists = contributingArtistsProperty["System.Music.Artist"] as string[];

                //fileProperties.Genre = mytag.Genge; \\только для чтения
                fileProperties.TrackNumber = Convert.ToUInt32(mytag.TrackNumber);
                fileProperties.Album       = mytag.Albom;
                fileProperties.Artist      = mytag.Artist;
                //fileProperties.Composers = mytag.Composer; \\только для чтения
                fileProperties.Title       = mytag.NameSong;
                fileProperties.Year        = Convert.ToUInt32(mytag.Year);
                fileProperties.AlbumArtist = mytag.ArtistAlbom;
                //*Ошибка доступа для Флер
                await fileProperties.SavePropertiesAsync();

                var temp_song = db.Find <Song>(c => c.TagId == mytag.Id);
                await Task.Run(() =>
                {
                    temp_song.DateChange = DateTime.Now.AddHours(5);
                    Db_Helper.Update_Song(temp_song);
                });
            }
            var dialog = new MessageDialog("Тег изменен");
            await dialog.ShowAsync();
        }
예제 #4
0
        // 通过 StorageFolder.Properties 的 GetImagePropertiesAsync(), GetVideoPropertiesAsync(), GetMusicPropertiesAsync(), GetDocumentPropertiesAsync() 方法获取文件的属性
        private async Task ShowProperties4(StorageFile storageFile)
        {
            StorageItemContentProperties storageItemContentProperties = storageFile.Properties;
            ImageProperties imageProperties = await storageItemContentProperties.GetImagePropertiesAsync();          // 图片属性

            VideoProperties videoProperties = await storageItemContentProperties.GetVideoPropertiesAsync();          // 视频属性

            MusicProperties musicProperties = await storageItemContentProperties.GetMusicPropertiesAsync();          // 音频属性

            DocumentProperties documentProperties = await storageItemContentProperties.GetDocumentPropertiesAsync(); // 文档属性

            lblMsg.Text += "image width:" + imageProperties.Width;
            lblMsg.Text += Environment.NewLine;
            lblMsg.Text += "image height:" + imageProperties.Height;
            lblMsg.Text += Environment.NewLine;
        }