source: josm/trunk/src/org/openstreetmap/josm/actions/audio/AudioPlayPauseAction.java@ 560

Last change on this file since 560 was 547, checked in by david, 16 years ago

much improved audio handling: threaded audio, controls, sync with waypoints

File size: 1.0 KB
Line 
1// License: GPL. Copyright 2008 by David Earl and others
2package org.openstreetmap.josm.actions.audio;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.awt.event.InputEvent;
8import java.awt.event.KeyEvent;
9import java.net.URL;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.actions.JosmAction;
13import org.openstreetmap.josm.tools.AudioPlayer;
14import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
15
16public class AudioPlayPauseAction extends JosmAction {
17
18 public AudioPlayPauseAction() {
19 super(tr("Play/pause"), "audio-playpause", tr("Play/pause audio."), KeyEvent.VK_PERIOD, 0, true);
20 }
21
22 public void actionPerformed(ActionEvent e) {
23 URL url = AudioPlayer.url();
24 try {
25 if (AudioPlayer.paused() && url != null) {
26 AudioPlayer.play(url);
27 } else if (AudioPlayer.playing()){
28 AudioPlayer.pause();
29 } else {
30 // find first audio marker to play
31 MarkerLayer.playAudio();
32 }
33 } catch (Exception ex) {
34 AudioPlayer.audioMalfunction(ex);
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.