1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io.audio;
|
---|
3 |
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.net.URL;
|
---|
6 |
|
---|
7 | import org.openstreetmap.josm.io.audio.AudioPlayer.Execute;
|
---|
8 | import org.openstreetmap.josm.io.audio.AudioPlayer.State;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Sound player interface. Implementations can be backed up by Java Sound API or Java FX Media API.
|
---|
12 | * @since 12328
|
---|
13 | */
|
---|
14 | public interface SoundPlayer {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Ask player to play a new media.
|
---|
18 | * @param command Command containing media information
|
---|
19 | * @param stateChange the previous state
|
---|
20 | * @param playingUrl the currently playing URL, if any
|
---|
21 | * @throws AudioException if an audio error occurs
|
---|
22 | * @throws IOException if an I/O error occurs
|
---|
23 | */
|
---|
24 | void play(Execute command, State stateChange, URL playingUrl) throws AudioException, IOException;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Ask player to pause the current playing media.
|
---|
28 | * @param command Command containing media information
|
---|
29 | * @param stateChange the previous state
|
---|
30 | * @param playingUrl the currently playing URL, if any
|
---|
31 | * @throws AudioException if an audio error occurs
|
---|
32 | * @throws IOException if an I/O error occurs
|
---|
33 | */
|
---|
34 | void pause(Execute command, State stateChange, URL playingUrl) throws AudioException, IOException;
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Method called when a media is being played.
|
---|
38 | * @param command Command containing media information
|
---|
39 | * @return {@code true} if the playing call was blocking, and the playback is finished when this method returns
|
---|
40 | * @throws AudioException if an audio error occurs
|
---|
41 | * @throws IOException if an I/O error occurs
|
---|
42 | * @throws InterruptedException if the play is interrupted
|
---|
43 | */
|
---|
44 | boolean playing(Execute command) throws AudioException, IOException, InterruptedException;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Returns the media playback position, in seconds.
|
---|
48 | * @return the media playback position, in seconds
|
---|
49 | */
|
---|
50 | double position();
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Returns the media playback speed ratio.
|
---|
54 | * @return the media playback speed ratio
|
---|
55 | */
|
---|
56 | double speed();
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Adds a listener that will be notified of audio playback events.
|
---|
60 | * @param listener audio listener
|
---|
61 | */
|
---|
62 | void addAudioListener(AudioListener listener);
|
---|
63 | }
|
---|