Example #1
0
    private void RefreshFile()//刷新文件列表
    {
        DirectoryInfo direction = new DirectoryInfo(Application.streamingAssetsPath);

        FileInfo[] files = direction.GetFiles("*.mp4", SearchOption.AllDirectories);
        if (null != files && files.Length > 0)
        {
            Func <FileInfo, VideoItem> CreateItem = v =>
            {
                VideoItem itm = new VideoItem();
                itm.name = v.Name;
                itm.path = v.FullName;
                ShellClass sh   = new ShellClass();
                Folder     dir  = sh.NameSpace(v.DirectoryName);
                FolderItem item = dir.ParseName(v.Name);
                itm.description = dir.GetDetailsOf(item, 24);
                return(itm);
            };
            playList = new PlayList {
                items = files.Select(CreateItem).ToList()
            };
        }
        foreach (var item in playList.items)
        {
            Debug.Log(item.name + " : " + item.description);
        }
    }
        /// <summary>
        /// 添加音乐文件信息
        /// </summary>
        /// <param name="files"></param>
        private void AddMusic(string[] files)
        {
            MusicInfo temp;
            //ObservableCollection<MusicInfo> temp_list = new ObservableCollection<MusicInfo>();
            ShellClass shell = new ShellClass();

            //Music_List.Clear();
            foreach (string file in files)
            {
                temp = new MusicInfo();
                Folder     dir  = shell.NameSpace(Path.GetDirectoryName(file));
                FolderItem item = dir.ParseName(Path.GetFileName(file));

                temp.file_name   = dir.GetDetailsOf(item, 0);
                temp.music_title = dir.GetDetailsOf(item, 21);
                temp.album       = dir.GetDetailsOf(item, 14);
                temp.artist      = dir.GetDetailsOf(item, 13);
                temp.length      = dir.GetDetailsOf(item, 27);
                temp.size        = dir.GetDetailsOf(item, 1);
                temp.file_path   = file;

                if (!Music_List.Any(t => t.file_name.Equals(temp.file_name)))
                {
                    Music_List.Add(temp);
                }
                else
                {
                    continue;
                }
                //Music_List.Add(temp);
            }
        }
        public void setRecord(string recordPath, string sender, string senderID, string profileImgPath)
        {
            this.recordPath = recordPath;

            // 获取音频时间
            string     dirName  = System.IO.Path.GetDirectoryName(recordPath);
            FileInfo   fInfo    = new FileInfo(recordPath);
            string     SongName = System.IO.Path.GetFileName(recordPath);
            ShellClass sh       = new ShellClass();
            Folder     dir      = sh.NameSpace(dirName);
            FolderItem item     = dir.ParseName(SongName);

            string time = Regex.Match(dir.GetDetailsOf(item, -1), "\\d:\\d{2}:\\d{2}").Value;

            string[] timeArray = Regex.Split(time, ":");
            int      hour      = int.Parse(timeArray[0]);
            int      min       = int.Parse(timeArray[1]);
            int      sec       = int.Parse(timeArray[2]);

            lbl_time.Text = (hour * 3600 + min * 60 + sec) + "s";

            lbl_sender.Text = sender;
            this.senderID   = senderID;
            pictureBox_profile.Load(profileImgPath);
        }
Example #4
0
        /// <summary>
        /// トラック情報の取得
        /// </summary>
        private void GetTrackInfo()
        {
            // トラック情報の初期化
            TrackTitle  = "";
            TrackArtist = "";
            TrackAlbum  = "";

            // ファイルプロパティ(ID3タグ情報)の取得
            string dir  = System.IO.Directory.GetParent(TrackFilePath).ToString();
            string file = System.IO.Path.GetFileName(TrackFilePath);

            ShellClass shell = new ShellClass();
            Folder     f     = shell.NameSpace(dir);
            FolderItem item  = f.ParseName(file);

            //// ID3情報の格納位置確認 (※出力ウィンドウに表示されます)
            //      for (int i = 0; i < 100; i++)
            //{
            //    string msg = string.Format("[{0}] {1}", i, f.GetDetailsOf(item, i));
            //    System.Diagnostics.Debug.WriteLine(msg);
            //}

            TrackTitle  = f.GetDetailsOf(item, 21);     // タイトル
            TrackArtist = f.GetDetailsOf(item, 13);     // アーティスト
            TrackAlbum  = f.GetDetailsOf(item, 14);     // アルバム
        }
Example #5
0
        public static void PinUnpinTaskBar(string filePath, bool pin)
        {
            if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
            {
                string directory = Path.GetDirectoryName(filePath);
                string filename  = Path.GetFileName(filePath);

                Shell      shell      = new ShellClass();
                Folder     folder     = shell.NameSpace(directory);
                FolderItem folderItem = folder.ParseName(filename);

                FolderItemVerbs verbs = folderItem.Verbs();

                for (int i = 0; i < verbs.Count; i++)
                {
                    FolderItemVerb verb     = verbs.Item(i);
                    string         verbName = verb.Name.Replace(@"&", "");

                    if ((pin && verbName.Equals("pin to taskbar", StringComparison.InvariantCultureIgnoreCase)) ||
                        (!pin && verbName.Equals("unpin from taskbar", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        verb.DoIt();
                        return;
                    }
                }
            }
        }
        private void list_print(string path)//리스트에 그리자
        {
            string[] temp     = new string[4];
            string   filename = null;

            string[]     tempstr = new string[10];
            ListViewItem item;
            ShellClass   shell  = new ShellClass();
            Folder       folder = shell.NameSpace(path);
            FolderItem   mp3file;
            char         spr = '\\';
            int          i   = 0;

            fileArray = Directory.GetFiles(path, "*.mp3");
            foreach (string str in fileArray)
            {
                tempstr = str.Split(spr);
                foreach (string tempname in tempstr)
                {
                    filename = tempname;
                }

                mp3file   = folder.ParseName(filename);
                temp[0]   = folder.GetDetailsOf(mp3file, 0);
                temp[1]   = folder.GetDetailsOf(mp3file, 13);
                temp[2]   = folder.GetDetailsOf(mp3file, 27);
                temp[3]   = folder.GetDetailsOf(mp3file, 28);
                query[i]  = temp[0];
                query[i] += "@" + temp[1] + "@" + temp[2] + "@" + temp[3];
                i++;
                item = new ListViewItem(temp);
                musicList.Items.Add(item);
            }
        }
    public static string GetLength(this FileInfo info)
    {
        var shell  = new ShellClass();
        var folder = shell.NameSpace(info.DirectoryName);
        var item   = folder.ParseName(info.Name);

        return(folder.GetDetailsOf(item, 27));
    }
Example #8
0
        /// <summary>
        /// 获取指定的音乐的时间
        /// </summary>
        /// <param name="fileUrl"></param>
        /// <returns></returns>
        public static string GetMusicTime(string fileUrl)
        {
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(fileUrl));
            FolderItem item = dir.ParseName(Path.GetFileName(fileUrl));
            string     str  = dir.GetDetailsOf(item, 27);

            return(str);
        }
Example #9
0
            static void Tags()
            {
                ShellClass shell = new ShellClass();

                string dir  = @"C:\mp3"; // MP3ファイルのあるディレクトリ
                string file = "";

                Folder     f    = shell.NameSpace(dir);
                FolderItem item = f.ParseName(file);
            }
Example #10
0
        //得到歌曲标题
        //需要 reference shell32,并using Shell32,DLL的属性Embed Interop Type 设为False
        static string getMusicName(string file, int iCol)
        {
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(file));
            FolderItem item = dir.ParseName(Path.GetFileName(file));

            string str = dir.GetDetailsOf(item, iCol);

            return(str);
        }
        //Get the AFG display for the Manage Satellite connections
        public AutoFormGenerator.UserControls.FormControl GetAFGControl(List <Core.Objects.SatelliteConnection> SatelliteConnections)
        {
            //Use the shell class as the base for AFG to display
            //Just AFG stuff it can be ignorged...
            ShellClass ShellClass = new ShellClass
            {
                SatelliteConnections = SatelliteConnections
            };

            return(AFG.BuildFormControl(ShellClass));
        }
Example #12
0
        private static void func1(string[] files)
        {
            ShellClass sh = new ShellClass();

            foreach (string f in files)
            {
                Folder     dir  = sh.NameSpace(Path.GetDirectoryName(f));
                FolderItem item = dir.ParseName(Path.GetFileName(f));
                string     det  = dir.GetDetailsOf(item, 21);
                Console.WriteLine(f + "-------" + det);
                Console.ReadKey();
            }
        }
Example #13
0
        /// <summary>
        /// 获取mp3文件信息
        /// </summary>
        public void GetSongInfo()
        {
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(System.IO.Path.GetDirectoryName(URL));
            FolderItem item = dir.ParseName(System.IO.Path.GetFileName(URL));

            Singer   = dir.GetDetailsOf(item, 13);            //歌手
            SongName = dir.GetDetailsOf(item, 21);            //歌名
            Album    = dir.GetDetailsOf(item, 14);            //专辑
            Time     = dir.GetDetailsOf(item, 27);
            Time     = Time.Substring(Time.IndexOf(":") + 1); //时长
            Size     = dir.GetDetailsOf(item, 1);             //文件大小
        }
Example #14
0
        //プロパティ取得
        private void GetProperty(string path)
        {
            string     dir   = System.IO.Path.GetDirectoryName(path); // ファイルのあるディレクトリ
            string     file  = System.IO.Path.GetFileName(path);      //ファイル名
            ShellClass shell = new ShellClass();
            Folder     f     = shell.NameSpace(dir);
            FolderItem item  = f.ParseName(file);

            infoArray[0] = f.GetDetailsOf(item, 21); //曲名
            infoArray[1] = f.GetDetailsOf(item, 0);  //ファイル名
            infoArray[2] = f.GetDetailsOf(item, 13); //アーティスト
            infoArray[3] = f.GetDetailsOf(item, 14); //アルバム 未使用
        }
Example #15
0
        /// <summary>
        /// 获取比特率
        /// </summary>
        /// <param name="fileUrl"></param>
        /// <returns></returns>
        public static string GetMusicBit(string fileUrl)
        {
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(fileUrl));
            FolderItem item = dir.ParseName(Path.GetFileName(fileUrl));
            string     str  = dir.GetDetailsOf(item, 28);

            if (string.IsNullOrEmpty(str))
            {
                str = "0kbps";
            }
            return(str);
        }
Example #16
0
        static ImageHelper()
        {
            TIFFCodec =
                ImageCodecInfo
                .GetImageEncoders()
                .Where(x => x.MimeType == "image/tiff")
                .First();
            ImgTo8bbpEncoderParams = new EncoderParameters(1);
            var encoder = Encoder.ColorDepth;

            ImgTo8bbpEncoderParams.Param[0] = new EncoderParameter(encoder, 8L);
            ShellObject = new ShellClass();
        }
        /// <summary>
        /// 获取照片拍摄时间
        /// </summary>
        /// <param name="imagePath">文件路径</param>
        /// <returns></returns>
        public static string GetPhotoData(string imagePath)
        {
            var shell = new ShellClass();
            var dir   = shell.NameSpace(Path.GetDirectoryName(imagePath));
            var item  = dir.ParseName(Path.GetFileName(imagePath));

            if (dir.GetDetailsOf(item, 12) != "")
            {
                return(DateFormat(dir.GetDetailsOf(item, 12)));                                 // 12 为照片拍摄时间
            }
            else
            {
                return("");
            }
        }
Example #18
0
        private int GetMusicTime(string songPath)
        {
            if (!File.Exists(songPath))
            {
                return(0);
            }
            string     dirName  = System.IO.Path.GetDirectoryName(songPath);
            string     SongName = System.IO.Path.GetFileName(songPath);
            ShellClass sh       = new ShellClass();
            Folder     dir      = sh.NameSpace(dirName);
            FolderItem item     = dir.ParseName(SongName);
            string     s        = System.Text.RegularExpressions.Regex.Match(dir.GetDetailsOf(item, -1), "\\d:\\d{2}:\\d{2}").Value;

            string[] num = s.Split(':');
            return(Convert.ToInt32(num[0]) * 3600 + Convert.ToInt32(num[1]) * 60 + Convert.ToInt32(num[2]));
        }
Example #19
0
        public string GetShortcutTargetFile(string shortcutFilename)
        {
            string pathOnly     = Path.GetDirectoryName(shortcutFilename);
            string filenameOnly = Path.GetFileName(shortcutFilename);
            Shell  shell        = new ShellClass();

            Shell32.Folder folder     = shell.NameSpace(pathOnly);
            FolderItem     folderItem = folder.ParseName(filenameOnly);

            if (folderItem != null)
            {
                ShellLinkObject link = (ShellLinkObject)folderItem.GetLink;
                return(link.Path);
            }
            return(String.Empty);
        }
Example #20
0
        /// <summary>
        /// 获取系统背景音乐列表 mp3path.
        /// </summary>
        /// <param name="mp3path">The mp3path.</param>
        /// <returns></returns>
        public string getmp3info(string mp3path)
        {
            string     strMp3           = mp3path;
            string     mp3InfoInterHtml = "{";
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(Server.MapPath(strMp3)));
            FolderItem item = dir.ParseName(Path.GetFileName(Server.MapPath(strMp3)));

            mp3InfoInterHtml += "\"filename\":\"" + dir.GetDetailsOf(item, 0) + "\",";
            mp3InfoInterHtml += "\"musicsize\":\"" + dir.GetDetailsOf(item, 1) + "\",";
            mp3InfoInterHtml += "\"musicname\":\"" + dir.GetDetailsOf(item, 21) + "\",";
            mp3InfoInterHtml += "\"singer\":\"" + dir.GetDetailsOf(item, 13) + "\",";
            mp3InfoInterHtml += "\"album\":\"" + dir.GetDetailsOf(item, 14) + "\",";
            mp3InfoInterHtml += "\"duration\":\"" + dir.GetDetailsOf(item, 27) + "\"";
            mp3InfoInterHtml += "}";
            return(mp3InfoInterHtml);
        }
 private void orderfile_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.OpenFileDialog openFileDialog1 = new Microsoft.Win32.OpenFileDialog();
     openFileDialog1.Filter = "mp3文件(*.mp3)|*.mp3|wma文件(*.wma)|*.wma|wav文件(*.wav)|*.wav";
     if (openFileDialog1.ShowDialog().Value)
     {
         ShellClass sh       = new ShellClass();
         Folder     dir      = sh.NameSpace(System.IO.Path.GetDirectoryName(openFileDialog1.FileName));
         FolderItem item     = dir.ParseName(System.IO.Path.GetFileName(openFileDialog1.FileName));
         string     title    = dir.GetDetailsOf(item, 21);
         string     artist   = dir.GetDetailsOf(item, 20);
         string     duration = dir.GetDetailsOf(item, 27);
         Music      m        = new Music(System.IO.Path.GetFullPath(openFileDialog1.FileName), title, artist, duration);
         currentShowingList.Musiclist.Add(m);
         playlist.Items.Refresh();
     }
 }
Example #22
0
        public static DateTime GetMediaDateFromFileName(string filePath)
        {
            // Work with shell should be in method with [STAThread] attribute or in the Thread with ApartmentState.STA
            var value = StartSTATask(() =>
            {
                var shell      = new ShellClass();
                var folder     = shell.NameSpace(Path.GetDirectoryName(filePath));
                var folderItem = folder.ParseName(Path.GetFileName(filePath));

                const int mediaCreatedValue = 208;
                return(folder.GetDetailsOf(folderItem, mediaCreatedValue).Trim());
            }).Result;

            value = RemoveInvalidCharacters(value);
            // If the value string is empty, return DateTime.MinValue, otherwise return the "Media Created" date
            return(value == string.Empty ? DateTime.MinValue : DateTime.Parse(value));
        }
        public static MusicInfo GetMusicInfo(string filePath)
        {
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(filePath));
            FolderItem item = dir.ParseName(Path.GetFileName(filePath));

            MusicInfo musicInfo = new MusicInfo
            {
                MusicName  = GetMusicName(dir, item),
                Singer     = GetSinger(dir, item),
                TimeLength = GetTimeLength(dir, item),
                Album      = GetAlbum(dir, item),
                Rate       = GetRate(dir, item)
            };

            return(musicInfo);
        }
Example #24
0
    static void Main()
    {
        string dir  = @"C:\Users\ryu\Desktop"; // MP3ファイルのあるディレクトリ
        string file = "1-16 I Will.mp3";

        ShellClass shell = new ShellClass();
        Folder     f     = shell.NameSpace(dir);
        FolderItem item  = f.ParseName(file);

        for (int i = 0; i < 200; i++)
        {
            if (!string.IsNullOrEmpty(f.GetDetailsOf(item, i)))
            {
                Console.WriteLine(f.GetDetailsOf(item, i));  // アーティスト
            }
        }
    }
Example #25
0
        /// <summary>
        /// 获取指定路径的MP3文件音乐TAG
        /// 必须在STA线程下执行
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Dictionary <MusicInfos, string> GetInfo(string path)
        {
            var        Info = new Dictionary <MusicInfos, string>();
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(path));
            FolderItem item = dir.ParseName(Path.GetFileName(path));

            Info.Add(MusicInfos.Title, dir.GetDetailsOf(item, 21));
            Info.Add(MusicInfos.Singer, dir.GetDetailsOf(item, 13));
            Info.Add(MusicInfos.Album, dir.GetDetailsOf(item, 14));
            Info.Add(MusicInfos.Size, dir.GetDetailsOf(item, 1));
            Info.Add(MusicInfos.BitRate, dir.GetDetailsOf(item, 28));
            Info.Add(MusicInfos.Duration, dir.GetDetailsOf(item, 27));
            Info.Add(MusicInfos.AlbumImageUrl, GetImage(path));

            if (string.IsNullOrWhiteSpace(Info[MusicInfos.Singer]))
            {
                Info[MusicInfos.Singer] = dir.GetDetailsOf(item, 232);
            }
            if (string.IsNullOrWhiteSpace(Info[MusicInfos.Title]))
            {
                Info[MusicInfos.Title] = Path.GetFileNameWithoutExtension(path);
            }
            else if (!Path.GetFileNameWithoutExtension(path).Contains(Info[MusicInfos.Title]))
            {
                Info[MusicInfos.Title] = Path.GetFileNameWithoutExtension(path);
            }

            var virtualLrc  = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + ".lrc";
            var virtualLrc2 = "DownLoad\\Lyric\\" + Path.GetFileNameWithoutExtension(path) + ".lrc";

            if (File.Exists(virtualLrc))
            {
                Info.Add(MusicInfos.LyricUrl, virtualLrc);
            }
            else if (File.Exists(virtualLrc2))
            {
                Info.Add(MusicInfos.LyricUrl, Path.GetFullPath(virtualLrc2));
            }
            else
            {
                Info.Add(MusicInfos.LyricUrl, string.Empty);
            }
            return(Info);
        }
Example #26
0
        /// <summary>
        /// 获取音乐文件的属性
        /// </summary>
        /// <param name="path"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static FileAttributes GetFileAttributes(string path)
        {
            FileAttributes attr = new FileAttributes();
            ShellClass     sh   = new ShellClass();
            Folder         dir  = sh.NameSpace(Path.GetDirectoryName(path));
            FolderItem     item = dir.ParseName(Path.GetFileName(path));

            if (item != null)
            {
                attr.Name   = dir.GetDetailsOf(item, 0);
                attr.Size   = dir.GetDetailsOf(item, 1);
                attr.Type   = dir.GetDetailsOf(item, 2);
                attr.Album  = dir.GetDetailsOf(item, 14);
                attr.Title  = dir.GetDetailsOf(item, 21);
                attr.Length = dir.GetDetailsOf(item, 27);
            }
            return(attr);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                path.Text = openFileDialog1.FileName;
                axWindowsMediaPlayer1.URL = path.Text;
                FileInfo info = new FileInfo(path.Text);

                ShellClass sh   = new ShellClass();
                Folder     dir  = sh.NameSpace(Path.GetDirectoryName(path.Text));
                FolderItem item = dir.ParseName(Path.GetFileName(path.Text));

                artist.Text = dir.GetDetailsOf(item, 13);
                title.Text  = dir.GetDetailsOf(item, 21);
                album.Text  = dir.GetDetailsOf(item, 14);
                au.Text     = dir.GetDetailsOf(item, 236);
                leng.Text   = dir.GetDetailsOf(item, 27);
            }
        }
Example #28
0
        /// <summary>
        /// 获取音乐详情.
        /// </summary>
        /// <param name="mp3path">The mp3path.</param>
        /// <returns></returns>
        public Psd.H5Show.Model.Tools.MusicInfo getmp3info(string mp3path, string filename)
        {
            Psd.H5Show.Model.Tools.MusicInfo musicInfoModel = new Psd.H5Show.Model.Tools.MusicInfo();
            ShellClass sh  = new ShellClass();
            Folder     dir = sh.NameSpace(Path.GetDirectoryName(Server.MapPath(mp3path)));

            foreach (FolderItem item in dir)
            {
            }
            FolderItem item = dir.ParseName(Path.GetFileName(Server.MapPath(filename)));

            musicInfoModel.filename  = dir.GetDetailsOf(item, 0);
            musicInfoModel.musicsize = dir.GetDetailsOf(item, 1);
            musicInfoModel.musicname = dir.GetDetailsOf(item, 21);
            musicInfoModel.singer    = dir.GetDetailsOf(item, 13);
            musicInfoModel.album     = dir.GetDetailsOf(item, 14);
            musicInfoModel.duration  = dir.GetDetailsOf(item, 27);
            return(musicInfoModel);
        }
Example #29
0
        /// <summary>
        /// 获取歌曲信息
        /// </summary>
        /// <param name="path">歌曲路径</param>
        /// <returns></returns>
        public MusicInfo GetInfo(string path, string s)
        {
            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(path); //路径
            FolderItem item = dir.ParseName(s);   //文件名称加扩展名

            MusicInfo music = new MusicInfo
            {
                Mname  = dir.GetDetailsOf(item, 0).Split('.')[0],
                Msize  = dir.GetDetailsOf(item, 1),
                Album  = dir.GetDetailsOf(item, 14),
                Author = dir.GetDetailsOf(item, 20),
                Mtime  = dir.GetDetailsOf(item, 27),
                //完整路径加扩展名
                Path = Path.Combine(path, s)
            };

            GetMusicBitmap(music);
            return(music);
        }
Example #30
0
        /// <summary>
        /// 获得mp3文件的详细信息
        /// </summary>
        /// <param name="strPath"></param>
        /// <returns></returns>
        public List <string> GetMp3FileDetailInfo(string strPath)
        {
            List <string> fileInfoArr = new List <string>();

            ShellClass sh   = new ShellClass();
            Folder     dir  = sh.NameSpace(Path.GetDirectoryName(strPath));
            FolderItem item = dir.ParseName(Path.GetFileName(strPath));

            for (int i = -1; i < 50; i++)
            {
                // 0检索项的名称。
                // 1检索项的大小。
                // 2检索条目的类型。
                // 3检索项最后修改日期和时间。
                // 4检索项的属性。
                // -1项检索信息提示信息。
                fileInfoArr.Add(dir.GetDetailsOf(item, i));
            }
            return(fileInfoArr);
        }