public void Reload()
        {
            _title.Text     = _sheet.title();
            _performer.Text = _sheet.performer();
            _composer.Text  = _sheet.composer();
            _year.Text      = _sheet.year();
            _subtitle.Text  = _sheet.subtitle();

            try {
                _imagefile.SelectFilename(_sheet.imageFullFileName());
                Gdk.Pixbuf pb = new Gdk.Pixbuf(_sheet.imageFullFileName(), 100, 100);
                _image.Pixbuf = pb;
            } catch (System.Exception e) {
                Hyena.Log.Information(e.ToString());
            }
            _store.Clear();
            int i, N;

            for (i = 0, N = _sheet.nEntries(); i < N; i++)
            {
                double b = _sheet.entry(i).offset();
                int    m, s, hs, t;
                t  = (int)(b * 100.0);
                hs = t % 100;
                m  = t / (100 * 60);
                s  = (t / 100) % 60;
                String offset = String.Format("{0:00}", m) + ":" +
                                String.Format("{0:00}", s) + "." +
                                String.Format("{0:00}", hs);
                _store.AppendValues(i + 1, _sheet.entry(i).title(), _sheet.entry(i).performer(),
                                    _sheet.entry(i).getComposer(), _sheet.entry(i).getPiece(), offset);
            }
        }
Example #2
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());
     }
 }
        private void setLatinTags(CueSheet s)
        {
            int i, N;

            for (i = 0, N = s.nEntries(); i < N; i++)
            {
                ProgressCurrentTrack = i + 1;
                setLatinTag(i, s, s.entry(i));
            }
        }
Example #4
0
        public override void Reload()
        {
            store.Clear();
            int i = 0;

            for (i = 0; i < _sheet.nEntries(); i++)
            {
                CueSheetEntry e = _sheet.entry(i);
                store.Add(e);

                /*double l=e.length ();
                 * int t=(int) (l*100.0);
                 * int m=t/(60*100);
                 * int secs=(t/100)%60;
                 * string ln=String.Format ("{0:00}:{0:00}",m,secs);
                 * store.AppendValues (i+1,e.title (),e.getPiece (),e.performer (),e.getComposer(),ln);*/
            }
            base.RaiseReloaded();
        }
Example #5
0
 public void reLoad()
 {
     index = 0;
     try {
         CueSheet sheet = MySource.getSheet();
         //ServiceManager.PlayerEngine.SetAccurateSeek(true);
         CueSheetEntry e = sheet.entry(index);
         _song_id = e.id();
         ServiceManager.PlayerEngine.Open(e);
         ServiceManager.PlayerEngine.Play();
         if (ServiceManager.PlaybackController.Source != MySource)
         {
             ServiceManager.PlaybackController.Source = MySource;
         }
         if (ServiceManager.PlaybackController.NextSource != MySource)
         {
             ServiceManager.PlaybackController.NextSource = MySource;
         }
         //ServiceManager.PlaybackController.SetSeekMode (true);
     } catch (SystemException ex) {
         Hyena.Log.Information(ex.ToString());
     }
     mscount = chgcount - 1;
 }
        //private Stack<DatabaseTrackInfo> stk=new Stack<DatabaseTrackInfo>();
        public void ImportSheet(CueSheet s)
        {
            if (import_manager==null) {
                try {
                    import_manager = new LibraryImportManager (false);
                    /*import_manager.ImportResult+=delegate(object sender,DatabaseImportResultArgs args) {
                        DatabaseTrackInfo trk=args.Track;
                        stk.Push (trk);
                    };*/
                } catch (Exception ex) {
                    Hyena.Log.Error (ex.ToString ());
                }
            }

            Hyena.Log.Debug ("Importsheet: Starting transaction");
            int i,N;
            for(i=0,N=s.nEntries ();i<N;i++) {
                try {
                    CueSheetEntry e=s.entry (i);
                    string file=e.file ();
                    string uuid=Regex.Replace(e.id (),"\\s","_");
                    string ext=".mp3";

                    string uid=Guid.NewGuid ().ToString ();
                    string u1=uid.Substring (0,1);
                    string u2=uid.Substring (0,2);
                    string dir=basedir+"/.banshee/"+u1;
                    if (!Directory.Exists (dir))  {
                        Directory.CreateDirectory(dir);
                    }
                    dir+="/"+u2;
                    if (!Directory.Exists(dir)) {
                        Directory.CreateDirectory(dir);
                    }
                    uuid=dir+"/"+uuid+ext;

                    UnixFileInfo f=new UnixFileInfo(file);
                    if (File.Exists (uuid)) { File.Delete(uuid); }
                    //f.CreateLink (uuid);
                    f.CreateSymbolicLink(uuid);

                    DatabaseTrackInfo trk=import_manager.ImportTrack(uuid);
                    //File.Delete (uuid);
                    /*if (trk==null) {
                        Hyena.Log.Warning ("track = null (file="+e.file ()+")");
                        if (stk.Count>0) { trk=stk.Pop (); }
                    }*/

                    if (trk==null) {
                        Hyena.Log.Error ("track = null (file="+e.file ()+")");
                    } else {
                        Hyena.Log.Information ("track!=null (file="+e.file ()+")");
                        //MySource.DbConnection.BeginTransaction();
                        trk.PartOfCue=1;
                        trk.CueAudioFile=e.file ();
                        trk.AlbumTitle=s.title ();
                        //trk.Album=s.title ();
                        trk.AlbumArtist=s.performer ();
                        trk.Composer=(e.Composer=="") ? s.composer () : e.Composer;
                        //trk.ArtworkId=s.getArtId ();
                        //trk.Artist=
                        trk.ArtistName=(e.performer ()=="") ? s.performer () : e.performer ();
                        trk.TrackTitle=e.title ();
                        trk.TrackNumber=i+1;
                        trk.Genre=s.genre ();
                        trk.BeginOffset=e.BeginOffset;
                        trk.EndOffset=e.EndOffset;
                        //trk.Uri=trk.CueAudioUri;
              						//trk.MediaAttributes = TrackMediaAttributes.ExternalResource;
                        //trk.PrimarySource = ServiceManager.SourceManager.MusicLibrary;

                        trk.Save ();
                        //MySource.DbConnection.CommitTransaction();
                    }
                } catch (Exception ex) {
                    Hyena.Log.Error (ex.ToString ());
                }
            }
            import_manager.NotifyAllSources ();
        }
Example #7
0
        //private Stack<DatabaseTrackInfo> stk=new Stack<DatabaseTrackInfo>();

        public void ImportSheet(CueSheet s)
        {
            if (import_manager == null)
            {
                try {
                    import_manager = new LibraryImportManager(false);

                    /*import_manager.ImportResult+=delegate(object sender,DatabaseImportResultArgs args) {
                     *      DatabaseTrackInfo trk=args.Track;
                     *      stk.Push (trk);
                     * };*/
                } catch (Exception ex) {
                    Hyena.Log.Error(ex.ToString());
                }
            }

            Hyena.Log.Debug("Importsheet: Starting transaction");
            int i, N;

            for (i = 0, N = s.nEntries(); i < N; i++)
            {
                try {
                    CueSheetEntry e    = s.entry(i);
                    string        file = e.file();
                    string        uuid = Regex.Replace(e.id(), "\\s", "_");
                    string        ext  = ".mp3";

                    string uid = Guid.NewGuid().ToString();
                    string u1  = uid.Substring(0, 1);
                    string u2  = uid.Substring(0, 2);
                    string dir = basedir + "/.banshee/" + u1;
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    dir += "/" + u2;
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    uuid = dir + "/" + uuid + ext;

                    UnixFileInfo f = new UnixFileInfo(file);
                    if (File.Exists(uuid))
                    {
                        File.Delete(uuid);
                    }
                    //f.CreateLink (uuid);
                    f.CreateSymbolicLink(uuid);

                    DatabaseTrackInfo trk = import_manager.ImportTrack(uuid);
                    //File.Delete (uuid);

                    /*if (trk==null) {
                     *      Hyena.Log.Warning ("track = null (file="+e.file ()+")");
                     *      if (stk.Count>0) { trk=stk.Pop (); }
                     * }*/

                    if (trk == null)
                    {
                        Hyena.Log.Error("track = null (file=" + e.file() + ")");
                    }
                    else
                    {
                        Hyena.Log.Information("track!=null (file=" + e.file() + ")");
                        //MySource.DbConnection.BeginTransaction();
                        trk.PartOfCue    = 1;
                        trk.CueAudioFile = e.file();
                        trk.AlbumTitle   = s.title();
                        //trk.Album=s.title ();
                        trk.AlbumArtist = s.performer();
                        trk.Composer    = (e.Composer == "") ? s.composer() : e.Composer;
                        //trk.ArtworkId=s.getArtId ();
                        //trk.Artist=
                        trk.ArtistName  = (e.performer() == "") ? s.performer() : e.performer();
                        trk.TrackTitle  = e.title();
                        trk.TrackNumber = i + 1;
                        trk.Genre       = s.genre();
                        trk.BeginOffset = e.BeginOffset;
                        trk.EndOffset   = e.EndOffset;
                        //trk.Uri=trk.CueAudioUri;
                        //trk.MediaAttributes = TrackMediaAttributes.ExternalResource;
                        //trk.PrimarySource = ServiceManager.SourceManager.MusicLibrary;

                        trk.Save();
                        //MySource.DbConnection.CommitTransaction();
                    }
                } catch (Exception ex) {
                    Hyena.Log.Error(ex.ToString());
                }
            }
            import_manager.NotifyAllSources();
        }
Example #8
0
        private int chgcount = 3000 / 100;                         // every 3 seconds
        //private CueSheetEntry     _playing=null;

        public bool PositionDisplay()
        {
            if (ServiceManager.PlaybackController.Source == MySource)
            {
                CueSheet sheet = MySource.getSheet();
                if (sheet != null)
                {
                    mscount += 1;
                    if (mscount > chgcount)
                    {
                        mscount = 0;
                    }

                    // Position if necessary
                    if (_set_position)
                    {
                        _set_position = false;
                        _positioning  = true;
                        ServiceManager.PlayerEngine.Position = _position;
                    }

                    // Do nothing while seeking
                    uint   pos = ServiceManager.PlayerEngine.Position;
                    double p   = ((double)pos) / 1000.0;
                    if (_positioning && pos <= _position)
                    {
                        //Hyena.Log.Information ("seek="+_position+", pos="+pos);
                        // do nothing
                    }
                    else
                    {
                        _positioning = false;
                        // Track number
                        int i = sheet.searchIndex(_song_id, p);
                        if (i != index && i >= 0)
                        {
                            // Handle repeat track
                            if (ServiceManager.PlaybackController.RepeatMode == PlaybackRepeatMode.RepeatSingle)
                            {
                                seekSong(index);
                            }
                            else if (sheet.SheetKind == CueSheet.Kind.PlayList)
                            {
                                index = i;
                                seekSong(i);
                            }
                            // Every 2 seconds
                            if (mscount == 0)
                            {
                                Hyena.Log.Information("Found index i=" + i + ", songid=" + _song_id);
                                index = i;
                                CueSheetEntry e = sheet.entry(index);
                                Hyena.Log.Information("current entry: " + e);
                                //ServiceManager.PlayerEngine.SetCurrentTrack (e);
                            }
                        }

                        if (mscount == 0 && index >= 0)
                        {
                            Hyena.Log.Information("mscount=" + mscount + ", index=" + index);
                            //view.ScrollTo(index);
                            view.Selection.QuietUnselect(view.Selection.FirstIndex);
                            view.Selection.Select(index);
                        }
                    }
                }
            }
            return(true);
        }
Example #9
0
        public override void Reload()
        {
            _filteredList.Clear();
            List <CueSheet> s = MySource.getSheets();
            int             i, N;
            string          artist = "";

            if (_artist != null)
            {
                artist = Loosely.prepare(_artist.Name);
            }
            string composer = "";

            if (_composer != null)
            {
                composer = Loosely.prepare(_composer.Name);
            }
            for (i = 0, N = s.Count; i < N; i++)
            {
                bool do_add = true;
                if (_genre != null)
                {
                    if (s[i].genre() != _genre.Genre)
                    {
                        do_add = false;
                    }
                }
                if (_artist != null && do_add)
                {
                    if (!Loosely.eqp(artist, s[i].performer()))
                    {
                        do_add = false;
                    }
                }
                if (_composer != null && do_add)
                {
                    if (!Loosely.eqp(composer, s[i].composer()))
                    {
                        do_add = false;
                    }
                }
                if (_album_search != null && do_add)
                {
                    if (!s[i].title().ToLower().Contains(_album_search) &&
                        !s[i].performer().ToLower().Contains(_album_search) &&
                        !s[i].composer().ToLower().Contains(_album_search))
                    {
                        if (_also_in_tracks)
                        {
                            CueSheet q = s[i];
                            int      k, M;
                            bool     can_add = false;
                            for (k = 0, M = q.nEntries(); k < M && !can_add; k++)
                            {
                                CueSheetEntry e = q.entry(k);
                                if (e.title().ToLower().Contains(_album_search) ||
                                    e.performer().ToLower().Contains(_album_search) ||
                                    e.getComposer().ToLower().Contains(_album_search))
                                {
                                    can_add = true;
                                }
                            }
                            do_add = can_add;
                        }
                        else
                        {
                            do_add = false;
                        }
                    }
                }

                if (do_add)
                {
                    _filteredList.Add(new CS_AlbumInfo(s[i]));
                }
            }
            _filteredList.Sort(new CS_AlbumInfo.Comparer());
            base.RaiseReloaded();
        }
 private void setLatinTags(CueSheet s)
 {
     int i,N;
     for(i=0,N=s.nEntries ();i<N;i++) {
         ProgressCurrentTrack=i+1;
         setLatinTag (i,s,s.entry (i));
     }
 }