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

Last change on this file since 5871 was 5871, checked in by Don-vip, 11 years ago

fix #8611 (audio slower broken) + update all audio javadoc

  • Property svn:eol-style set to native
File size: 1.7 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;
5import static org.openstreetmap.josm.tools.I18n.trc;
6import java.awt.event.ActionEvent;
7import java.awt.event.KeyEvent;
8import java.net.URL;
9
10import org.openstreetmap.josm.actions.JosmAction;
11import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
12import org.openstreetmap.josm.tools.AudioPlayer;
13import org.openstreetmap.josm.tools.Shortcut;
14
15/**
16 * If not playing, play the sound track from the first Audio Marker, or from the point at which it was paused.<br/>
17 * If playing, pause the sound.<br/>
18 * If fast forwarding or slow forwarding, resume normal speed.
19 * @since 547
20 */
21public class AudioPlayPauseAction extends JosmAction {
22
23 /**
24 * Constructs a new {@code AudioPlayPauseAction}.
25 */
26 public AudioPlayPauseAction() {
27 super(trc("audio", "Play/Pause"), "audio-playpause", tr("Play/pause audio."),
28 Shortcut.registerShortcut("audio:pause", tr("Audio: {0}", trc("audio", "Play/Pause")), KeyEvent.VK_PERIOD, Shortcut.DIRECT), true);
29 }
30
31 public void actionPerformed(ActionEvent e) {
32 URL url = AudioPlayer.url();
33 try {
34 if (AudioPlayer.paused() && url != null) {
35 AudioPlayer.play(url);
36 } else if (AudioPlayer.playing()){
37 if (AudioPlayer.speed() != 1.0)
38 AudioPlayer.play(url, AudioPlayer.position());
39 else
40 AudioPlayer.pause();
41 } else {
42 // find first audio marker to play
43 MarkerLayer.playAudio();
44 }
45 } catch (Exception ex) {
46 AudioPlayer.audioMalfunction(ex);
47 }
48 }
49}
Note: See TracBrowser for help on using the repository browser.