File Coverage

blib/lib/DCOP/Amarok/Playlist.pm
Criterion Covered Total %
statement 15 62 24.1
branch n/a
condition 1 3 33.3
subroutine 4 24 16.6
pod 21 21 100.0
total 41 110 37.2


line stmt bran cond sub pod time code
1             package DCOP::Amarok::Playlist;
2              
3 1     1   25227 use 5.008001;
  1         4  
  1         45  
4 1     1   7 use strict;
  1         2  
  1         40  
5 1     1   6 use warnings;
  1         7  
  1         6554  
6              
7             require DCOP::Amarok;
8              
9             our @ISA = qw(DCOP::Amarok);
10              
11             our $VERSION = '0.009';
12              
13             =head1 NAME
14              
15             DCOP::Amarok::Playlist - Perl extension to speak to an amaroK player object via system's DCOP.
16              
17             =head1 SYNOPSIS
18              
19             use DCOP::Amarok::Playlist;
20             $playlist = DCOP::Amarok::Playlist->new();
21              
22             $playlist->togglePlaylist();
23             print $playlist->getActiveIndex();
24              
25             =head1 DESCRIPTION
26              
27             This module is a quick hack to get an interface between perl and Kde's DCOP,
28             since Kde3.4's perl bindings are disabled. This suite talks to 'dcop'.
29             DCOP::Amarok::Playlist talks directly to the playlist object of amaroK.
30              
31             =head1 EXPORT
32              
33             None by default.
34              
35             =head1 METHODS
36              
37             =item new()
38              
39             Constructor. No arguments needed. If the program will be run remotely, the
40             need for 'user => "myusername"' arises.
41              
42             =cut
43              
44             sub new() {
45 1     1 1 81 my $proto = shift;
46 1   33     9 my $class = ref( $proto ) || $proto;
47 1         4 my %params = @_;
48 1         12 my $self = $class->SUPER::new( %params, control => "playlist" );
49 1         3833 bless( $self, $class );
50 1         24 return $self;
51             }
52              
53             =item interfaces()
54              
55             Returns a list of the interfaces.
56              
57             =cut
58              
59             sub interfaces() {
60 0     0 1   my $self = shift;
61 0           return $self->run( "interfaces" );
62             }
63              
64             =item functions()
65              
66             Returns a list of the functions.
67              
68             =cut
69              
70             sub functions() {
71 0     0 1   my $self = shift;
72 0           return $self->run( "functions" );
73             }
74              
75             =item getActiveIndex()
76              
77             Returns the number of the active index.
78              
79             =cut
80              
81             sub getActiveIndex() {
82 0     0 1   my $self = shift;
83 0           return $self->run( "getActiveIndex" );
84             }
85              
86             =item getTotalTrackCount()
87              
88             Returns the total number of tracks in the playlist.
89              
90             =cut
91              
92             sub getTotalTrackCount() {
93 0     0 1   my $self = shift;
94 0           return $self->run( "getTotalTrackCount" );
95             }
96              
97             =item saveCurrentPlaylist()
98              
99             Makes the object save the present list.
100             Returns the path.
101              
102             =cut
103              
104             sub saveCurrentPlaylist() {
105 0     0 1   my $self = shift;
106 0           return $self->run( "saveCurrentPlaylist" );
107             }
108              
109             =item addMedia($URL)
110              
111             Adds new media.
112              
113             =cut
114              
115             sub addMedia() {
116 0     0 1   my $self = shift;
117 0           while ( @_ ) {
118 0           $self->run( "addMedia", "$_" );
119             }
120             }
121              
122             =item addMediaList()
123              
124             Adds new media.
125              
126             =cut
127              
128             sub addMediaList() {
129 0     0 1   my $self = shift;
130 0           $self->run( "addMediaList", @_ );
131             }
132              
133             =item clearPlaylist()
134              
135              
136             =cut
137              
138             sub clearPlaylist() {
139 0     0 1   my $self = shift;
140 0           $self->run( "clearPlaylist" );
141             }
142              
143             =item playByIndex($index)
144              
145             Plays the song in the $index position.
146              
147             =cut
148              
149             sub playByIndex() {
150 0     0 1   my $self = shift;
151 0           my $index = shift;
152 0           $self->run( "playByIndex", "$index" );
153             }
154              
155             =item playMedia($uri)
156              
157             Play a specific object.
158              
159             =cut
160              
161             sub playMedia() {
162 0     0 1   my $self = shift;
163 0           my $url = shift;
164 0           $self->run( "playMedia", "$url" );
165             }
166              
167             =item popupMessage($msg)
168              
169             Pops up $msg in screen.
170             TODO: $msg has to escape white spaces with '\'.
171             e.g. "Hi\\\ there";
172             e.g2. 'I\ am\ here'
173              
174             =cut
175              
176             sub popupMessage() {
177 0     0 1   my $self = shift;
178 0           my $msg = shift;
179 0           $self->run( "popupMessage", "$msg" );
180             }
181              
182             =item removeCurrentTrack()
183              
184             Removes current track from playlist
185              
186             =cut
187              
188             sub removeCurrentTrack() {
189 0     0 1   my $self = shift;
190 0           $self->run( "removeCurrentTrack" );
191             }
192              
193             =item repopulate()
194              
195             Repopulate playlist.
196              
197             =cut
198              
199             sub repopulate() {
200 0     0 1   my $self = shift;
201 0           $self->run( "repopulate" );
202             }
203              
204             =item saveM3uRelative($path)
205              
206             Saves the M3U file with a relavtive path.
207              
208             =cut
209              
210             sub saveM3uRelative() {
211 0     0 1   my $self = shift;
212 0           my $path = shift;
213 0           $self->run( "saveM3u", "$path", "1" );
214             }
215              
216             =item saveM3uAbsolute($path)
217              
218             Saves the M3U file with an absolut path.
219              
220             =cut
221              
222             sub saveM3uAbsolute() {
223 0     0 1   my $self = shift;
224 0           my $path = shift;
225 0           $self->run( "saveM3u", "$path", "0" );
226             }
227              
228             =item setStopAfterCurrent()
229              
230             Enable StopAfterCurrent track.
231              
232             =cut
233              
234             sub setStopAfterCurrent() {
235 0     0 1   my $self = shift;
236 0           $self->run( "setStopAfterCurrent", "1" );
237             }
238              
239             =item notStopAfterCurrent()
240              
241             Disable StopAfterCurrent track.
242              
243             =cut
244              
245             sub notStopAfterCurrent() {
246 0     0 1   my $self = shift;
247 0           $self->run( "setStopAfterCurrent", "0" );
248             }
249              
250             =item shortStatusMessage($msg)
251              
252             Display $msg in the status bar.
253              
254             =cut
255              
256             sub shortStatusMessage() {
257 0     0 1   my $self = shift;
258 0           my $msg = shift;
259 0           $self->run( "shortStatusMessage", "$msg" );
260             }
261              
262             =item shufflePlaylist()
263              
264             Shuffle playlist.
265              
266             =cut
267              
268             sub shufflePlaylist() {
269 0     0 1   my $self = shift;
270 0           $self->run( "shufflePlaylist" );
271             }
272              
273             =item togglePlaylist()
274              
275             Show/Hide playlist.
276              
277             =cut
278              
279             sub togglePlaylist() {
280 0     0 1   my $self = shift;
281 0           $self->run( "togglePlaylist" );
282             }
283              
284             1;
285              
286             __END__