예제 #1
0
        MusicItem GetNextMusicItem()
        {
            selectIndex++;

            var tabContent = (dmItemContent)currentTabItem.Content;

            var listView = tabContent.musicList;

            if (listView.Items.Count == selectIndex)
            {
                selectIndex = 0;
            }

            MusicItem mItem = (MusicItem)listView.Items[selectIndex];

            return(mItem);
        }
예제 #2
0
        void PlaySound(MusicItem mItem)
        {
            if (currentMusicItem != null)
            {
                currentMusicItem.Playing = "";
            }

            mItem.Playing = ">";

            musicPlayer.CleanupPlayback();
            musicPlayer.Open(mItem.FilePath, null);
            musicPlayer.Play();

            currentTabItem   = (TabItem)extendedTabControl.SelectedItem;
            currentMusicItem = mItem;

            ((dmItemContent)currentTabItem.Content).musicList.Items.Refresh();

            trackBar.Value   = 0;
            trackBar.Maximum = musicPlayer.Length.TotalSeconds;

            btnPlay.Content    = 4;
            btnPlay.Background = Brushes.Red;
        }
예제 #3
0
        MusicItem CreateMusicItem(TagLib.File f)
        {
            MusicItem musicItem = new MusicItem();

            if (f.Tag.Title == null)
            {
                // ID3 태그가 읽히지 않은것이다.
                // 걍 파일명을 등록한다.
                musicItem.Title    = System.IO.Path.GetFileNameWithoutExtension(f.Name);
                musicItem.Duration = "";
            }
            else
            {
                Stream streamT = GenerateStreamFromString(f.Tag.Title);
                Stream streamA = GenerateStreamFromString(f.Tag.FirstAlbumArtist);

                byte[] tmpBuff_T = new byte[4];
                byte[] tmpBuff_A = new byte[4];

                if (streamT != null)
                {
                    streamT.Read(tmpBuff_T, 0, 4);
                }

                if (streamA != null)
                {
                    streamA.Read(tmpBuff_A, 0, 4);
                }

                byte[] tmpTargets = { 194, 195, 77, 78, 68, 49, 74, 70 };

                string title  = f.Tag.Title;
                string artist = f.Tag.FirstAlbumArtist;

                Func <string, string> act = (string tmp) =>
                {
                    if (string.IsNullOrEmpty(tmp))
                    {
                        tmp = "";
                    }

                    Encoding enc        = Encoding.GetEncoding("iso-8859-1");
                    byte[]   sorceBytes = enc.GetBytes(tmp);
                    byte[]   encBytes   = Encoding.Convert(Encoding.GetEncoding("euc-kr"), Encoding.UTF8, sorceBytes);
                    var      tmpStr     = Encoding.UTF8.GetString(encBytes);
                    return(tmpStr);
                };

                if (streamT != null && Array.Exists(tmpTargets, x => x == tmpBuff_T[0]))
                {
                    title = act(f.Tag.Title);
                }

                if (streamA != null && Array.Exists(tmpTargets, x => x == tmpBuff_A[0]))
                {
                    artist = act(f.Tag.FirstAlbumArtist);
                }

                TimeSpan time = TimeSpan.FromSeconds(f.Properties.Duration.TotalSeconds);

                string strDuration = time.ToString(@"mm\:ss");
                string duration    = string.Format("{0}", f.Properties.Duration.TotalSeconds);

                musicItem.Title    = title + "/" + artist;
                musicItem.Duration = strDuration;
            }

            musicItem.FilePath = f.Name;

            return(musicItem);
        }