/// <summary>
        /// Ask the user if they want changes to be made. if yes, then make the changes, if no, return true, if cancel, return false
        /// </summary>
        /// <param name="newData">the copied mp3files taghandler</param>
        /// <param name="orig">the original mp3file</param>
        /// <param name="checkFirst"></param>
        /// <returns>return false if the user wants to cancel all changes, true in any other case</returns>
        public static bool queryUserMakeChangesAndContinue(TagHandlerUpdate newData, Mp3Lib.Mp3File orig, bool checkFirst)
        {
            usercheck UC = null;

            if (checkFirst)
            {
                if (areThereDifferences(orig, newData) == false)
                {
                    MessageBox.Show("No changes need to be made for this file");
                }
                else
                {
                    UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)),
                                       DictionaryExtras.DictToListOfListViewItems(newData.toDict()));
                    UC.ShowDialog();
                }

                if (UC == null || UC.cancelval)
                {
                    return(false);
                }
                if (UC.makeChanges == false)
                {
                    return(true);
                }
            }

            return(makeChangesAndContinue(newData, orig));
        }
Esempio n. 2
0
 public ID3AdapterEdit(Mp3File mp3File)
 {
     _mp3File = mp3File;
     _tagHandler = new TagHandler(_mp3File.TagModel);
     InitializeComponent();
     _textBoxTrackNo.Text = _tagHandler.Track;
     _textBoxArtist.Text = _tagHandler.Artist;
 }
Esempio n. 3
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 static bool areThereDifferences(Mp3File orig, TagHandlerUpdate newData)
        {
            var UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)),
                DictionaryExtras.DictToListOfListViewItems(newData.toDict()));

            if (UC.noChanges)
                return false;

            return true;
        }
            public TagHandlerUpdate(Mp3Lib.Mp3File mff)
            {
                var TH = mff.TagHandler;

                this.Album = TH.Album;
                Artist     = TH.Artist;
                Comment    = TH.Comment;
                Composer   = TH.Composer;
                Disc       = TH.Disc;
                Genre      = TH.Genre;
                Lyrics     = TH.Lyrics;
                Song       = TH.Song;
                Title      = TH.Title;
                Track      = TH.Track;
                Year       = TH.Year;
                Path       = mff.FileName;
            }
Esempio n. 6
0
    void alphabetizeByAlbum()
    {
        GameObject[] audioHolders = new GameObject[10000]; //temporary placeholder max size

        print (musicFiles.Count);

        foreach(FileInfo f in musicFiles) {
            //print("Loading "+f.FullName);
            GameObject audioHolder = new GameObject(f.Name);
            audioHolders[songIndex] = audioHolder;
            songIndex++;

            ID3v1 tagger = new ID3v1();

            FileStream mp3Stream = new FileStream(f.FullName, FileMode.Open);

            Mp3File currentMP3 = new Mp3File(f);

            currentMP3.Update();

            tagger.Deserialize(mp3Stream);

            mp3Stream.Close();

            string album = tagger.Album;

            //print ("album: " + album);

            for (int i = 0; i < alphabeticalTitles.Length; i++) {

                string firstChar = alphabeticalTitles.GetValue(i).ToString().Substring(5,1);

                if (album.StartsWith(firstChar)) {

                    audioHolder.transform.parent = alphabeticalTitles[i].transform;

                }

            }
        }

        return;
    }
        private static Dictionary <String, String> TagHandlerToDict(Mp3Lib.Mp3File mpf)
        {
            var TH  = mpf.TagHandler;
            var ret = new Dictionary <string, string>();

            ret.Add("Album", TH.Album);
            ret.Add("Artist", TH.Artist);
            ret.Add("Comment", TH.Comment);
            ret.Add("Composer", TH.Composer);
            ret.Add("Disc", TH.Disc);
            ret.Add("Genre", TH.Genre);
            ret.Add("Lyrics", TH.Lyrics);
            ret.Add("Song", TH.Song);
            ret.Add("Title", TH.Title);
            ret.Add("Track", TH.Track);
            ret.Add("Year", TH.Year);
            ret.Add("Path", mpf.FileName);
            return(ret);
        }
        public void Compact( string filename )
        {
            try
            {
                // create mp3 file wrapper; open it and read the tags
                Mp3File mp3File = new Mp3File(filename);

                try
                {
                    using( new CursorKeeper(Cursors.WaitCursor) )
                    {
                        mp3File.UpdatePacked();
                    }
                }
                catch (Exception e)
                {
                    ExceptionMessageBox.Show(_form, e, "Error Writing Tag");
                }
            }
            catch (Exception e)
            {
                ExceptionMessageBox.Show(_form, e, "Error Reading Tag");
            }
        }
        public static void DropInFiles(string[] files, ListView fileList)
        {
            var acceptall = false;
            var nochanges = false;
            const string YTA = "Yes To All";
            const string nostr = "No";
            const string noallstr = "No To All";
            const string yesstr = "Yes";
            const string cancelstr = "Cancel";

            var l = new List<string>();
            l.Add(YTA);
            l.Add(yesstr);
            l.Add(nostr);
            l.Add(noallstr);
            l.Add(cancelstr);

            foreach (var s in files)
            {
                var LVI = initLVI(fileList);
                LVI.Text = fileList.Items.Count.ToString();
                LVI.Name = LVI.Text;
                LVI.SubItems.Add(s);

                Mp3File mf = null;

                var retrycount = 0;
                var retrymax = 10;
                retry:

                try
                {
                    mf = new Mp3File(s);
                }
                catch (Exception exp)
                {
                    retrycount++;
                    if (retrycount >= retrymax)
                    {
                        MessageBox.Show("Error opening file:" + exp.ToString());

                        var DR = MessageBox.Show("Do you want to continue?", "option", MessageBoxButtons.YesNo);
                        if (DR == DialogResult.No)
                            return;

                        continue;
                    }

                    //for a certain period, retry
                    Thread.Sleep(100);
                    goto retry;
                }

                LVI.Tag = mf;
                var sas = mf.Audio;
                sas.ScanWholeFile();

                //clean files on entry
                var newData = new changes.TagHandlerUpdate(mf);

                if (nochanges == false)
                {
                    Music_File_Info_Editor.changes.cleanMP3(newData);

                    var changes = Music_File_Info_Editor.changes.areThereDifferences(mf, newData);
                    var makechanges = true;
                    if (changes && acceptall == false)
                    {
                        var tt = "The file:" + mf.FileName +
                                    " has a title/album/artist with blank characters at the start or end, or has multiple white space. Do you wish to fix these?";
                        var MMB = new MultipleMessageBox("option", tt, l);
                        MMB.ShowDialog();

                        if (MMB.IsSet == false)
                            return;

                        switch (MMB.Result)
                        {
                            case cancelstr:
                                return;

                            case nostr:
                                makechanges = false;
                                break;

                            case YTA:
                                acceptall = true;
                                break;

                            case noallstr:
                                makechanges = false;
                                nochanges = true;
                                break;
                        }
                    }

                    if (makechanges)
                    {
                        if (Music_File_Info_Editor.changes.makeChangesAndContinue(newData, mf) == false)
                            return;
                    }
                }

                //only add if the name isnt there already
                var add = true;
                foreach (ListViewItem tt in fileList.Items)
                {
                    var s1 = tt.SubItems[ListViewExtras.GetColumnNumber(fileList, "Path")].Text;

                    if (s1.Equals(mf.FileName))
                    {
                        add = false;
                        break;
                    }
                }

                if (add)
                    fileList.Items.Add(LVI);
            }

            RefreshInfo(fileList);
            ListViewExtras.AutoResize(fileList);
        }
Esempio n. 10
0
        /// <summary>
        /// copy the newdata to the original.
        /// </summary>
        /// <param name="newData"></param>
        /// <param name="orig"></param>
        /// <returns>always true</returns>
        public static bool makeChangesAndContinue(TagHandlerUpdate newData,  Mp3File orig)
        {
            newData.copy(orig.TagHandler);

            var retrycount = 0;
            var maxretry = 10;
            retry:
            try
            {
                orig.Update();
            }
            catch (Exception ecp)
            {
                retrycount++;
                if (retrycount >= maxretry)
                {
                    MessageBox.Show("Changes could not be made-" + ecp.ToString());
                    return true;
                }
                System.Threading.Thread.Sleep(100);
                goto retry;
            }

            return true;
        }
Esempio n. 11
0
        /// <summary>
        /// Scans for the next file. Returns false if no files found
        /// </summary>
        /// <param name="missingArt">Only stops when we find a file with missing art</param>
        /// <param name="startAtOne">Check the current file as well</param>
        public bool selectNextItem(bool missingArt, bool startAtZero)
        {
            int currentIndex = FileList.SelectedIndex;

            bool firstItem = true;
            bool exit = false;
            bool invalidTag = false;
            while(exit == false && currentIndex > -1 && currentIndex < FileList.Items.Count)
            {
                invalidTag = false;
                if (firstItem && startAtZero)
                {
                    currentIndex--;
                }
                firstItem = false;
                currentIndex++;
                //open the file (peek at it, then close, to make sure we don't OOM
                FileInfo fi = FileList.Items[currentIndex] as FileInfo;
                Mp3File peekFile = new Mp3File(fi);

                //check for unsupported tags
                try
                {
                    if (peekFile.TagHandler.Picture == null)
                    {
                        //null test to see if the picture errors. Probably not needed
                    }
                }
                catch (NotImplementedException e)
                {
                    MessageBox.Show("Invalid tag on " + peekFile.FileName + " - " + e.Message);
                    invalidTag = true;
                }

                //if we are not looking for artwork, exit
                //or, if we have a valid tag, and it has a pic, exit

                if (missingArt) //looking for next file with missing artwork
                {
                    //skip invalid tags
                    if (!invalidTag && peekFile.TagHandler.Picture == null)
                    {
                        FileList.SelectedIndex = currentIndex;
                        exit = true;
                    }
                }
                else //looking for next valid file
                {
                    if (!invalidTag)
                    {
                        FileList.SelectedIndex = currentIndex;
                        exit = true;
                    }
                }

                //peekFile = null;
                //fi = null;
                //GC as the unmanaged code is a memory w***e
                GC.Collect(GC.MaxGeneration);
                GC.WaitForPendingFinalizers();

            }
            //return true if we found a file, false if we didnt.
            return exit;
        }
Esempio n. 12
0
        public void saveTags()
        {
            if (imageUpdated)
            {

                System.Drawing.Image image = Tag_Image.Tag as System.Drawing.Image;
                //Bitmap b = Tag_Image.Tag as Bitmap;
                file.TagHandler.Picture = image;
            }

            if (tagsUpdated)
            {
                file.TagHandler.Album = Tag_Album.Text;
                file.TagHandler.Artist = Tag_Artist.Text;
                file.TagHandler.Song = Tag_Song.Text;
            }
            try
            {

                file.Update();

                //move / delete any bak files
                string bakName = System.IO.Path.ChangeExtension(file.FileName, "bak");
                FileInfo bakfile = new FileInfo(bakName);
                if (bakfile.Exists)
                {
                    if (chk_Backup.IsChecked == true)
                    {
                        string location = backupDirectory.FullName + @"\" + System.IO.Path.GetFileName(file.FileName);
                        bakfile.MoveTo(location);
                    }
                    else
                    {
                        bakfile.Delete();
                    }
                }

                //move file to output folder (if selected)
                if (destinationDirectory != null)
                {
                    FileInfo fi = new FileInfo(file.FileName);
                    file = null;
                    fi.MoveTo(destinationDirectory.FullName + "\\" + fi.Name);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 13
0
        public void refreshCurrentTag()
        {
            //loop through the selected files and grab the ID3 tags and info

            if (FileList.SelectedItems.Count > 0)
            {
                try
                {
                    FileInfo fi = FileList.SelectedItems[0] as FileInfo;

                    if (file != null) { file = null; }

                    file = new Mp3File(fi);
                    Tag_File.Text = fi.Name;

                    if (file.TagHandler.Picture != null)
                    {
                        SetImageFromBitmap(file.TagHandler.Picture, false);
                    }
                    else
                    {
                        Tag_Image.Source = null;
                    }
                    Tag_Album.Text = file.TagHandler.Album;
                    Tag_Artist.Text = file.TagHandler.Artist;

                    Tag_Song.Text = file.TagHandler.Song;
                    imageUpdated = false;
                    tagsUpdated = false;

                    webFrame.Visibility = System.Windows.Visibility.Hidden;

                }
                catch (Id3Lib.Exceptions.TagNotFoundException)
                {
                    //drop out if no tag. Should still be able to write one.

                    file = null;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }

            }
            else
            {
                //todo - lock fields
            }
        }
Esempio n. 14
0
        internal void RemoveV2tag( string filename )
        {
            try
            {
                // create mp3 file wrapper; open it and read the tags
                Mp3File mp3File = new Mp3File(filename);

                try
                {
                    using( new CursorKeeper(Cursors.WaitCursor) )
                    {
                        mp3File.UpdateNoV2tag();
                    }
                }
                catch( Exception e )
                {
                    ExceptionMessageBox.Show(_form, e, "Error Writing Tag");
                }
            }
            catch( Exception e )
            {
                ExceptionMessageBox.Show(_form, e, "Error Reading Tag");
            }
        }
Esempio n. 15
0
        public void EditTag(string filename)
        {
            Mp3File mp3File = null;

            try
            {
                // create mp3 file wrapper; open it and read the tags
                mp3File = new Mp3File(filename);
            }
            catch (Exception e)
            {
                ExceptionMessageBox.Show(_form, e, "Error Reading Tag");
                return;
            }

            // create dialog and give it the ID3v2 block for editing
            // this is a bit sneaky; it uses the edit dialog straight out of TagScanner.exe as if it was a dll.
            TagEditor.ID3AdapterEdit id3Edit = new TagEditor.ID3AdapterEdit(mp3File);

            if (id3Edit.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    using( new CursorKeeper(Cursors.WaitCursor) )
                    {
                        mp3File.Update();
                    }
                }
                catch (Exception e)
                {
                    ExceptionMessageBox.Show(_form, e, "Error Writing Tag");
                }
            }
        }
Esempio n. 16
0
 public Song(string path)
 {
     _path = path;
     Mp3 = new Mp3File(path);
 }
Esempio n. 17
0
    // Update is called once per frame
    void Update()
    {
        if (boxIsMoving) {
            moveBox(interactable.transform.parent.gameObject, boxEndPosition);
        }

        if (folderIsMoving && !foldersOut) {
            int folderIndex = 0;
            foreach (Transform artistFolder in artistFolderContainer.transform) {
                moveFolder(artistFolder.gameObject, folderEndPositions[folderIndex]);
                folderIndex++;
            }
        }

        if (folderIsMoving && foldersOut) {
            int folderIndex = 0;
            foreach (Transform artistFolder in artistFolderContainer.transform) {
                moveFolder(artistFolder.gameObject, folderOriginalPositions[folderIndex]);
                folderIndex++;
            }
        }

        if (Input.GetKeyDown ("x") && !boxIsMoving && waitingForArtistSelection && !artistSelected) {
            boxIsMoving = true;
            boxEndPosition = boxOriginalPosition;
            foreach (Transform artistFolder in artistFolderContainer.transform) {
                Destroy(artistFolder.gameObject);
            }
            waitingForAlbumSelection = false;
            selectedFolder = 0;
        }

        if (interactable.transform.parent.transform.localPosition == boxOriginalPosition && waitingForArtistSelection) {
            raycaster.enabled = true;
            waitingForArtistSelection = false;
            boxIsMoving = false;
            boxIsOpen = false;
        }

        /*Artist selection*/
        try {
            if (foldersOut) {
                artistFolderContainer.transform.GetChild(selectedFolder).GetChild(2).GetComponent<MeshRenderer>().material.color = ToColor(16761477);

                selectedArtist = artistFolderContainer.transform.GetChild(selectedFolder).transform;

                if (Input.GetKeyDown ("s") && selectedFolder+1 < artistFolderContainer.transform.childCount && !waitingForAlbumSelection) {
                    artistFolderContainer.transform.GetChild(selectedFolder).GetChild(2).GetComponent<MeshRenderer>().material.color = folderDefaultColor;
                    selectedFolder++;
                }
                if (Input.GetKeyDown ("w") && selectedFolder-1 >= 0) {
                    artistFolderContainer.transform.GetChild(selectedFolder).GetChild(2).GetComponent<MeshRenderer>().material.color = folderDefaultColor;
                    selectedFolder--;
                }
                if (Input.GetKeyDown ("f") && !waitingForAlbumSelection) {
                    //Pull folders out of view, make appropriate albums visible, wait for album selection
                    folderIsMoving = true;
                    foldersLifted = false;
                    foldersOut = false;
                    artistSelected = true;
                    foreach (Transform artist in alphabeticalContainer.transform) {
                        if (selectedArtist.gameObject.name == artist.gameObject.name) {
                            selectedArtistContainer = artist;
                            foreach (Transform album in artist) {
                                album.gameObject.SetActive(true);
                                album.position = new Vector3(0, -7, 0);
                            }
                        }
                    }
                }
            }
        } catch (UnityException) {
            //There are no artists under that letter
        }

        /*Album selection*/
        try {
            if (artistSelected && !albumSelected) {

                selectedAlbum = selectedArtistContainer.transform.GetChild(selectedAlbumIndex);
                selectedAlbum.GetChild(0).GetComponent<MeshRenderer>().material.shader = GUI3DTextShader;
                selectedAlbum.GetChild(0).gameObject.SetActive(true);
                selectedAlbum.GetChild(0).GetComponent<TextMesh>().text = selectedAlbum.name;
                if (!foldersLifted || !waitingForAlbumSelection) {
                    foreach (Transform artistFolder in artistFolderContainer.transform) {
                        liftFolder(artistFolder.gameObject, artistFolder.position + new Vector3(0, 20, 0));
                    }
                    //Move albums into view
                    int albumIndex = 0;
                    Vector3 currentOffset;
                    float currentY = selectedArtistContainer.position.y;
                    if (!waitingForAlbumSelection) {
                        foreach (Transform album in selectedArtistContainer) {
                            currentOffset = new Vector3(folderEndPositions[0].x * -0.2f, 0, folderEndPositions[0].z * -0.2f);
                            albumEndPositions[albumIndex] = (new Vector3(folderEndPositions[0].x * 0.8f, currentY, folderEndPositions[0].z * 0.8f) - currentOffset*(currentY/-0.5f));
                            positionAlbum(album.gameObject, albumEndPositions[albumIndex]);
                            albumIndex++;
                            currentY -= 0.1f;
                        }
                    }
                }
                if (Input.GetKeyDown("x")) {
                    folderIsMoving = true;
                    artistSelected = false;
                    waitingForAlbumSelection = false;
                    //Move albums back, deactivate
                    foreach (Transform album in selectedArtistContainer) {
                        album.gameObject.SetActive(false);
                    }
                    albumsOut = false;
                    foldersLifted = false;
                }

                if (Input.GetKeyDown("w")) {
                    waitingForAlbumSelection = true;
                    if (selectedAlbumIndex > 0) {
                        selectedAlbum.GetChild(0).gameObject.SetActive(false);
                        selectedAlbumIndex--;

                        //Move albums down
                        albumLiftingDown = true;
                        previouslySelectedAlbum = selectedAlbum;
                        previouslySelectedAlbumIndex = previouslySelectedAlbum.GetSiblingIndex();
                        scrollTarget = selectedAlbum.parent.GetChild(previouslySelectedAlbumIndex-1).localPosition + new Vector3(0, -3, 0);
                    }
                }
                if (Input.GetKeyDown("s")) {
                    waitingForAlbumSelection = true;
                    if (selectedAlbumIndex < selectedArtistContainer.childCount-1) {
                        selectedAlbum.GetChild(0).gameObject.SetActive(false);
                        selectedAlbumIndex++;

                        //Move albums up
                        albumLiftingUp = true;
                        previouslySelectedAlbum = selectedAlbum;
                        previouslySelectedAlbumIndex = previouslySelectedAlbum.GetSiblingIndex();
                        scrollTarget = selectedAlbum.parent.GetChild(previouslySelectedAlbumIndex+1).localPosition + new Vector3(0, 3, 0);
                    }
                }
                if (Input.GetKeyDown("f") && albumsOut && !albumSelected) {
                    albumSelected = true;
                }
                selectedAlbum = selectedArtistContainer.transform.GetChild(selectedAlbumIndex);
                if (albumLiftingUp) {
                    liftAlbumUp(previouslySelectedAlbum.gameObject, scrollTarget);
                }
                if (albumLiftingDown) {
                    liftAlbumDown(selectedAlbum.gameObject, albumEndPositions[selectedAlbumIndex]);
                }

            }
        } catch (UnityException) {

        }

        /*Song selection*/
        try {
            if (albumSelected && !songSelected) {
                //print ("Album selected");
                //Generate song names
                folderIsMoving = false;

                if (!songsOut) {
                    songIndex = 0;
                    foreach (Transform song in selectedAlbum) {
                        selectedAlbum.gameObject.transform.GetChild(0).gameObject.SetActive(false);
                        if (song.gameObject.name != "AlbumTitle" &&
                           (song.gameObject.name.EndsWith(".mp3") ||
                         	song.gameObject.name.EndsWith(".wav") ||
                         	song.gameObject.name.EndsWith(".ogg"))) {

                            FileInfo f = new FileInfo(song.gameObject.name);
                            ID3v1 tagger = new ID3v1();
                            FileStream mp3Stream = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.None);
                            Mp3File currentMP3 = new Mp3File(f);

                            currentMP3.Update();

                            string songName = "";

                            try {
                                tagger.Deserialize(mp3Stream);
                                mp3Stream.Close();
                                songName = tagger.Song;
                            } catch (Id3Lib.Exceptions.TagNotFoundException ex) {
                                songName = "[Unknown track title]";
                                print(ex);
                            }

                            songHolders[songIndex] = new GameObject(song.gameObject.name);
                            songHolders[songIndex].transform.position = selectedAlbum.transform.GetChild(0).transform.position;
                            songHolders[songIndex].transform.eulerAngles = selectedAlbum.transform.GetChild(0).transform.eulerAngles;
                            //songHolders[songIndex].transform.eulerAngles -= new Vector3(0, -90, 0);
                            songHolders[songIndex].transform.position -= new Vector3(0, songIndex * 0.2f - 0.7f, 0);
                            songHolders[songIndex].AddComponent<TextMesh>();
                            songHolders[songIndex].GetComponent<TextMesh>().text = songName;
                            songHolders[songIndex].GetComponent<TextMesh>().fontSize = 60 - songName.Length;
                            songHolders[songIndex].GetComponent<TextMesh>().characterSize = .03f;

                            songHolders[songIndex].GetComponent<MeshRenderer>().material.shader = GUI3DTextShader;

                            songIndex++;
                        }
                    }
                    songHolders[0].GetComponent<MeshRenderer>().material.color = Color.yellow;
                    songsOut = true;
                }
                else {
                    songHolders[selectedSong].GetComponent<MeshRenderer>().material.color = Color.yellow;
                    if (Input.GetKeyDown("s") && (selectedSong < songIndex-1)) {
                        songHolders[selectedSong].GetComponent<MeshRenderer>().material.color = Color.white;
                        selectedSong++;
                    }
                    if (Input.GetKeyDown("w") && (selectedSong > 0)) {
                        songHolders[selectedSong].GetComponent<MeshRenderer>().material.color = Color.white;
                        selectedSong--;
                    }
                    if (Input.GetKeyDown("x")) {
                        selectedAlbum.GetChild(0).gameObject.SetActive(true);
                        for (int i = 0; i <= songIndex; i++) {
                            Destroy(songHolders[i]);
                        }
                        songsOut = false;
                        albumSelected = false;
                        selectedSong = 0;
                        songIndex = 0;
                    }
                    if (Input.GetKeyDown("f")) {
                        PreserveData p = selectedSongInfo.GetComponent<PreserveData>();
                        p.path = songHolders[selectedSong].name;
                        if (selectedAlbum.gameObject.GetComponent<Renderer>().material.mainTexture == null) {
                            print ("null here");
                        }
                        if (selectedAlbum.gameObject.GetComponent<Renderer>().material.mainTexture != null) {
                            Color[] albumColors = colorAnalyzer.findColorScheme(selectedAlbum.gameObject.GetComponent<Renderer>().material.mainTexture, colorDetail, colorTolerance);
                            p.colorScheme = albumColors;
                            /*for (int i = 0; i < colorDetail; i++) {
                                print (albumColors[i]);
                            }*/
                        };

                        //Application.LoadLevel("ParticleRoom");
                        Application.LoadLevel(levelToLoad);
                    }
                }

            }
        } catch (UnityException) {

        }
    }
Esempio n. 18
0
    void alphabetizeByArtist()
    {
        GameObject[] audioHolders = new GameObject[10000]; //temporary placeholder max size

        //print (musicFiles.Count);

        string artist = "No Artist";
        string album = "No Album";

        foreach(FileInfo f in musicFiles) {
            //print("Loading "+f.FullName);
            GameObject audioHolder = new GameObject(f.Name);
            audioHolder.name = f.FullName;
            audioHolders[songIndex] = audioHolder;
            songIndex++;
            if (!(f.FullName.EndsWith(".jpg") || f.FullName.EndsWith(".png"))) {
                ID3v1 tagger = new ID3v1();

                FileStream mp3Stream = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.None);

                Mp3File currentMP3 = new Mp3File(f);

                currentMP3.Update();

                try {
                    tagger.Deserialize(mp3Stream);
                    mp3Stream.Close();
                    artist = tagger.Artist;
                    album = tagger.Album;
                } catch (Id3Lib.Exceptions.TagNotFoundException ex) {
                    mp3Stream.Close();
                    album = "No Album";
                    artist = "No artist";
                    print(ex);
                }

            }

            for (int i = 0; i < alphabeticalTitles.Length; i++) {

                string firstChar = alphabeticalTitles.GetValue(i).ToString().Substring(5,1);

                //Organize into specific artists and albums
                if (artist.StartsWith(firstChar)) {

                    //if artist holder doesn't already exist, create - otherwise add song to artist holder
                    bool artistExists = false;
                    Transform currentArtistHolder = null;
                    foreach(Transform artistHolder in alphabeticalTitles[i].transform) {
                        if (artistHolder.name.Trim() == artist.Trim()) {
                            artistExists = true;
                            currentArtistHolder = artistHolder;
                        }
                    }
                    if (!artistExists) {
                        currentArtistHolder = new GameObject(artist).transform;
                        currentArtistHolder.transform.parent = alphabeticalTitles[i].transform;
                    }

                    //audioHolder.transform.parent = currentArtistHolder;

                    bool albumExists = false;
                    Transform currentAlbumHolder = null;
                    foreach(Transform albumHolder in currentArtistHolder.transform) {
                        if (albumHolder.name.Trim () == album.Trim()) {
                            albumExists = true;
                            currentAlbumHolder = albumHolder;
                        }
                    }
                    if (!albumExists) {
                        currentAlbumHolder = Instantiate(albumSleevePrefab).transform;
                        currentAlbumHolder.transform.parent = currentArtistHolder;
                        currentAlbumHolder.name = album;
                    }
                    /*if (!albumExists) {
                        currentAlbumHolder = new GameObject(album).transform;
                        currentAlbumHolder.transform.parent = currentArtistHolder;
                        currentAlbumHolder.gameObject.AddComponent<Renderer>();
                        currentAlbumHolder.gameObject.GetComponent<Renderer>().material.mainTexture = artGrabber.getAlbumArtAsTexture(audioHolder);
                    }*/

                    audioHolder.transform.parent = currentAlbumHolder;
                    currentAlbumHolder.gameObject.GetComponent<Renderer>().material.mainTexture = artGrabber.getAlbumArtAsTexture(audioHolder, f);
                    if (currentAlbumHolder.gameObject.GetComponent<Renderer>().material.mainTexture == null) {
                        currentAlbumHolder.gameObject.GetComponent<Renderer>().material.mainTexture = Resources.Load("defaultAlbumArt") as Texture2D;
                    }

                }

            }

        }

        return;
    }
Esempio n. 19
0
        public ID3AdapterEdit(Mp3File mp3File)
        {
            _mp3File = mp3File;
            _tagHandler = new TagHandler(_mp3File.TagModel);

            InitializeComponent();
        }
Esempio n. 20
0
        public ActionResult GetMeta()
        {
            ShownItems = new Audios(MusicSingltone.Core.GetAudios());

            var audio = ShownItems.Last();
            var mp3File = new Mp3File(audio.FullPath);

            return View(mp3File);
        }
Esempio n. 21
0
        public void EditExtendedTag( string filename )
        {
            Mp3File mp3File = null;

            try
            {
                // create mp3 file wrapper; open it and read the tags
                mp3File = new Mp3File(filename);
            }
            catch (Exception ex)
            {
                ExceptionMessageBox.Show(_form, ex, "Error Reading Tag");
                return;
            }

            if (mp3File.TagModel != null)
            {
                // create dialog and give it the ID3v2 block for editing
                // this is a bit sneaky; it uses the edit dialog straight out of TagScanner.exe as if it was a dll.
                TagEditor.ID3PowerEdit id3PowerEdit = new TagEditor.ID3PowerEdit();
                id3PowerEdit.TagModel = mp3File.TagModel;
                id3PowerEdit.ShowDialog();
            }
        }