public ID3AdapterEdit(Mp3File mp3File)
 {
     _mp3File = mp3File;
     _tagHandler = new TagHandler(_mp3File.TagModel);
     InitializeComponent();
     _textBoxTrackNo.Text = _tagHandler.Track;
     _textBoxArtist.Text = _tagHandler.Artist;
 }
Beispiel #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="mFileName">Mp3文件路径</param>
 public TagHelper(string mFileName)
 {
     this.mFileName = mFileName;
     //创建Mp3File对象
     mMp3File = new Mp3File(mFileName);
     //获取TagHandler
     mHandler = mMp3File.TagHandler;
 }
 public void copy(Id3Lib.TagHandler TH)
 {
     TH.Album    = this.Album;
     TH.Artist   = Artist;
     TH.Comment  = Comment;
     TH.Composer = Composer;
     TH.Disc     = Disc;
     TH.Genre    = Genre;
     TH.Lyrics   = Lyrics;
     TH.Song     = Song;
     TH.Title    = Title;
     TH.Track    = Track;
     TH.Year     = Year;
     //dont copy path, since that wouldnt do anything
 }
Beispiel #4
0
        /// <summary>
        /// Construct from file info; parse ID3 tags from stream and calculate where the audio must be
        /// </summary>
        /// <param name="fileinfo"></param>
        public Mp3FileData(FileInfo fileinfo)
        {
            _sourceFileInfo = fileinfo;

            // create an empty frame model, to use if we don't parse anything better
            TagModel tagModel = new TagModel();

            // don't know how big the audio is until we've parsed the tags
            UInt32 audioNumBytes;

            using( FileStream sourceStream = fileinfo.Open( FileMode.Open, FileAccess.Read, FileShare.Read ) )
            {
                // all the header calculations use UInt32;
                // this guarantees all the file offsets we have to deal with fit in a UInt32
                if( sourceStream.Length > UInt32.MaxValue )
                    throw new InvalidAudioFrameException( "MP3 file can't be bigger than 4gb" );

                // in the absence of any recognised tags,
                // audio starts at the start
                _audioStart = 0;
                // audio is entire file length
                audioNumBytes = (UInt32)sourceStream.Length;

                // try to read an ID3v1 block.
                // If ID3v2 block exists, its values overwrite these
                // Otherwise, if ID3V1 block exists, its values are used
                // The audio is anything that's left after all the tags are excluded.
                try
                {
                    ID3v1 id3v1 = new ID3v1();
                    id3v1.Deserialize( sourceStream );

                    // fill in ID3v2 block from the ID3v1 data
                    tagModel = id3v1.FrameModel;

                    // audio is shorter by the length of the id3v1 tag
                    audioNumBytes -= ID3v1.TagLength;
                }
                catch( TagNotFoundException )
                {
                    // ignore "no ID3v1 block"
                    // everything else isn't caught here, and throws out to the caller
                }

                try
                {
                    sourceStream.Seek( 0, SeekOrigin.Begin );
                    tagModel = TagManager.Deserialize( sourceStream );

                    // audio starts after the tag
                    _audioStart = (uint)sourceStream.Position;
                    // audio is shorter by the length of the id3v2 tag
                    audioNumBytes -= _audioStart;
                }
                catch( TagNotFoundException )
                {
                    // ignore "no ID3v2 block"
                    // everything else isn't caught here, and throws out to the caller
                }

                // create a taghandler to hold the tagmodel we've parsed, if any
                _tagHandler = new TagHandler( tagModel );

            } // closes sourceStream

            // save the location of the audio in the original file
            // passing in audio size and id3 length tag (if any) to help with bitrate calculations
            _audio = new AudioFile( fileinfo, _audioStart, audioNumBytes, _tagHandler.Length );
            _audioReplaced = false;
        }
        public ID3AdapterEdit(Mp3File mp3File)
        {
            _mp3File = mp3File;
            _tagHandler = new TagHandler(_mp3File.TagModel);

            InitializeComponent();
        }
        private MusicWindow(FileInfo imgSrc)
        {
            InitializeComponent();
            SpectrumAnalyzer.RegisterSoundPlayer(BassEngine.Instance);
            string file = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + @"\" +
                          Path.GetFileNameWithoutExtension(imgSrc.Name) + ".mp3";
            _fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + @"\Lyrics\"
                       + Path.GetFileNameWithoutExtension(imgSrc.Name) + ".lrc";

            TagHandler tagHandler = new TagHandler(new Mp3File(file).TagModel);
            ItemTitle.Text = tagHandler.Title != ""
                                 ? tagHandler.Title
                                 : Path.GetFileNameWithoutExtension(imgSrc.Name);
            OrilTime.Text = tagHandler.Track != "" ? "发源时间:" + tagHandler.Genre : "";

            Kind.Text = tagHandler.Track != "" ? "类别:" + tagHandler.Artist : "";
            // != "" ? _tagHandler.Artist : "未知类别";
            OrilLoca.Text = tagHandler.Track != "" ? "起源地:" + tagHandler.Album : "";
            // != "" ? "《" + _tagHandler.Album + "》" : "未知专辑";
            Year.Text = tagHandler.Track != "" ? "入遗时间:" + tagHandler.Year : "";
            Rank.Text = tagHandler.Track != "" ? "级别:" + tagHandler.Track : "";

            _timerLyric = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(200)};
            _timerLyric.Tick += (a, b) => ShowLyric();
            _timerLyric.Start();

            DirectoryInfo phothDir =
                new DirectoryInfo(imgSrc.Directory.FullName + @"\" + Path.GetFileNameWithoutExtension(imgSrc.Name));
            if (phothDir.Exists)
            {
                photo.ImageUrl = imgSrc.FullName;
                photo.Width = gd.Width;
                photo.Height = gd.Height;
                List<FileInfo> photos = new List<FileInfo>();

                photos.AddRange(phothDir.GetFiles("*.jpg", SearchOption.AllDirectories));
                photos.AddRange(phothDir.GetFiles("*.png", SearchOption.AllDirectories));
                photos.Add(imgSrc);
                _timerPhoto = new DispatcherTimer {Interval = TimeSpan.FromSeconds(4)};
                _timerPhoto.Tick += (a, b) =>
                    {
                        photo.ImageUrl = photos[_photoIndex++].FullName;
                        _photoIndex = _photoIndex%photos.Count;
                    };
                _timerPhoto.Start();
            }

            Width = SystemParameters.PrimaryScreenWidth;
            Height = SystemParameters.PrimaryScreenHeight;
            Left = 0;
            Top = 0;
            // this.Topmost = true;

            _img = new BitmapImage(new Uri(imgSrc.FullName));

            //根据分辨率不同,调整DetialWindow出现的位置
            if (Width > 1300)
            {
                _size = SystemParameters.PrimaryScreenWidth*0.415;
            }
            else if (Width < 1300 && Width > 1000)
            {
                _size = SystemParameters.PrimaryScreenWidth*0.415;
            }
            gd.Background = new ImageBrush(_img);
            if (_img.Width >= _img.Height)
            {
                _w = _size;
                _h = _size/_img.Width*_img.Height;
            }
            else
            {
                _h = _size;
                _w = _size/_img.Height*_img.Width;
            }

            _stdStart = (Storyboard) Resources["start"];
            _stdMusicFinish = (Storyboard) Resources["MusicFinish"];
            _stdEnd = (Storyboard) Resources["end"];
            _stdEnd2 = (Storyboard) Resources["end_2"];

            _stdStart.Completed += (a, b) =>
                {
                    //stdMiddle.Begin();
                    MusicInfo.Visibility = Visibility.Visible;
                    //MusicInfo.Opacity = 0;
                    var datImg = new DoubleAnimation(0, -1*SystemParameters.PrimaryScreenWidth*0.23,
                                                     new Duration(TimeSpan.FromMilliseconds(700)));
                    var datInfo = new DoubleAnimation(0, SystemParameters.PrimaryScreenWidth*0.23,
                                                      new Duration(TimeSpan.FromMilliseconds(700)));
                    var datPrs = new DoubleAnimation(0, 300, new Duration(TimeSpan.FromMilliseconds(2000)));

                    tlt.BeginAnimation(TranslateTransform.XProperty, datImg);
                    infoTlt.BeginAnimation(TranslateTransform.XProperty, datInfo);
                    process.BeginAnimation(WidthProperty, datPrs);
                };
            _stdEnd.Completed += (c, d) =>
                {
                    CloseAnmit();
                    _stdEnd2.Begin();
                };
            _stdEnd2.Completed += (e, f) => Close();
            Loaded += MainWindow_Loaded;
        }