4 package Audio
::MPD
::Common
::Item
::Song
;
5 # ABSTRACT: a song object with some audio tags
10 use base
qw{ Audio
::MPD
::Common
::Item
};
11 use overload
'""' => \
&as_string
;
13 Readonly
my $SEP => ' = ';
28 Last modification date of the song
.
32 Path to the song
. Only attribute which will always be
defined.
40 Id of the song
in MPD
's database.
44 Position of the song in the playlist.
52 Track number of the song.
56 Length of the song in seconds.
60 has album => ( is=>'ro
', isa=>'Str
' );
61 has artist => ( is=>'ro
', isa=>'Str
' );
62 has date => ( is=>'ro
', isa=>'Int
' );
63 has file => ( is=>'ro
', isa=>'Str
', required=>1 );
64 has genre => ( is=>'ro
', isa=>'Str
' );
65 has id => ( is=>'ro
', isa=>'Int
' );
66 has pos => ( is=>'ro
', isa=>'Int
' );
67 has title => ( is=>'ro
', isa=>'Str
' );
68 has track => ( is=>'ro
', isa=>'Int
' );
69 has time => ( is=>'ro
', isa=>'Int
' );
74 =method my $str = $song->as_string;
76 Return a string representing $song. This string will be:
80 =item either "album = track = artist = title"
82 =item or "artist = title"
90 (in this order), depending on the existing tags of the song. The last
91 possibility always exist of course, since it's a path
.
93 This method is also used to automatically stringify the C
<$song>.
100 return $self->file unless defined $self->title;
101 my $str = $self->title;
102 return $str unless defined $self->artist;
103 $str = $self->artist . $SEP . $str;
104 return $str unless defined $self->album && defined $self->track;
116 L<Audio::MPD::Common::Item::Song> is more a placeholder with some
117 attributes. Those attributes are taken from the song tags, so some of
118 them can be empty depending on the file.
120 The constructor should only be called by L<Audio::MPD::Common::Item>'s