Beispiel #1
0
        public PlaylistItem(MPDSongResponseBlock block, DataModel dataModel)
        {
            Path = new Path(block.File);
            Position = block.Pos;
            Id = block.Id;

            if (Path.IsStream())
            {
                Artist = null;
                Album = null;
                AudioStream stream = dataModel.StreamsCollection.StreamByPath(Path);

                if (stream != null)
                {
                    Title = stream.Label;
                }
                else
                {
                    Title = block.Name ?? Path.ToString();
                }
            }
            else
            {
                Title = block.Title;
                Album = block.Album;

                if (Settings.Default.UseAlbumArtist)
                {
                    Artist = block.AlbumArtist ?? block.Artist;
                }

                Artist = block.Artist;
            }
        }
Beispiel #2
0
 public static AudioStream CreateAudioStream(Path path, string label, MPDSongResponseBlock block)
 {
     AudioStream result = new AudioStream(path, label);
     result.Title = block.Title;
     result.Name = block.Name;
     return result;
 }
Beispiel #3
0
        public PlaylistItem(MPDSongResponseBlock block, DataModel dataModel)
        {
            Path     = new Path(block.File);
            Position = block.Pos;
            Id       = block.Id;

            if (Path.IsStream())
            {
                Artist = null;
                Album  = null;
                AudioStream stream = dataModel.StreamsCollection.StreamByPath(Path);

                if (stream != null)
                {
                    Title = stream.Label;
                }
                else
                {
                    Title = block.Name ?? Path.ToString();
                }
            }
            else
            {
                Title = block.Title ?? Path.Filename;
                Album = block.Album;

                if (Settings.Default.UseAlbumArtist)
                {
                    Artist = block.AlbumArtist ?? block.Artist;
                }

                Artist = block.Artist;
            }
        }
Beispiel #4
0
        public static AudioStream CreateAudioStream(Path path, string label, MPDSongResponseBlock block)
        {
            AudioStream result = new AudioStream(path, label);

            result.Title = block.Title;
            result.Name  = block.Name;
            return(result);
        }
Beispiel #5
0
 public static Link CreateLink(Path path, MPDSongResponseBlock block)
 {
     Link result = new Link(path);
     result.Title = block.Title;
     result.Artist = block.Artist;
     result.Album = block.Album;
     result.Date = block.Date;
     return result;
 }
Beispiel #6
0
        public static Link CreateLink(Path path, MPDSongResponseBlock block)
        {
            Link result = new Link(path);

            result.Title  = block.Title;
            result.Artist = block.Artist;
            result.Album  = block.Album;
            result.Date   = block.Date;
            return(result);
        }
Beispiel #7
0
        public static Playable FetchSongOrCreateLink(Path path, MPDSongResponseBlock block, Database database)
        {
            Song song = null;

            if (database.Songs.TryGetValue(path, out song))
            {
                return(song);
            }
            else
            {
                return(CreateLink(path, block));
            }
        }
Beispiel #8
0
        public static Song FetchSong(Path path, MPDSongResponseBlock block, Database database)
        {
            Song song = null;

            if (database.Songs.TryGetValue(path, out song))
            {
                return song;
            }
            else
            {
                throw new Exception("PlayableFactory.FetchSong(): expected to find \"" + block.File + "\" in library, didn't.");
            }
        }
Beispiel #9
0
        public static Playable CreatePlayable(MPDSongResponseBlock block, DataModel dataModel = null)
        {
            Path path = new Path(block.File);

            if (path.IsStream())
            {
                return CreateAudioStream(path, null, block);
            }
            else if (dataModel == null || !path.IsLocal())
            {
                return CreateLink(path, block);
            }

            return FetchSong(path, block, dataModel.Database);
        }
Beispiel #10
0
        public Song(MPDSongResponseBlock block)
        {
            Path = new Path(block.File);
            Title = block.Title;
            Length = block.Time;
            Track = block.Track;
            Length = block.Time;
            Filename = Path.Directories.Last();

            // These need to be set by the caller as they require external external objects.
            Artist = null;
            Album = null;
            Genre = null;
            Date = null;
            Directory = null;
        }
Beispiel #11
0
        public Song(MPDSongResponseBlock block)
        {
            Path         = new Path(block.File);
            Title        = block.Title;
            Length       = block.Time;
            Track        = block.Track;
            Length       = block.Time;
            LastModified = block.LastModified ?? DateTime.MinValue;

            // These need to be set by the caller as they require external external objects.
            Artist    = null;
            Album     = null;
            Genre     = null;
            Date      = null;
            Directory = null;
        }
Beispiel #12
0
        public static Playable CreatePlayable(MPDSongResponseBlock block, DataModel dataModel = null)
        {
            Path path = new Path(block.File);

            if (path.IsStream())
            {
                return(CreateAudioStream(path, null, block));
            }
            else if (dataModel != null && path.IsLocal())
            {
                return(FetchSongOrCreateLink(path, block, dataModel.Database));
            }
            else
            {
                return(CreateLink(path, block));
            }
        }