]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - config/mpfire/perl/Audio/MPD/Common/Item/Song.pm
Finalized core13 and redirector fixes
[people/pmueller/ipfire-2.x.git] / config / mpfire / perl / Audio / MPD / Common / Item / Song.pm
CommitLineData
83d20a45
CS
1#
2# This file is part of Audio::MPD::Common
3# Copyright (c) 2007 Jerome Quelin, all rights reserved.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the same terms as Perl itself.
7#
8#
9
10package Audio::MPD::Common::Item::Song;
11
12use strict;
13use warnings;
14
15use overload '""' => \&as_string;
16use Readonly;
17
18use base qw[ Class::Accessor::Fast Audio::MPD::Common::Item ];
19__PACKAGE__->mk_accessors( qw[ Album Artist file id pos Title Track time ] );
20
21#our ($VERSION) = '$Rev: 5645 $' =~ /(\d+)/;
22
23Readonly my $SEP => ' = ';
24
25
26#
27# my $str = $song->as_string;
28#
29# Return a string representing $song. This string will be;
30# - either "Album = Track = Artist = Title"
31# - or "Artist = Title"
32# - or "Title"
33# - or "file"
34# (in this order), depending on the existing tags of the song. The last
35# possibility always exist of course, since it's a path.
36#
37sub as_string {
38 my ($self) = @_;
39
40 return $self->file unless defined $self->Title;
41 my $str = $self->Title;
42 return $str unless defined $self->Artist;
43 $str = $self->Artist . $SEP . $str;
44 return $str unless defined $self->Album && defined $self->Track;
45 return join $SEP,
46 $self->Album,
47 $self->Track,
48 $str;
49}
50
511;
52
53__END__
54
55
56=head1 NAME
57
58Audio::MPD::Common::Item::Song - a song object with some audio tags
59
60
61=head1 DESCRIPTION
62
63C<Audio::MPD::Common::Item::Song> is more a placeholder for a
64hash ref with some pre-defined keys, namely some audio tags.
65
66
67=head1 PUBLIC METHODS
68
69This module has a C<new()> constructor, which should only be called by
70C<Audio::MPD::Common::Item>'s constructor.
71
72The only other public methods are the accessors - see below.
73
74
75=head2 Accessors
76
77The following methods are the accessors to their respective named fields:
78C<Album()>, C<Artist()>, C<file()>, C<id>, C<pos>, C<Title()>, CTTrack()>,
79C<time()>. You can call them either with no arg to get the value, or with
80an arg to replace the current value.
81
82
83=head2 Methods
84
85
86=over 4
87
88=item $song->as_string()
89
90Return a string representing $song. This string will be:
91
92=over 4
93
94=item either "Album = Track = Artist = Title"
95
96=item or "Artist = Title"
97
98=item or "Title"
99
100=item or "file"
101
102=back
103
104(in this order), depending on the existing tags of the song. The last
105possibility always exist of course, since it's a path.
106
107=back
108
109
110=head1 SEE ALSO
111
112=over 4
113
114=item L<Audio::MPD>
115
116=item L<POE::Component::Client::MPD>
117
118=back
119
120
121=head1 AUTHOR
122
123Jerome Quelin, C<< <jquelin at cpan.org> >>
124
125
126=head1 COPYRIGHT & LICENSE
127
128Copyright (c) 2007 Jerome Quelin, all rights reserved.
129
130This program is free software; you can redistribute it and/or modify
131it under the same terms as Perl itself.
132
133=cut