コード例 #1
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: video-adder <mp4 file>");
                Console.WriteLine("Adds a video file to all connected devices");
                return;
            }

            string file = args[0];

            foreach (Device device in Device.ListDevices())
            {
                Console.WriteLine("Adding {0} to '{1}'", file, device.Name);
                TrackDatabase db = device.TrackDatabase;

                Track track = db.CreateTrack();
                track.Type     = MediaType.Video;
                track.Artist   = Prompt("Artist: ");
                track.Title    = Prompt("Title: ");
                track.Duration = TimeSpan.Parse(Prompt("Duration (e.g. 2:00:00 for 2 hours): "));
                track.FileName = file;

                Console.Write("Saving...");
                db.Save();
                Console.WriteLine("Done.");
            }
        }
コード例 #2
0
        public override async void Execute(object parameter)
        {
            var track = parameter as TrackItem;

            if (track == null)
            {
                return;
            }
            var trackDatabase = new TrackDatabase();
            // searching the track in the trackcollection
            int i = Locator.MusicLibraryVM.Tracks.IndexOf(track);

            // If the track is favorite, then now it is not
            // if the track was not favorite, now it is
            // updating the Track collection
            Locator.MusicLibraryVM.Tracks[i].Favorite = !(track).Favorite;
            var trackFromArtistCollection = Locator.MusicLibraryVM.Artists.FirstOrDefault(
                x =>
            {
                var trackItem = parameter as TrackItem;
                return(trackItem != null && x.Name == trackItem.ArtistName);
            })
                                            .Albums.FirstOrDefault(y =>
            {
                var item = parameter as TrackItem;
                return(item != null && y.Name == item.AlbumName);
            })
                                            .Tracks.FirstOrDefault(z => z == (parameter as TrackItem));

            // Update Database
            await trackDatabase.Update(Locator.MusicLibraryVM.Tracks[i]);
        }
コード例 #3
0
 public void LoadTrackDatabase(bool createFresh)
 {
     if (track_database == null)
     {
         track_database = new TrackDatabase(this, createFresh);
     }
 }
コード例 #4
0
        public void Save()
        {
            if (track_database != null)
            {
                TrackDatabase.Save();
            }

            if (photo_database != null)
            {
                PhotoDatabase.Save();
            }

            // nothing more to do
            if (equalizers == null)
            {
                return;
            }

            string backup_path = String.Format("{0}.bak", EqualizerDatabasePath);

            try {
                // Back up the eq db
                if (File.Exists(EqualizerDatabasePath))
                {
                    File.Copy(EqualizerDatabasePath, backup_path, true);
                }

                // Save the eq db
                using (BinaryWriter writer = new BinaryWriter(new FileStream(EqualizerDatabasePath, FileMode.Create))) {
                    equalizer_container_record.Save(writer);
                }
            } catch (Exception e) {
                // restore the backup
                File.Copy(backup_path, EqualizerDatabasePath, true);
                throw e;
            }
        }
コード例 #5
0
        public KatatsukiContext(string path)
        {
            if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "katatsuki")))
            {
                Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "katatsuki"));
            }
            this.tracksCache = new TrackDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                              "katatsuki", "tracks.db"));
            this.uiContext = SynchronizationContext.Current;

            this.EnsureDirectory(Path.Combine(path, "Music"));
            this.EnsureDirectory(Path.Combine(path, "Automatically Add to Library"));

            this.TrackLibrary = new Library(Path.Combine(path, "Music\\"));
            this.Watcher      = new TrackboxListener(Path.Combine(path, "Automatically Add to Library\\"));

            this.tracks = new ObservableCollection <Track>(tracksCache.GetAllTracks());
            this.Tracks = new ReadOnlyObservableCollection <Track>(this.tracks);
            this.EnsureDirectory(Path.Combine(this.Watcher.TrackboxPath.FullName, ".notadded"));

            this.TrackLibrary.TrackAddedEvent   += TrackLibrary_TrackAddedEvent;
            this.TrackLibrary.TrackDeletedEvent += TrackLibrary_TrackDeletedEvent;
            this.Watcher.InitAsync();
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Usage();
                return;
            }

            Device        device = new Device(args[1]);
            TrackDatabase db     = device.TrackDatabase;

            switch (args[0])
            {
            case "--dump-files":
                if (args.Length < 3)
                {
                    Console.WriteLine("Destination directory required.");
                    Environment.Exit(1);
                }

                string dest  = args[2];
                int    count = 1;
                int    total = db.Tracks.Count;

                foreach (Track track in db.Tracks)
                {
                    string path = GetTrackPath(dest, track);
                    Console.WriteLine("Copying ({0} of {1}): {2}", count++, total, track);

                    string dir = Path.GetDirectoryName(path);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    File.Copy(track.FileName, path);
                }
                break;

            case "--dump-tracks":
                foreach (Track track in db.Tracks)
                {
                    Console.WriteLine(track);
                }
                break;

            case "--dump-playlists":
                foreach (Playlist playlist in db.Playlists)
                {
                    Console.WriteLine("Playlist: " + playlist.Name);
                    foreach (Track track in playlist.Tracks)
                    {
                        Console.WriteLine("\t" + track);
                    }
                }
                break;

            case "--add-track":
            {
                Track track = db.CreateTrack();
                track.Artist   = "WOO WOO";
                track.Album    = "WOO WOO";
                track.Title    = "WOO WOO";
                track.Duration = new TimeSpan(333 * TimeSpan.TicksPerMillisecond);
                track.FileName = "/tmp/foobar.mp3";
            }
            break;

            case "--remove-track":
                int id = Int32.Parse(args[2]);
                foreach (Track track in db.Tracks)
                {
                    if (track.Id == id)
                    {
                        db.RemoveTrack(track);
                    }
                }
                break;

            case "--clear":
                foreach (Track track in db.Tracks)
                {
                    db.RemoveTrack(track);
                }
                break;

            case "--playcounts":
                foreach (Track track in db.Tracks)
                {
                    Console.WriteLine("{0}: total {1}, latest {2}", track.Title,
                                      track.PlayCount, track.LatestPlayCount);
                }
                break;

            case "--dump-sportkits":
                SportKit[] kits = device.SportKitManager.SportKits;
                Console.WriteLine("{0} sport kits found.", kits.Length);

                for (int i = 0; i < kits.Length; i++)
                {
                    SportKit kit = kits[i];

                    Console.WriteLine("Kit {0}:", i);
                    Console.WriteLine("  ID: {0}", kit.ID);
                    Console.WriteLine("  Path: {0}", kit.Path);

                    // ugly ugly ugly
                    foreach (object[] data in new object[] { new object[] { "Latest Workouts", kit.LatestWorkouts },
                                                             new object[] { "Synched Workouts", kit.SynchedWorkouts } })
                    {
                        Console.WriteLine("  {0}:", data[0]);

                        foreach (Workout w in ((Workout[])data[1]))
                        {
                            Console.WriteLine("   - Workout on {0}:", w.Time);
                            Console.WriteLine("      * FileName: {0}", w.FileName);
                            Console.WriteLine("      * Format Version: {0}", w.Version);
                            Console.WriteLine("      * Name: {0}", w.Name);
                            Console.WriteLine("      * Duration: {0} ({1} min)", w.Duration, w.Duration.TotalMinutes);
                            Console.WriteLine("      * Distance: {0} {1}", w.Distance, w.DistanceUnit);
                            Console.WriteLine("      * Pace: {0}", w.Pace);
                            Console.WriteLine("      * Calories: {0}", w.Calories);
                            Console.WriteLine("      * Template ID: {0}", w.TemplateID);
                            Console.WriteLine("      * Template Name: {0}", w.TemplateName);
                            Console.WriteLine("      * Start Time: {0}", w.StartTime);
                            Console.WriteLine("      * Interval Value: {0}", w.IntervalValue);

                            Console.WriteLine("      * Intervals:");
                            Console.Write("        ");

                            foreach (double interval in w.Intervals)
                            {
                                Console.Write("{0}  ", interval);
                            }

                            Console.WriteLine();
                            Console.WriteLine();
                        }
                    }
                }

                return;

            default:
                Usage();
                break;
            }

            db.Save();
        }
コード例 #7
0
ファイル: Playlist.cs プロジェクト: mono/ipod-sharp
 internal Playlist(TrackDatabase db, PlaylistRecord record)
 {
     this.db = db;
     this.record = record;
 }
コード例 #8
0
ファイル: Playlist.cs プロジェクト: mono/ipod-sharp
 internal Playlist(TrackDatabase db, string title, List<Track> otgtracks)
 {
     this.otgtitle = title;
     this.otgtracks = otgtracks;
 }
コード例 #9
0
 internal Playlist(TrackDatabase db, PlaylistRecord record)
 {
     this.db     = db;
     this.record = record;
 }
コード例 #10
0
 internal Playlist(TrackDatabase db, string title, List <Track> otgtracks)
 {
     this.otgtitle  = title;
     this.otgtracks = otgtracks;
 }
コード例 #11
0
 public void CreateEmptyTrackDatabase()
 {
     track_database = null;
     LoadTrackDatabase(true);
 }
コード例 #12
0
ファイル: Track.cs プロジェクト: mono/ipod-sharp
 internal Track(TrackDatabase db, TrackRecord record)
 {
     this.db = db;
     this.record = record;
 }
コード例 #13
0
 internal Track(TrackDatabase db, TrackRecord record)
 {
     this.db     = db;
     this.record = record;
 }
コード例 #14
0
ファイル: Device.cs プロジェクト: mono/ipod-sharp
 public void LoadTrackDatabase(bool createFresh)
 {
     if (track_database == null)
         track_database = new TrackDatabase (this, createFresh);
 }
コード例 #15
0
ファイル: Device.cs プロジェクト: mono/ipod-sharp
 public void CreateEmptyTrackDatabase()
 {
     track_database = null;
     LoadTrackDatabase (true);
 }