Changeset 21779 in osm for applications
- Timestamp:
- 2010-06-18T20:14:22+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/GpsPlayer.java
r21656 r21779 91 91 } 92 92 93 //wal k waypoints forward/backward 94 public void jumpRel(int k) 95 { 96 97 if ((ls.indexOf(curr)+k>0)&&(ls.indexOf(curr)<ls.size())) //check range 98 { 99 jump(ls.get(ls.indexOf(curr)+k)); 100 } 101 Main.map.mapView.repaint(); 102 } 103 93 104 //select the k-th waypoint 94 105 public void jump(int k) 95 106 { 96 if ((ls.indexOf(curr)+k>0)&&(ls.indexOf(curr)<ls.size())) 97 { 98 jump(ls.get(ls.indexOf(curr)+k)); //FIXME here is a bug 99 } 107 if (k>0) 108 { 109 if ((ls.indexOf(curr)+k>0)&&(ls.indexOf(curr)<ls.size())) //check range 110 { 111 jump(ls.get(k)); 112 } 113 Main.map.mapView.repaint(); 114 } 100 115 } 101 116 … … 294 309 public long getRelativeTime() 295 310 { 296 return curr.getTime().getTime()-start.getTime().getTime(); //TODO assumes timeintervall is constant!!!! 311 return getRelativeTime(curr); 312 } 313 314 public long getRelativeTime(WayPoint p) 315 { 316 return p.getTime().getTime()-start.getTime().getTime(); //TODO assumes timeintervall is constant!!!! 297 317 } 298 318 299 319 //jumps to a specific time 300 320 public void jump(long relTime) { 301 int pos = (int) (relTime/1000);//TODO ugly quick hack 302 jump(pos); 303 321 int pos = Math.round(relTime/1000);//TODO ugly quick hack 322 jump(pos); 304 323 } 305 324 306 325 //toggles walking along the track 307 326 public void play() 308 { 327 { /* 309 328 if (t==null) 310 329 { … … 329 348 t.cancel(); 330 349 t=null; 331 } 350 }*/ 332 351 } 333 352 … … 340 359 this.autoCenter=b; 341 360 } 361 362 public List<WayPoint> getTrack() 363 { 364 return ls; 365 } 342 366 343 367 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PlayerObserver.java
r21656 r21779 3 3 //an Interface for communication for both players 4 4 public interface PlayerObserver { 5 void paused(); 6 void start_playing(); 7 void jumping(long relTime); 8 void changeSpeed(float ratio); 5 void playing(long time); 6 void jumping(long time); 9 7 10 8 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PositionLayer.java
r21656 r21779 8 8 import java.util.Collection; 9 9 import java.util.Date; 10 import java.util.HashSet; 10 11 import java.util.Iterator; 11 12 import java.util.LinkedList; 12 13 import java.util.List; 13 14 import java.util.ListIterator; 15 import java.util.Set; 14 16 import java.util.Timer; 15 17 import java.util.TimerTask; … … 53 55 //Basic rendering and GPS layer interaction 54 56 public class PositionLayer extends Layer implements MouseListener,MouseMotionListener { 57 private static Set<PlayerObserver> observers = new HashSet<PlayerObserver>(); //we have to implement our own Observer pattern 55 58 private List<WayPoint> ls; 56 59 public GpsPlayer player; … … 67 70 this.ls=ls; 68 71 player= new GpsPlayer(ls); 69 70 icon=ImageProvider.get("videomapping.png"); 72 icon = new ImageIcon("images/videomapping.png"); 71 73 mins = new SimpleDateFormat("hh:mm:ss:S"); 72 74 ms= new SimpleDateFormat("mm:ss"); … … 84 86 @Override 85 87 public Object getInfoComponent() { 86 return tr("{0} covers {1}% of GPS track",gps.getVideo().getName(),gps.getCoverage()*10); 88 String temp; 89 String sep=System.getProperty("line.separator"); 90 temp=tr("{0} {1}% of GPS track",gps.getVideo().getName(),gps.getCoverage()*10+sep); 91 temp=temp+gps.getNativePlayerInfos(); 92 return temp; 87 93 } 88 94 … … 129 135 p = Main.map.mapView.getPoint(n.getEastNorth()); 130 136 g.drawOval(p.x - 2, p.y - 2, 4, 4); 131 } 132 //draw surrounding points 137 } 138 //draw synced points 139 g.setColor(Color.ORANGE); 140 for(WayPoint n: ls) { 141 if(n.attr.containsKey("synced")) 142 { 143 p = Main.map.mapView.getPoint(n.getEastNorth()); 144 g.drawOval(p.x - 2, p.y - 2, 4, 4); 145 } 146 } 147 //draw current segment points 133 148 g.setColor(Color.YELLOW); 134 149 if(player.getPrev()!=null) … … 176 191 } 177 192 193 //finds the first waypoint that is nearby the given point 178 194 private WayPoint getNearestWayPoint(Point mouse) 179 195 { … … 182 198 Rectangle rect = new Rectangle(mouse.x-MAX/2,mouse.y-MAX/2,MAX,MAX); 183 199 //iterate through all possible notes 184 for(WayPoint n : ls) //TODO this is not very clever, what better way to find this WP? 200 for(WayPoint n : ls) //TODO this is not very clever, what better way to find this WP? Hashmaps? Divide and Conquer? 185 201 { 186 202 p = Main.map.mapView.getPoint(n.getEastNorth()); … … 228 244 mouse=e.getPoint(); 229 245 dragIcon=true; 230 //ani.cancel();231 246 } 232 247 } … … 250 265 { 251 266 player.jump(wp); 252 if(gps!=null) gps.notifyGPSClick();267 if(gps!=null) notifyObservers(player.getRelativeTime()); //call videoplayer to set rigth position 253 268 } 254 269 } … … 290 305 291 306 } 307 308 public static void addObserver(PlayerObserver observer) { 309 310 observers.add(observer); 311 312 } 313 314 315 316 public static void removeObserver(PlayerObserver observer) { 317 318 observers.remove(observer); 319 320 } 321 322 private static void notifyObservers(long newTime) { 323 324 for (PlayerObserver o : observers) { 325 326 o.jumping(newTime); 327 328 } 329 330 } 292 331 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoMappingPlugin.java
r21656 r21779 38 38 39 39 /** 40 * @author Matthias Meißer 40 * @author Matthias Meißer (digi_c at arcor dot de) 41 41 * @ released under GPL 42 42 * This Plugin allows you to link a video against a GPS track and playback both synchronously … … 48 48 private GpxData GPSTrack; 49 49 private List<WayPoint> ls; 50 private JosmAction VAdd,VRemove,VStart,Vbackward,Vforward,V loop;50 private JosmAction VAdd,VRemove,VStart,Vbackward,Vforward,Vfaster,Vslower,Vloop; 51 51 private JRadioButtonMenuItem VIntBob,VIntNone,VIntLinear; 52 52 private JCheckBoxMenuItem VCenterIcon; … … 54 54 private GPSVideoPlayer player; 55 55 private PositionLayer layer; 56 private final String VM_DEINTERLACER="videomapping.deinterlacer"; 57 private final String VM_MRU="videomapping.mru"; 58 private final String VM_AUTOCENTER="videomapping.autocenter"; 59 private final String VM_JUMPLENGTH="videomapping.jumplength"; 60 private final String VM_LOOPLENGTH="videomapping.looplength"; 61 private boolean autocenter; 62 private String deinterlacer; 63 private Integer jumplength,looplength; 64 private String mru; 65 //TODO What more to store during sessions? Size/Position 56 66 57 67 58 68 public VideoMappingPlugin(PluginInformation info) { 59 69 super(info); 70 MapView.addLayerChangeListener(this); 60 71 //Register for GPS menu 61 72 VMenu = Main.main.menu.addMenu(" Video", KeyEvent.VK_V, Main.main.menu.defaultMenuPos,ht("/Plugin/Videomapping"));//TODO no more ugly " video" hack 62 73 addMenuItems(); 74 enableControlMenus(true); 63 75 loadSettings(); 64 enableControlMenus(false); 65 //setup 66 MapView.addLayerChangeListener(this); 76 applySettings(); 67 77 //further plugin informations are provided by build.xml properties 68 } 78 } 69 79 70 80 //only use with GPS and own layers 71 81 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 82 System.out.println(newLayer); 72 83 if (newLayer instanceof GpxLayer) 73 84 { … … 77 88 } 78 89 else 79 { 90 {/* 80 91 VAdd.setEnabled(false); 81 92 if(newLayer instanceof PositionLayer) … … 86 97 { 87 98 enableControlMenus(false); 88 } 99 }*/ 89 100 } 90 101 … … 100 111 //register main controls 101 112 private void addMenuItems() { 102 VAdd= new JosmAction( "Import Video","videomapping","Sync a video against this GPS track",null,false) {113 VAdd= new JosmAction(tr("Import Video"),"videomapping",tr("Sync a video against this GPS track"),null,false) { 103 114 private static final long serialVersionUID = 1L; 104 115 105 public void actionPerformed(ActionEvent arg0) { 106 copyGPSLayer(); 107 enableControlMenus(true); 108 layer = new PositionLayer("test",ls); 109 Main.main.addLayer(layer); 110 /*JFileChooser fc = new JFileChooser("Open Video file"); 111 fc.getSelectedFile();*/ 112 player = new GPSVideoPlayer(new File("C:\\temp\\test.mpg"), layer.player); 113 //TODO Check here if we can sync by hand 114 layer.setGPSPlayer(player); 115 VAdd.setEnabled(false); 116 VRemove.setEnabled(true); 117 } 118 }; 119 VRemove= new JosmAction("Remove Video","videomapping","Removes current video from Layer",null,false) { 116 public void actionPerformed(ActionEvent arg0) { 117 JFileChooser fc = new JFileChooser(); 118 //fc.setSelectedFile(new File(mru)); 119 fc.setSelectedFile(new File("C:\\TEMP")); 120 if(fc.showOpenDialog(Main.main.parent)!=JFileChooser.CANCEL_OPTION) 121 { 122 saveSettings(); 123 ls=copyGPSLayer(GPSTrack); 124 enableControlMenus(true); 125 layer = new PositionLayer(fc.getSelectedFile().getName(),ls); 126 Main.main.addLayer(layer); 127 player = new GPSVideoPlayer(fc.getSelectedFile(), layer.player); 128 //TODO Check here if we can sync by hand 129 layer.setGPSPlayer(player); 130 layer.addObserver(player); 131 VAdd.setEnabled(false); 132 VRemove.setEnabled(true); 133 } 134 } 135 136 }; 137 VRemove= new JosmAction(tr("Remove Video"),"videomapping",tr("removes current video from layer"),null,false) { 120 138 private static final long serialVersionUID = 1L; 121 139 … … 124 142 } 125 143 }; 126 VStart = new JosmAction( "play/pause", "audio-playpause", "starts/pauses video playback",144 VStart = new JosmAction(tr("play/pause"), "audio-playpause", tr("starts/pauses video playback"), 127 145 Shortcut.registerShortcut("videomapping:startstop","",KeyEvent.VK_SPACE, Shortcut.GROUP_DIRECT), false) { 128 146 129 147 public void actionPerformed(ActionEvent e) { 130 //video.play(); 131 //video.jump(605000); 132 //layer.l.jump(9*60+20); 133 //layer.pause(); 134 player.play((9*60+20)*1000); 135 } 136 }; 137 Vbackward = new JosmAction("backward", "audio-prev", "jumps n sec back", 148 if(player.playing()) player.pause(); else player.play(); 149 } 150 }; 151 Vbackward = new JosmAction(tr("backward"), "audio-prev", tr("jumps n sec back"), 138 152 Shortcut.registerShortcut("videomapping:backward","",KeyEvent.VK_NUMPAD4, Shortcut.GROUP_DIRECT), false) { 139 153 … … 143 157 } 144 158 }; 145 Vforward= new JosmAction( "forward", "audio-next", "jumps n sec forward",159 Vforward= new JosmAction(tr("forward"), "audio-next", tr("jumps n sec forward"), 146 160 Shortcut.registerShortcut("videomapping:forward","",KeyEvent.VK_NUMPAD6, Shortcut.GROUP_DIRECT), false) { 147 161 … … 151 165 } 152 166 }; 153 Vloop= new JosmAction("loop", "clock", "loops n sec around current position", 167 Vfaster= new JosmAction(tr("faster"), "audio-faster", tr("faster playback"), 168 Shortcut.registerShortcut("videomapping:faster","",KeyEvent.VK_PLUS, Shortcut.GROUP_DIRECT), false) { 169 170 public void actionPerformed(ActionEvent e) { 171 player.faster(); 172 173 } 174 }; 175 Vslower= new JosmAction(tr("slower"), "audio-slower", tr("slower playback"), 176 Shortcut.registerShortcut("videomapping:slower","",KeyEvent.VK_MINUS, Shortcut.GROUP_DIRECT), false) { 177 178 public void actionPerformed(ActionEvent e) { 179 player.slower(); 180 181 } 182 }; 183 Vloop= new JosmAction(tr("loop"), "clock", tr("loops n sec around current position"), 154 184 Shortcut.registerShortcut("videomapping:loop","",KeyEvent.VK_NUMPAD5, Shortcut.GROUP_DIRECT), false) { 155 185 … … 161 191 162 192 //now the options menu 163 VCenterIcon = new JCheckBoxMenuItem(new JosmAction("Keep centered", null, "Follows the video icon automaticly",null, false) { 164 165 public void actionPerformed(ActionEvent e) { 166 player.setAutoCenter(VCenterIcon.isSelected()); 167 168 } 169 }); 170 171 VJumpLength = new JMenuItem(new JosmAction("Jump length", null, "Set the length of a jump",null, false) { 193 VCenterIcon = new JCheckBoxMenuItem(new JosmAction(tr("Keep centered"), "cursor/crosshair", tr("follows the video icon automaticly"),null, false) { 194 195 public void actionPerformed(ActionEvent e) { 196 autocenter=VCenterIcon.isSelected(); 197 applySettings(); 198 saveSettings(); 199 200 } 201 }); 202 203 VJumpLength = new JMenuItem(new JosmAction(tr("Jump length"), null, tr("Set the length of a jump"),null, false) { 172 204 173 205 public void actionPerformed(ActionEvent e) { 174 206 Object[] possibilities = {"200", "500", "1000", "2000", "10000"}; 175 String s = (String)JOptionPane.showInputDialog(Main.parent,"Jump in video for x ms","Jump length",JOptionPane.QUESTION_MESSAGE,null,possibilities,"1000"); 176 player.setJumpLength(Integer.getInteger(s)); 177 178 } 179 }); 180 181 VLoopLength = new JMenuItem(new JosmAction("Loop length", null, "Set the length around a looppoint",null, false) { 207 String s = (String)JOptionPane.showInputDialog(Main.parent,tr("Jump in video for x ms"),tr("Jump length"),JOptionPane.QUESTION_MESSAGE,null,possibilities,jumplength); 208 jumplength=Integer.getInteger(s); 209 applySettings(); 210 saveSettings(); 211 } 212 }); 213 214 VLoopLength = new JMenuItem(new JosmAction(tr("Loop length"), null, tr("Set the length around a looppoint"),null, false) { 182 215 183 216 public void actionPerformed(ActionEvent e) { 184 217 Object[] possibilities = {"500", "1000", "3000", "5000", "10000"}; 185 String s = (String)JOptionPane.showInputDialog(Main.parent,"Jump in video for x ms","Loop length",JOptionPane.QUESTION_MESSAGE,null,possibilities,"5000"); 186 player.setLoopLength(Integer.getInteger(s)); 218 String s = (String)JOptionPane.showInputDialog(Main.parent,tr("Jump in video for x ms"),tr("Loop length"),JOptionPane.QUESTION_MESSAGE,null,possibilities,looplength); 219 looplength=Integer.getInteger(s); 220 applySettings(); 221 saveSettings(); 187 222 188 223 } … … 190 225 191 226 VDeinterlacer= new JMenu("Deinterlacer"); 192 VIntNone= new JRadioButtonMenuItem(new JosmAction("none", null, "no deinterlacing",null, false) { 193 194 public void actionPerformed(ActionEvent e) { 195 player.setDeinterlacer(null); 196 } 197 }); 198 VIntBob= new JRadioButtonMenuItem(new JosmAction("bob", null, "deinterlacing using line doubling",null, false) { 199 200 public void actionPerformed(ActionEvent e) { 201 player.setDeinterlacer("bob"); 202 } 203 }); 204 VIntLinear= new JRadioButtonMenuItem(new JosmAction("linear", null, "deinterlacing using linear interpolation",null, false) { 205 206 public void actionPerformed(ActionEvent e) { 207 player.setDeinterlacer("bob"); 227 VIntNone= new JRadioButtonMenuItem(new JosmAction(tr("none"), null, tr("no deinterlacing"),null, false) { 228 229 public void actionPerformed(ActionEvent e) { 230 deinterlacer=null; 231 applySettings(); 232 saveSettings(); 233 } 234 }); 235 VIntBob= new JRadioButtonMenuItem(new JosmAction("bob", null, tr("deinterlacing using line doubling"),null, false) { 236 237 public void actionPerformed(ActionEvent e) { 238 deinterlacer="bob"; 239 applySettings(); 240 saveSettings(); 241 } 242 }); 243 VIntLinear= new JRadioButtonMenuItem(new JosmAction("linear", null, tr("deinterlacing using linear interpolation"),null, false) { 244 245 public void actionPerformed(ActionEvent e) { 246 deinterlacer="linear"; 247 applySettings(); 248 saveSettings(); 208 249 } 209 250 }); … … 216 257 VMenu.add(Vbackward); 217 258 VMenu.add(Vforward); 259 VMenu.add(Vfaster); 260 VMenu.add(Vslower); 218 261 VMenu.add(Vloop); 219 262 VMenu.addSeparator(); … … 235 278 } 236 279 237 //load all properties 280 //load all properties or set defaults 238 281 private void loadSettings() { 282 String temp; 283 temp=Main.pref.get(VM_AUTOCENTER); 284 if((temp!=null)&&(temp.length()!=0))autocenter=Boolean.getBoolean(temp); else autocenter=false; 285 temp=Main.pref.get(VM_DEINTERLACER); 286 if((temp!=null)&&(temp.length()!=0)) deinterlacer=Main.pref.get(temp); 287 temp=Main.pref.get(VM_JUMPLENGTH); 288 if((temp!=null)&&(temp.length()!=0)) jumplength=Integer.valueOf(temp); else jumplength=1000; 289 temp=Main.pref.get(VM_LOOPLENGTH); 290 if((temp!=null)&&(temp.length()!=0)) looplength=Integer.valueOf(temp); else looplength=6000; 291 temp=Main.pref.get(VM_MRU); 292 if((temp!=null)&&(temp.length()!=0)) mru=Main.pref.get(VM_MRU);else mru=System.getProperty("user.home"); 293 } 294 295 private void applySettings(){ 296 //Internals 297 if(player!=null) 298 { 299 player.setAutoCenter(autocenter); 300 player.setDeinterlacer(deinterlacer); 301 player.setJumpLength(jumplength); 302 player.setLoopLength(looplength); 303 } 304 //GUI 305 VCenterIcon.setSelected(autocenter); 239 306 VIntNone.setSelected(true); 307 if(deinterlacer=="bob")VIntBob.setSelected(true); 308 if(deinterlacer=="linear")VIntLinear.setSelected(true); 309 310 } 311 312 private void saveSettings(){ 313 Main.pref.put(VM_AUTOCENTER, autocenter); 314 Main.pref.put(VM_DEINTERLACER, deinterlacer); 315 Main.pref.put(VM_JUMPLENGTH, jumplength.toString()); 316 Main.pref.put(VM_LOOPLENGTH, looplength.toString()); 317 Main.pref.put(VM_MRU, mru); 240 318 } 241 319 242 320 //make a flat copy 243 private void copyGPSLayer()321 private List<WayPoint> copyGPSLayer(GpxData route) 244 322 { 245 323 ls = new LinkedList<WayPoint>(); 246 for (GpxTrack trk : GPSTrack.tracks) {324 for (GpxTrack trk : route.tracks) { 247 325 for (GpxTrackSegment segment : trk.getSegments()) { 248 326 ls.addAll(segment.getWayPoints()); … … 250 328 } 251 329 Collections.sort(ls); //sort basing upon time 330 return ls; 252 331 } 253 332 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoPlayer.java
r21656 r21779 9 9 import javax.swing.JButton; 10 10 11 import org.openstreetmap.josm.data.gpx.WayPoint; 11 12 import org.openstreetmap.josm.plugins.videomapping.GpsPlayer; 12 13 //combines video and GPS playback 14 public class GPSVideoPlayer{ 13 import org.openstreetmap.josm.plugins.videomapping.PlayerObserver; 14 15 //combines video and GPS playback, major control has the video player 16 public class GPSVideoPlayer implements PlayerObserver{ 15 17 Timer t; 16 18 TimerTask syncGPSTrack; … … 42 44 syncBtn.setBackground(Color.GREEN); 43 45 synced=true; 46 markSyncedPoints(); 44 47 gps.play(); 45 48 } … … 47 50 setSyncMode(true); 48 51 video.addComponent(syncBtn); 52 //allow sync 53 SimpleVideoPlayer.addObserver(new PlayerObserver() { 54 55 public void playing(long time) { 56 //sync the GPS back 57 if(synced) gps.jump(getGPSTime(time)); 58 59 } 60 61 public void jumping(long time) { 62 63 } 64 65 66 }); 49 67 t = new Timer(); 50 68 } 51 69 70 //marks all points that are covered by video AND GPS track 71 private void markSyncedPoints() { 72 long time; 73 //TODO this is poor, a start/end calculation would be better 74 for (WayPoint wp : gps.getTrack()) { 75 time=getVideoTime(gps.getRelativeTime(wp)); 76 if(time>0) wp.attr.put("synced", "true"); 77 } 78 79 } 80 52 81 public void setSyncMode(boolean b) 53 82 { … … 73 102 public void play(long gpsstart) 74 103 { 104 //video is already playing 75 105 jumpToGPSTime(gpsstart); 76 106 gps.jump(gpsstart); 77 gps.play(); 107 //gps.play(); 108 } 109 110 public void play() 111 { 112 video.play(); 113 } 114 115 public void pause() 116 { 117 video.pause(); 78 118 } 79 119 … … 96 136 } 97 137 98 //when we clicked on the layer, here we update the video position 99 public void notifyGPSClick() { 100 if(synced) jumpToGPSTime(gps.getRelativeTime()); 101 102 } 138 103 139 104 140 public void setJumpLength(Integer integer) { … … 151 187 152 188 189 //not called by GPS 190 public boolean playing() { 191 return video.playing(); 192 } 193 194 //when we clicked on the layer, here we update the video position 195 public void jumping(long time) { 196 if(synced) jumpToGPSTime(gps.getRelativeTime()); 197 198 } 199 200 public String getNativePlayerInfos() { 201 return video.getNativePlayerInfos(); 202 } 203 204 public void faster() { 205 video.faster(); 206 207 } 208 209 public void slower() { 210 video.slower(); 211 212 } 213 214 public void playing(long time) { 215 // TODO Auto-generated method stub 216 217 } 218 219 153 220 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/SimpleVideoPlayer.java
r21656 r21779 37 37 import org.openstreetmap.josm.Main; 38 38 import org.openstreetmap.josm.plugins.videomapping.PlayerObserver; 39 import static org.openstreetmap.josm.tools.I18n.*; 39 40 40 41 import uk.co.caprica.vlcj.binding.LibVlc; … … 60 61 private final String[] mediaOptions = {""}; 61 62 private boolean syncTimeline=false; 62 private SimpleDateFormat df; 63 private static final Logger LOG = Logger.getLogger(SimpleVideoPlayer.class); 63 private boolean looping=false; 64 private SimpleDateFormat ms; 65 private static final Logger LOG = Logger.getLogger(MediaPlayerFactory.class); 64 66 private int jumpLength=1000; 65 67 private int loopLength=6000; … … 86 88 mp.setStandardMediaOptions(standardMediaOptions); 87 89 //setup GUI 88 setSize(400, 300); 90 setSize(400, 300); //later we resize 89 91 setAlwaysOnTop(true); 90 92 //setIconImage(); 91 df= new SimpleDateFormat("hh:mm:ss:S");93 ms = new SimpleDateFormat("hh:mm:ss:S"); 92 94 scr=new Canvas(); 93 95 timeline = new JSlider(0,100,0); … … 95 97 timeline.setMajorTickSpacing(5); 96 98 timeline.setPaintTicks(true); 97 play= new JButton( "play");99 play= new JButton(tr("play")); 98 100 back= new JButton("<"); 99 101 forward= new JButton(">"); 100 loop= new JToggleButton( "loop");102 loop= new JToggleButton(tr("loop")); 101 103 speed = new JSlider(-200,200,0); 102 104 speed.setMajorTickSpacing(100); … … 127 129 catch (NoClassDefFoundError e) 128 130 { 129 System.err.println( "Unable to find JNA Java library!");131 System.err.println(tr("Unable to find JNA Java library!")); 130 132 } 131 133 catch (UnsatisfiedLinkError e) 132 134 { 133 System.err.println( "Unable to find native libvlc library!");135 System.err.println(tr("Unable to find native libvlc library!")); 134 136 } 135 137 … … 181 183 182 184 public void actionPerformed(ActionEvent arg0) { 183 mp.setTime((long) (mp.getTime()-jumpLength)); 184 //jump(600000); //10,05 185 185 backward(); 186 186 } 187 187 }); … … 190 190 191 191 public void actionPerformed(ActionEvent arg0) { 192 mp.setTime((long) (mp.getTime()+jumpLength)); 193 192 forward(); 194 193 } 195 194 }); … … 198 197 199 198 public void actionPerformed(ActionEvent arg0) { 200 if(!loop.isSelected()) 201 { 202 t.cancel(); 203 } 204 else 205 { 206 final long resetpoint=(long) mp.getTime()-loopLength/2; 207 TimerTask ani=new TimerTask() { 208 209 @Override 210 public void run() { 211 mp.setTime(resetpoint); 212 } 213 }; 214 t= new Timer(); 215 t.schedule(ani,loopLength/2,loopLength); //first run a half looptime till reset 216 } 199 loop(); 217 200 } 218 201 }); … … 330 313 if(mp.isPlaying()) 331 314 { 332 setTitle( df.format(new Date(mp.getTime()))); //FIXME there is a leading hour even at the beginning315 setTitle(ms.format(new Date(mp.getTime()))); //FIXME there is a leading hour even at the beginning 333 316 syncTimeline=true; 334 317 timeline.setValue(Math.round(mp.getPosition()*100)); 335 318 syncTimeline=false; 319 notifyObservers(mp.getTime()); 336 320 } 337 321 } … … 363 347 } 364 348 365 public void loop() { 366 loop.notifyAll(); 349 public void loop() { 350 if(looping) 351 { 352 t.cancel(); 353 looping=false; 354 } 355 else 356 { 357 final long resetpoint=(long) mp.getTime()-loopLength/2; 358 TimerTask ani=new TimerTask() { 359 360 @Override 361 public void run() { 362 mp.setTime(resetpoint); 363 } 364 }; 365 t= new Timer(); 366 t.schedule(ani,loopLength/2,loopLength); //first run a half looptime till reset 367 looping=true; 368 } 369 367 370 } 368 371 369 372 public void forward() { 370 forward.notifyAll();373 mp.setTime((long) (mp.getTime()+jumpLength)); 371 374 } 372 375 373 376 public void backward() { 374 back.notifyAll();377 mp.setTime((long) (mp.getTime()-jumpLength)); 375 378 376 379 } … … 396 399 } 397 400 398 private static void notifyObservers( ) {401 private static void notifyObservers(long newTime) { 399 402 400 403 for (PlayerObserver o : observers) { 401 404 402 o. changeSpeed(0.0f);405 o.playing(newTime); 403 406 404 407 } … … 406 409 } 407 410 411 public String getNativePlayerInfos() { 412 return "VLC "+LibVlc.INSTANCE.libvlc_get_version(); 413 } 414 415 public void faster() { 416 speed.setValue(speed.getValue()+100); 417 418 } 419 420 public void slower() { 421 speed.setValue(speed.getValue()-100); 422 423 } 424 425 public void pause() { 426 if (mp.isPlaying()) mp.pause(); 427 428 } 429 430 public boolean playing() { 431 return mp.isPlaying(); 432 } 433 408 434 409 435
Note:
See TracChangeset
for help on using the changeset viewer.