public static MusicFileService Instance()
 {
     if (T == null)
     {
         T = new MusicFileService();
     }
     return(T);
 }
Ejemplo n.º 2
0
        //展示音乐整合后
        public MusicMenu ShowFiles()
        {
            this.musicMenu = new MusicMenu();
            List <MusicFile> files = MusicFileService.Instance().GetAllFiles();

            for (int i = 0; i < files.Count; i++)
            {
                this.musicMenu.addItem(new MenuItem(i, files[i].Name));
            }
            if (this.musicMenu.playingIndex != -1)
            {
                this.musicMenu.CurrentItem = this.musicMenu.playingIndex;
            }
            return(this.musicMenu);
        }
Ejemplo n.º 3
0
        public void nextPlay(MenuItem item)
        {
            this.musicMenu.playingIndex = (this.musicMenu.playingIndex + 1) % (this.musicMenu.getItemSize() - 4);
            string    name = this.musicMenu.getItemByIndex(this.musicMenu.playingIndex).Name;
            MusicFile file = MusicFileService.Instance().FindFile(name);

            if (cm != null)
            {
                cm.StopT();
            }
            cm          = new clsMCI();
            cm.FileName = file.Path;
            cm.play();
            this.musicMenu.Show();
        }
Ejemplo n.º 4
0
        static void previousPlay(MenuItem item)
        {
            int size = musicMenu.getItemSize() - 4;

            musicMenu.playingIndex = (musicMenu.playingIndex + size - 1) % size;
            string    name = musicMenu.getItemByIndex(musicMenu.playingIndex).Name;
            MusicFile file = MusicFileService.Instance().FindFile(name);

            if (cm != null)
            {
                cm.StopT();
            }
            cm          = new clsMCI();
            cm.FileName = file.Path;
            cm.play();
            musicMenu.Show();
        }
Ejemplo n.º 5
0
        public void ShowFiles(MenuItem item)
        {
            this.musicMenu.Clear();

            List <MusicFile> files = MusicFileService.Instance().GetAllFiles();

            for (int i = 0; i < files.Count; i++)
            {
                this.musicMenu.addItem(new MenuItem(i, files[i].Name, playMusic));
            }
            this.musicMenu.addItem(new MenuItem(files.Count, "返回主菜单", returnMainMenu));
            this.musicMenu.addItem(new MenuItem(files.Count + 1, "下一首", nextPlay));
            this.musicMenu.addItem(new MenuItem(files.Count + 2, "停止播放", stopPlay));
            this.musicMenu.addItem(new MenuItem(files.Count + 3, "上一首", previousPlay));
            if (this.musicMenu.playingIndex != -1)
            {
                this.musicMenu.CurrentItem = this.musicMenu.playingIndex;
            }
            this.musicMenu.Show();
        }
Ejemplo n.º 6
0
        //整合功能
        public void LoadFiles()
        {
            FolderBrowserDialog df = new FolderBrowserDialog();

            df.ShowDialog();
            string selectPath = df.SelectedPath;

            if ("" == selectPath)
            {
                return;
            }
            DirectoryInfo dInfo = new DirectoryInfo(selectPath);

            foreach (FileInfo f in dInfo.GetFiles("*.mp3"))
            {
                MusicFileService.Instance().AddFile(new MusicFile(f.Name, f.FullName, f.Length));
            }
            MusicFileService.Instance().Save();
            //mainMenu.Show();
        }
Ejemplo n.º 7
0
        //播放音乐
        public void playMusic(MenuItem item)
        {
            //歌曲播放选中
            this.musicMenu.playingIndex = item.Id;
            //MessageBox.Show("播放音乐"+item.Name);
            MusicFile file = MusicFileService.Instance().FindFile(item.Name);

            if (null == file)
            {
                this.musicMenu.Show();
                return;
            }
            //停止旧的歌曲
            if (null != cm)
            {
                cm.StopT();
            }
            //播放
            cm          = new clsMCI();
            cm.FileName = file.Path;
            cm.play();
        }