Exemple #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());
     }
 }
Exemple #2
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();
        }