Example #1
0
 public void seekSong(int i)
 {
     Hyena.Log.Information("SeekSong called " + i);
     try {
         CueSheet sheet = MySource.getSheet();
         if (sheet.Count == 0)
         {
             if (_selected != null)
             {
                 loadCueSheet(_selected);
             }
         }
         CueSheetEntry e = sheet.entry(i);
         _song_id = e.id();
         if (_song_file != e.file())
         {
             ServiceManager.PlayerEngine.Open(e);
             ServiceManager.PlayerEngine.Play();
             _song_file = e.file();
         }
         double offset = e.offset();
         //ServiceManager.PlayerEngine.SetCurrentTrack(e);
         _position     = (uint)(offset * 1000.0);
         _set_position = true;
         mscount       = chgcount - (1000 / timeout);
     } catch (SystemException ex) {
         Hyena.Log.Information(ex.ToString());
     }
 }
Example #2
0
        public int searchIndex(string _current_entry_id, double _offset)
        {
            Hyena.Log.Information("id=" + _current_entry_id + ", offset=" + _offset);
            int k, N;

            if (_current_entry_id == null)
            {
                for (k = 0, N = nEntries(); k < N && _offset > _tracks[k].offset(); k++)
                {
                    ;
                }
                return(k - 1);
            }
            else
            {
                for (k = 0, N = nEntries(); k < N && _current_entry_id != entry(k).id(); k++)
                {
                    ;
                }
                if (k == N)
                {
                    return(N - 1);
                }
                else
                {
                    CueSheetEntry e = entry(k);
                    Hyena.Log.Information("offset=" + e.offset() + ", endoffset=" + e.end_offset() + " offset=" + _offset);
                    if (_offset < e.offset())
                    {
                        return(k - 1);
                    }
                    else if (e.end_offset() <= 0.0)                         // end track, we don't know
                    {
                        return(k);
                    }
                    else if (_offset >= e.end_offset())
                    {
                        return(k + 1);
                    }
                    else
                    {
                        return(k);
                    }
                }
            }
        }
Example #3
0
 void writeEntry(StreamWriter wrt, CueSheetEntry e, int i)
 {
     indent = "  ";
     wrtl_track(wrt, i + 1);
     indent = "    ";
     wrtl(wrt, "title", e.title());
     wrtl(wrt, "performer", e.performer());
     wrtl(wrt, "piece", e.getPiece(), true);
     wrtl(wrt, "composer", e.getComposer(), true);
     wrtl_index(wrt, 1, e.offset());
 }
 void writeEntry(StreamWriter wrt,CueSheetEntry e,int i)
 {
     indent="  ";
     wrtl_track(wrt,i+1);
     indent="    ";
     wrtl (wrt,"title",e.title ());
     wrtl (wrt,"performer",e.performer ());
     wrtl (wrt,"piece",e.getPiece (),true);
     wrtl (wrt,"composer",e.getComposer (),true);
     wrtl_index(wrt,1,e.offset ());
 }
        public void iLoad(StreamReader sr)
        {
            _composer="";
            _year="";
            _subtitle="";
            _cddbId="";

            Boolean _in_tracks=false;
            string e_perf="";
            string e_title="";
            double e_offset=-1.0;
            string e_piece="";
            string e_composer="";
            string aaid="";
            int nr=0;

            //string filename=_cuefile;
            string directory=_directory;

            string line = "";
            while ((line = sr.ReadLine()) != null) {
                line=line.Trim ();
                if (line!="") {
                    //Console.WriteLine ("it="+_in_tracks+", "+line);
                    if (!_in_tracks) {
                        if (eq(line,"performer")) {
                            _performer=unquote(line.Substring (9).Trim ());
                        } else if (eq(line,"title")) {
                            _title=unquote(line.Substring (5).Trim ());
                        } else if (eq(line,"file")) {
                            _music_file_name=line.Substring (4).Trim ();
                            Match m=Regex.Match (_music_file_name,"([\"][^\"]+[\"])");
                            _music_file_name=m.ToString ();
                            _music_file_name=unquote(_music_file_name).Trim ();
                            _music_file_name=Tools.makefile(directory,_music_file_name);
                        } else if (line.Substring(0,5).ToLower ()=="track") {
                            _in_tracks=true;
                        } else if (eq(line,"rem")) {
                            //Hyena.Log.Information (line);
                            line=line.Substring (3).Trim ();
                            if (eq(line,"image")) {
                                _image_file_name=line.Substring (5).Trim ();
                                _image_file_name=unquote(_image_file_name).Trim ();
                                _img_full_path=Tools.makefile(directory,_image_file_name);
                            } else if (eq (line,"composer")) {
                                _composer=unquote(line.Substring (8).Trim ());
                            } else if (eq (line,"subtitle")) {
                                _subtitle=unquote(line.Substring (8).Trim ());
                            } else if (eq (line,"year")) {
                                _year=unquote(line.Substring (4).Trim ());
                            } else if (eq (line,"cddbid")) {
                                _cddbId=unquote(line.Substring (6).Trim ());
                            }
                        }
                    }

                    if (_in_tracks) {
                        if (aaid=="") { aaid=getArtId (); }

                        //Console.WriteLine ("line="+line);
                        if (eq(line,"track")) {
                            if (e_offset>=0) {
                                nr+=1;
                                CueSheetEntry e=new CueSheetEntry(this,_music_file_name,aaid,nr,-1,e_title,e_perf,_title,e_offset);
                                e.setComposer (e_composer);
                                e.setPiece (e_piece);
                                append (e);
                                if (nr>1) {
                                    CueSheetEntry ePrev;
                                    ePrev=this.entry (nr-2);
                                    ePrev.setLength(e.offset ()-ePrev.offset());
                                }
                            }
                            e_perf=_performer;
                            e_title="";
                            e_composer=_composer;
                            e_offset=-1.0;
                        } else if (eq(line,"title")) {
                            e_title=unquote(line.Substring (5).Trim ());
                        } else if (eq(line,"performer")) {
                            e_perf=unquote(line.Substring (9).Trim ());
                        } else if (eq(line,"rem")) {
                            line=line.Substring (3).Trim ();
                            if (eq (line,"composer")) {
                                e_composer=unquote(line.Substring (8).Trim ());
                            } else if (eq(line,"piece")) {
                                e_piece=unquote(line.Substring (5).Trim ());
                            }
                        } else if (eq(line,"index")) {
                            string s=line.Substring (5).Trim ();
                            s=Regex.Replace (s,"^\\s*[0-9]+\\s*","");
                            string []parts=Regex.Split(s,"[:]");
                            int min=Convert.ToInt32(parts[0]);
                            int secs=Convert.ToInt32(parts[1]);
                            int hsecs=Convert.ToInt32(parts[2]);
                            e_offset=min*60+secs+(hsecs/100.0);
                        }
                    }
                }
            }
            //Console.WriteLine ("Last entry adding");
            if (e_offset>=0) {
                nr+=1;
                CueSheetEntry e=new CueSheetEntry(this,_music_file_name,aaid,nr,-1,e_title,e_perf,_title,e_offset);
                e.setComposer (e_composer);
                e.setPiece (e_piece);
                append (e);
                if (nr>1) {
                    CueSheetEntry ePrev;
                    ePrev=this.entry (nr-2);
                    ePrev.setLength(e.offset ()-ePrev.offset());
                }
            }
            //Console.WriteLine ("Last entry added");

            {
                int i;
                for(i=0;i<nEntries();i++) {
                    entry (i).setNrOfTracks(nr);
                }
                //Console.WriteLine ("Ready");
            }

            base.Selection.MaxIndex=nEntries ();
        }
Example #6
0
        public void iLoad(StreamReader sr)
        {
            _composer = "";
            _year     = "";
            _subtitle = "";
            _cddbId   = "";

            Boolean _in_tracks = false;
            string  e_perf     = "";
            string  e_title    = "";
            double  e_offset   = -1.0;
            string  e_piece    = "";
            string  e_composer = "";
            string  aaid       = "";
            int     nr         = 0;

            //string filename=_cuefile;
            string directory = _directory;

            string line = "";

            while ((line = sr.ReadLine()) != null)
            {
                line = line.Trim();
                if (line != "")
                {
                    //Console.WriteLine ("it="+_in_tracks+", "+line);
                    if (!_in_tracks)
                    {
                        if (eq(line, "performer"))
                        {
                            _performer = unquote(line.Substring(9).Trim());
                        }
                        else if (eq(line, "title"))
                        {
                            _title = unquote(line.Substring(5).Trim());
                        }
                        else if (eq(line, "file"))
                        {
                            _music_file_name = line.Substring(4).Trim();
                            Match m = Regex.Match(_music_file_name, "([\"][^\"]+[\"])");
                            _music_file_name = m.ToString();
                            _music_file_name = unquote(_music_file_name).Trim();
                            _music_file_name = Tools.makefile(directory, _music_file_name);
                        }
                        else if (line.Substring(0, 5).ToLower() == "track")
                        {
                            _in_tracks = true;
                        }
                        else if (eq(line, "rem"))
                        {
                            //Hyena.Log.Information (line);
                            line = line.Substring(3).Trim();
                            if (eq(line, "image"))
                            {
                                _image_file_name = line.Substring(5).Trim();
                                _image_file_name = unquote(_image_file_name).Trim();
                                _img_full_path   = Tools.makefile(directory, _image_file_name);
                            }
                            else if (eq(line, "composer"))
                            {
                                _composer = unquote(line.Substring(8).Trim());
                            }
                            else if (eq(line, "subtitle"))
                            {
                                _subtitle = unquote(line.Substring(8).Trim());
                            }
                            else if (eq(line, "year"))
                            {
                                _year = unquote(line.Substring(4).Trim());
                            }
                            else if (eq(line, "cddbid"))
                            {
                                _cddbId = unquote(line.Substring(6).Trim());
                            }
                        }
                    }


                    if (_in_tracks)
                    {
                        if (aaid == "")
                        {
                            aaid = getArtId();
                        }

                        //Console.WriteLine ("line="+line);
                        if (eq(line, "track"))
                        {
                            if (e_offset >= 0)
                            {
                                nr += 1;
                                CueSheetEntry e = new CueSheetEntry(this, _music_file_name, aaid, nr, -1, e_title, e_perf, _title, e_offset);
                                e.setComposer(e_composer);
                                e.setPiece(e_piece);
                                append(e);
                                if (nr > 1)
                                {
                                    CueSheetEntry ePrev;
                                    ePrev = this.entry(nr - 2);
                                    ePrev.setLength(e.offset() - ePrev.offset());
                                }
                            }
                            e_perf     = _performer;
                            e_title    = "";
                            e_composer = _composer;
                            e_offset   = -1.0;
                        }
                        else if (eq(line, "title"))
                        {
                            e_title = unquote(line.Substring(5).Trim());
                        }
                        else if (eq(line, "performer"))
                        {
                            e_perf = unquote(line.Substring(9).Trim());
                        }
                        else if (eq(line, "rem"))
                        {
                            line = line.Substring(3).Trim();
                            if (eq(line, "composer"))
                            {
                                e_composer = unquote(line.Substring(8).Trim());
                            }
                            else if (eq(line, "piece"))
                            {
                                e_piece = unquote(line.Substring(5).Trim());
                            }
                        }
                        else if (eq(line, "index"))
                        {
                            string s = line.Substring(5).Trim();
                            s = Regex.Replace(s, "^\\s*[0-9]+\\s*", "");
                            string [] parts = Regex.Split(s, "[:]");
                            int       min   = Convert.ToInt32(parts[0]);
                            int       secs  = Convert.ToInt32(parts[1]);
                            int       hsecs = Convert.ToInt32(parts[2]);
                            e_offset = min * 60 + secs + (hsecs / 100.0);
                        }
                    }
                }
            }
            //Console.WriteLine ("Last entry adding");
            if (e_offset >= 0)
            {
                nr += 1;
                CueSheetEntry e = new CueSheetEntry(this, _music_file_name, aaid, nr, -1, e_title, e_perf, _title, e_offset);
                e.setComposer(e_composer);
                e.setPiece(e_piece);
                append(e);
                if (nr > 1)
                {
                    CueSheetEntry ePrev;
                    ePrev = this.entry(nr - 2);
                    ePrev.setLength(e.offset() - ePrev.offset());
                }
            }
            //Console.WriteLine ("Last entry added");

            {
                int i;
                for (i = 0; i < nEntries(); i++)
                {
                    entry(i).setNrOfTracks(nr);
                }
                //Console.WriteLine ("Ready");
            }

            base.Selection.MaxIndex = nEntries();
        }