1 /***
2 * Ambient - A music player for the Android platform
3 Copyright (C) 2007 Martin Vysny
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package sk.baka.ambient.playerservice;
19
20 import sk.baka.ambient.collection.TrackOriginEnum;
21
22 /***
23 * Listens for events produced by the {@link PlayerService}. Events are invoked
24 * in the message handler loop.
25 *
26 * @author Martin Vysny
27 */
28 public interface IPlayerListener {
29 /***
30 * <p>
31 * The playback was stopped (not paused). This may be caused by:
32 * </p>
33 * <ul>
34 * <li>the song playback finished</li>
35 * <li>an error occurred</li>
36 * </ul>
37 * <p>
38 * but never by
39 * </p>
40 * <ul>
41 * <li>{@link IPlayer#stop()} invocation</li>
42 * </ul>
43 *
44 * @param error
45 * if not <code>null</code> then the player stopped because of an
46 * unspecified error.
47 * @param errorMissing
48 * if <code>true</code> then the error occurred because the file
49 * is missing.
50 * @param origin
51 * the track origin
52 */
53 void stopped(final String error, final boolean errorMissing,
54 final TrackOriginEnum origin);
55
56 /***
57 * Player started to play the song. Invoked shortly after the playback order
58 * is issued.
59 *
60 * @param file
61 * the file
62 * @param duration
63 * the file duration in ms. May be 0 if the stream is endless or
64 * the duration is not known.
65 * @param currentPosition
66 * current playback position, in ms.
67 */
68 void started(final String file, final int duration,
69 final int currentPosition);
70
71 /***
72 * Track was switched while a radio is playing.
73 *
74 * @param name
75 * the new track name.
76 */
77 void radioNewTrack(final String name);
78
79 /***
80 * How much data is currently buffered. Applies only to online content,
81 * invoked with 0 when playing local tracks.
82 *
83 * @param percent
84 * how much the buffer is filled up. 0-100.
85 */
86 void buffered(byte percent);
87 }