Changeset 21584 in osm for applications/editors/josm/plugins/videomapping/src/org/openstreetmap
- Timestamp:
- 2010-06-05T09:37:55+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping
- Files:
-
- 4 added
- 1 deleted
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/GpsPlayer.java
r21555 r21584 18 18 private List<WayPoint> ls; 19 19 private WayPoint prev,curr,next; 20 private WayPoint start; 20 21 21 22 … … 35 36 super(); 36 37 this.ls = l; 38 start=ls.get(0); 37 39 prev=null; 38 40 curr=ls.get(0); … … 78 80 } 79 81 else next=null; 80 81 82 } 82 83 } … … 86 87 if ((ls.indexOf(curr)+t>0)&&(ls.indexOf(curr)<ls.size())) 87 88 { 88 jump(ls.get(ls.indexOf(curr)+t)); 89 jump(ls.get(ls.indexOf(curr)+t)); //FIXME here is a bug 89 90 } 90 91 } … … 280 281 } 281 282 282 public void pause() { 283 // TODO Auto-generated method stub 284 285 } 286 283 public long getRelativeTime() 284 { 285 return curr.getTime().getTime()-start.getTime().getTime(); //TODO assumes timeintervall is constant!!!! 286 } 287 288 //jumps to a speciffic time 289 public void jump(long relTime) { 290 jump(relTime/1000); //TODO ugly quick hack 291 292 } 287 293 288 294 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PositionLayer.java
r21555 r21584 49 49 public class PositionLayer extends Layer implements MouseListener,MouseMotionListener, KeyListener { 50 50 private List<WayPoint> ls; 51 p rivateGpsPlayer l;51 public GpsPlayer l; 52 52 private Collection<WayPoint> selected; 53 53 private Timer t; … … 67 67 df = new SimpleDateFormat("hh:mm:ss:S"); 68 68 Main.map.mapView.addMouseListener(this); 69 Main.map.mapView.addMouseMotionListener(this); 70 addKeys(); 71 72 } 73 74 //add key bindings for navigate through the track (and if synced trough the video, too) 75 private void addKeys() { 76 Action backward = new AbstractAction() { 77 public void actionPerformed(ActionEvent e) { 78 if(l!=null)l.prev(); 79 Main.map.mapView.repaint(); 80 }}; 81 82 Action forward = new AbstractAction() { 83 public void actionPerformed(ActionEvent e) { 84 if(l!=null)l.next(); 85 Main.map.mapView.repaint(); 86 }}; 87 Action startStop = new AbstractAction() { 88 public void actionPerformed(ActionEvent e) { 89 if (t==null) 90 { 91 //start 92 t= new Timer(); 93 TimerTask ani=new TimerTask() { 94 @Override 95 //some cheap animation stuff 96 public void run() { 97 l.next(); 98 Main.map.mapView.repaint(); 99 } 100 }; 101 t.schedule(ani,500,500); 102 } 103 else 104 { 105 //stop 106 t.cancel(); 107 t=null; 108 } 109 }}; 110 //TODO custome Shortkey management 111 Main.registerActionShortcut(backward, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)); 112 Main.registerActionShortcut(forward, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)); 113 //Main.registerActionShortcut(startStop, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)); 114 } 69 Main.map.mapView.addMouseMotionListener(this); 70 71 } 72 115 73 116 74 @Override … … 215 173 if (l.getCurr()!=null){ 216 174 p=Main.map.mapView.getPoint(l.getCurr().getEastNorth()); 217 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 218 g.drawString(df.format(l.getCurr().getTime()),p.x,p.y); 219 } 220 } 175 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 176 SimpleDateFormat ms=new SimpleDateFormat("mm:ss"); 177 g.drawString(ms.format(l.getRelativeTime()),p.x,p.y); 178 } 179 } 180 } 181 182 private void markNearestWayPoints(Point mouse) { 183 final int MAX=10; 184 Point p; 185 Rectangle rect = new Rectangle(mouse.x-MAX/2,mouse.y-MAX/2,MAX,MAX); 186 //iterate through all possible notes 187 for(WayPoint n : ls) 188 { 189 p = Main.map.mapView.getPoint(n.getEastNorth()); 190 if (rect.contains(p)) 191 { 192 selected.add(n); 193 } 194 195 } 196 } 197 198 private WayPoint getNearestWayPoint(Point mouse) 199 { 200 final int MAX=10; 201 Point p; 202 Rectangle rect = new Rectangle(mouse.x-MAX/2,mouse.y-MAX/2,MAX,MAX); 203 //iterate through all possible notes 204 for(WayPoint n : ls) //TODO this is not very clever, what better way to find this WP? 205 { 206 p = Main.map.mapView.getPoint(n.getEastNorth()); 207 if (rect.contains(p)) 208 { 209 return n; 210 } 211 212 } 213 return null; 214 215 } 216 217 @Override 218 public void visitBoundingBox(BoundingXYVisitor arg0) { 219 // TODO dunno what to do here 220 221 } 222 223 //mark selected points 224 public void mouseClicked(MouseEvent e) { 225 } 226 227 public void mouseEntered(MouseEvent arg0) { 228 } 229 230 public void mouseExited(MouseEvent arg0) { 231 } 232 233 public void mousePressed(MouseEvent e) { 234 if(e.getButton() == MouseEvent.BUTTON1) { 235 //is it on the cam icon? 236 if (l.getCurr()!=null) 237 { 238 if (getIconRect().contains(e.getPoint())) 239 { 240 mouse=e.getPoint(); 241 dragIcon=true; 242 //ani.cancel(); 243 } 244 } 245 } 246 247 } 248 249 public void mouseReleased(MouseEvent e) { 250 251 //only on leftclicks of our layer 252 if(e.getButton() == MouseEvent.BUTTON1) { 253 if(dragIcon) 254 { 255 dragIcon=false; 256 } 257 else 258 { 259 //JOptionPane.showMessageDialog(Main.parent,"test"); 260 markNearestWayPoints(e.getPoint()); 261 WayPoint wp = getNearestWayPoint(e.getPoint()); 262 if(wp!=null) 263 { 264 l.jump(wp); 265 } 266 } 267 Main.map.mapView.repaint(); 268 } 269 270 } 271 272 273 public void mouseDragged(MouseEvent e) { 274 if(dragIcon) 275 { 276 mouse=e.getPoint(); 277 //restrict to GPS track 278 iconPosition=l.getInterpolatedWaypoint(mouse); 279 280 Main.map.mapView.repaint(); 281 } 282 } 283 284 private Rectangle getIconRect() 285 { 286 Point p = Main.map.mapView.getPoint(l.getCurr().getEastNorth()); 287 return new Rectangle(p.x-icon.getIconWidth()/2,p.y-icon.getIconHeight()/2,icon.getIconWidth(),icon.getIconHeight()); 288 } 289 290 public void mouseMoved(MouseEvent e) { 291 292 if (l.getCurr()!=null) 293 { 294 if (getIconRect().contains(e.getPoint())) 295 { 296 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 297 } 298 else 299 { 300 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 301 } 302 } 303 304 } 305 306 public void keyPressed(KeyEvent e) { 307 int i; 308 System.out.println(e.getKeyCode()); 309 switch(e.getKeyCode()) 310 { 311 case KeyEvent.VK_RIGHT: 312 { 313 l.jump(1); 314 };break; 315 case KeyEvent.VK_LEFT: 316 { 317 l.jump(-1); 318 319 };break; 320 case KeyEvent.VK_SPACE: 321 { 322 ani.cancel(); 323 } 324 } 325 326 } 327 328 public void keyReleased(KeyEvent e) { 329 // TODO Auto-generated method stub 330 331 } 332 333 public void keyTyped(KeyEvent e) { 334 // TODO Auto-generated method stub 335 221 336 } 222 337 … … 236 351 }; 237 352 t.schedule(ani,500,500); 353 //and video 354 238 355 } 239 356 else … … 245 362 } 246 363 247 private void markNearestWayPoints(Point mouse) { 248 final int MAX=10; 249 Point p; 250 Rectangle rect = new Rectangle(mouse.x-MAX/2,mouse.y-MAX/2,MAX,MAX); 251 //iterate through all possible notes 252 for(WayPoint n : ls) 253 { 254 p = Main.map.mapView.getPoint(n.getEastNorth()); 255 if (rect.contains(p)) 256 { 257 selected.add(n); 258 } 259 260 } 261 } 262 263 private WayPoint getNearestWayPoint(Point mouse) 264 { 265 final int MAX=10; 266 Point p; 267 Rectangle rect = new Rectangle(mouse.x-MAX/2,mouse.y-MAX/2,MAX,MAX); 268 //iterate through all possible notes 269 for(WayPoint n : ls) //TODO this is not very clever, what better way to find this WP? 270 { 271 p = Main.map.mapView.getPoint(n.getEastNorth()); 272 if (rect.contains(p)) 273 { 274 return n; 275 } 276 277 } 278 return null; 279 280 } 281 282 @Override 283 public void visitBoundingBox(BoundingXYVisitor arg0) { 284 // TODO dunno what to do here 285 286 } 287 288 //mark selected points 289 public void mouseClicked(MouseEvent e) { 290 } 291 292 public void mouseEntered(MouseEvent arg0) { 293 } 294 295 public void mouseExited(MouseEvent arg0) { 296 } 297 298 public void mousePressed(MouseEvent e) { 299 if(e.getButton() == MouseEvent.BUTTON1) { 300 //is it on the cam icon? 301 if (l.getCurr()!=null) 302 { 303 if (getIconRect().contains(e.getPoint())) 304 { 305 mouse=e.getPoint(); 306 dragIcon=true; 307 //ani.cancel(); 308 } 309 } 310 } 311 312 } 313 314 public void mouseReleased(MouseEvent e) { 315 316 //only on leftclicks of our layer 317 if(e.getButton() == MouseEvent.BUTTON1) { 318 if(dragIcon) 319 { 320 dragIcon=false; 321 } 322 else 323 { 324 //JOptionPane.showMessageDialog(Main.parent,"test"); 325 markNearestWayPoints(e.getPoint()); 326 WayPoint wp = getNearestWayPoint(e.getPoint()); 327 if(wp!=null) 328 { 329 l.jump(wp); 330 } 331 } 332 Main.map.mapView.repaint(); 333 } 334 335 } 336 337 338 public void mouseDragged(MouseEvent e) { 339 if(dragIcon) 340 { 341 mouse=e.getPoint(); 342 //restrict to GPS track 343 iconPosition=l.getInterpolatedWaypoint(mouse); 344 345 Main.map.mapView.repaint(); 346 } 347 } 348 349 private Rectangle getIconRect() 350 { 351 Point p = Main.map.mapView.getPoint(l.getCurr().getEastNorth()); 352 return new Rectangle(p.x-icon.getIconWidth()/2,p.y-icon.getIconHeight()/2,icon.getIconWidth(),icon.getIconHeight()); 353 } 354 355 public void mouseMoved(MouseEvent e) { 356 357 if (l.getCurr()!=null) 358 { 359 if (getIconRect().contains(e.getPoint())) 360 { 361 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 362 } 363 else 364 { 365 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 366 } 367 } 368 369 } 370 371 public void keyPressed(KeyEvent e) { 372 int i; 373 System.out.println(e.getKeyCode()); 374 switch(e.getKeyCode()) 375 { 376 case KeyEvent.VK_RIGHT: 377 { 378 l.jump(1); 379 };break; 380 case KeyEvent.VK_LEFT: 381 { 382 l.jump(-1); 383 384 };break; 385 case KeyEvent.VK_SPACE: 386 { 387 ani.cancel(); 388 } 389 } 390 391 } 392 393 public void keyReleased(KeyEvent e) { 364 365 public void backward() { 366 if(l!=null)l.prev(); 367 Main.map.mapView.repaint(); 368 } 369 370 public void forward() { 371 if(l!=null)l.next(); 372 Main.map.mapView.repaint(); 373 } 374 375 376 public void loop() { 394 377 // TODO Auto-generated method stub 395 378 396 379 } 397 380 398 public void keyTyped(KeyEvent e) {399 // TODO Auto-generated method stub400 401 }402 403 381 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoMappingPlugin.java
r21555 r21584 4 4 import java.awt.event.ActionEvent; 5 5 import java.awt.event.KeyEvent; 6 import java.io.File; 7 import java.util.Collections; 8 import java.util.LinkedList; 9 import java.util.List; 6 10 7 11 import javax.swing.JMenu; … … 11 15 import org.openstreetmap.josm.Main; 12 16 import org.openstreetmap.josm.plugins.*; 13 import org.openstreetmap.josm.plugins.videomapping.actions.StartStopAction; 14 import org.openstreetmap.josm.plugins.videomapping.actions.VideoAddAction; 17 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideoPlayer; 15 18 import org.openstreetmap.josm.tools.ImageProvider; 19 import org.openstreetmap.josm.tools.Shortcut; 16 20 import org.openstreetmap.josm.actions.JosmAction; 17 21 import org.openstreetmap.josm.data.gpx.GpxData; 22 import org.openstreetmap.josm.data.gpx.GpxTrack; 23 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 24 import org.openstreetmap.josm.data.gpx.WayPoint; 18 25 import org.openstreetmap.josm.gui.MainMenu; 19 26 import org.openstreetmap.josm.gui.MapFrame; … … 33 40 private JMenu VMenu; 34 41 private GpxData GPSTrack; 35 private VideoAddAction VAdd; 36 private StartStopAction VStart; 42 private List<WayPoint> ls; 43 private JosmAction VAdd,VStart,Vbackward,Vforward,Vloop; 44 private GPSVideoPlayer video; 45 private PositionLayer layer; 37 46 38 47 … … 53 62 VAdd.setEnabled(true); 54 63 GPSTrack=((GpxLayer) newLayer).data; 55 VAdd.setGps(GPSTrack);56 64 //TODO append to GPS Layer menu 57 65 } … … 78 86 } //well ok we have a local copy of the GPS track.... 79 87 88 //register main controls 80 89 private void addMenuItems() { 81 VAdd= new VideoAddAction(this); 82 VStart = new StartStopAction(); 90 VAdd= new JosmAction("Sync Video","videomapping","Sync a video against this GPS track",null,false) { 91 92 /** 93 * 94 */ 95 private static final long serialVersionUID = 1L; 96 97 public void actionPerformed(ActionEvent arg0) { 98 copyGPSLayer(); 99 layer = new PositionLayer("test",ls); 100 Main.main.addLayer(layer); 101 enableControlMenus(true); 102 video = new GPSVideoPlayer(new File("C:\\temp\\test.mpg"), layer.l); 103 } 104 }; 105 VStart = new JosmAction("play/pause", "audio-playpause", "starts/pauses video playback", 106 Shortcut.registerShortcut("videomapping:startstop","",KeyEvent.VK_SPACE, Shortcut.GROUP_MENU), false) { 107 108 public void actionPerformed(ActionEvent e) { 109 video.play(); 110 video.jump(605000); 111 layer.l.jump(9*60+20); 112 layer.pause(); 113 } 114 }; 115 Vbackward = new JosmAction("backward", "audio-prev", "jumps n sec back", 116 Shortcut.registerShortcut("videomapping:backward","",KeyEvent.VK_NUMPAD4, Shortcut.GROUP_MENU), false) { 117 118 public void actionPerformed(ActionEvent e) { 119 layer.backward(); 120 121 } 122 }; 123 Vforward= new JosmAction("forward", "audio-next", "jumps n sec forward", 124 Shortcut.registerShortcut("videomapping:forward","",KeyEvent.VK_NUMPAD6, Shortcut.GROUP_MENU), false) { 125 126 public void actionPerformed(ActionEvent e) { 127 layer.forward(); 128 129 } 130 }; 131 Vloop= new JosmAction("loop", "clock", "loops n sec around current position", 132 Shortcut.registerShortcut("videomapping:loop","",KeyEvent.VK_NUMPAD5, Shortcut.GROUP_MENU), false) { 133 134 public void actionPerformed(ActionEvent e) { 135 layer.loop(); 136 137 } 138 }; 83 139 VMenu.add(VAdd); 84 140 enableControlMenus(false); 85 141 VMenu.add(VStart); 142 VMenu.add(Vbackward); 143 VMenu.add(Vforward); 144 VMenu.add(Vloop); 86 145 } 87 146 88 public void setMyLayer(PositionLayer layer)89 {90 VStart.setLayer(layer);91 enableControlMenus(true);92 }93 147 148 149 //we can only move on our layer 94 150 private void enableControlMenus(boolean enabled) 95 151 { 96 152 VStart.setEnabled(enabled); 153 Vbackward.setEnabled(enabled); 154 Vforward.setEnabled(enabled); 155 Vloop.setEnabled(enabled); 156 } 157 158 //make a flat copy 159 private void copyGPSLayer() 160 { 161 ls = new LinkedList<WayPoint>(); 162 for (GpxTrack trk : GPSTrack.tracks) { 163 for (GpxTrackSegment segment : trk.getSegments()) { 164 ls.addAll(segment.getWayPoints()); 165 } 166 } 167 Collections.sort(ls); //sort basing upon time 97 168 } 98 169 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/SimpleVideoPlayer.java
r21530 r21584 1 package org.openstreetmap.josm.plugins.videomapping.video; 1 2 import java.awt.Adjustable; 3 import org.apache.log4j.Logger; 4 2 5 import java.awt.BorderLayout; 3 6 import java.awt.Canvas; … … 5 8 import java.awt.event.ActionEvent; 6 9 import java.awt.event.ActionListener; 10 import java.awt.event.WindowEvent; 11 import java.awt.event.WindowListener; 7 12 import java.beans.PropertyChangeListener; 13 import java.io.File; 14 import java.text.SimpleDateFormat; 15 import java.util.Date; 8 16 import java.util.Timer; 9 17 import java.util.TimerTask; 18 import java.util.concurrent.TimeUnit; 19 import java.util.concurrent.Executors; 20 import java.util.concurrent.ScheduledExecutorService; 10 21 11 22 import javax.swing.Action; … … 26 37 import uk.co.caprica.vlcj.player.MediaPlayer; 27 38 import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter; 39 import uk.co.caprica.vlcj.player.MediaPlayerEventListener; 28 40 import uk.co.caprica.vlcj.player.MediaPlayerFactory; 41 import uk.co.caprica.vlcj.player.VideoMetaData; 29 42 30 43 //basic class of a videoplayer for one video 31 public class SimpleVideoPlayer extends JFrame{ 44 public class SimpleVideoPlayer extends JFrame implements MediaPlayerEventListener, WindowListener{ 32 45 private MediaPlayer mp; 33 46 private Timer t; … … 38 51 private JSlider speed; 39 52 private Canvas scr; 40 41 public SimpleVideoPlayer(JFrame mainwindow) { 53 private final String[] mediaOptions = {""}; 54 private boolean syncTimeline=false; 55 private SimpleDateFormat df; 56 private static final Logger LOG = Logger.getLogger(SimpleVideoPlayer.class); 57 58 public SimpleVideoPlayer() { 42 59 super(); 43 //TODO new EnvironmentCheckerFactory().newEnvironmentChecker().checkEnvironment(); 60 /*TODO new EnvironmentCheckerFactory().newEnvironmentChecker().checkEnvironment(); 61 * if(RuntimeUtil.isWindows()) { 62 vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins"); 63 } 64 */ 44 65 try 45 { 46 String mediaPath = "C:\\Dokumente und Einstellungen\\g\\Eigene Dateien\\Eigene Videos\\23C3-1610-en-fudging_with_firmware.m4v"; 66 { 47 67 String[] libvlcArgs = {""}; 48 68 String[] standardMediaOptions = {""}; 49 String[] mediaOptions = {""};69 50 70 System.out.println("libvlc version: " + LibVlc.INSTANCE.libvlc_get_version()); 51 71 //setup Media Player 52 72 //TODO we have to deal with unloading things.... 53 73 MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs); 54 FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy( mainwindow);74 FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(this); 55 75 mp = mediaPlayerFactory.newMediaPlayer(fullScreenStrategy); 56 76 mp.setStandardMediaOptions(standardMediaOptions); 57 //mp.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {});58 77 //setup GUI 78 setSize(400, 300); 79 df = new SimpleDateFormat("hh:mm:ss:S"); 59 80 scr=new Canvas(); 60 81 timeline = new JSlider(0,100,0); … … 69 90 setLayout(); 70 91 addListeners(); 71 //embed player 92 //embed vlc player 72 93 scr.setVisible(true); 73 94 setVisible(true); 74 95 mp.setVideoSurface(scr); 75 mp.playMedia(mediaPath, mediaOptions); 76 mainwindow.pack(); 96 mp.addMediaPlayerEventListener(this); 97 mp.pause(); 98 jump(0); 99 //set updater 100 ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); 101 executorService.scheduleAtFixedRate(new Syncer(this), 0L, 500L, TimeUnit.MILLISECONDS); 102 //setDefaultCloseOperation(EXIT_ON_CLOSE); 103 addWindowListener(this); 77 104 } 78 105 catch (NoClassDefFoundError e) … … 84 111 System.err.println("Unable to find native libvlc library!"); 85 112 } 113 86 114 } 87 115 … … 102 130 controlsPanel.add(back); 103 131 controlsPanel.add(forward); 104 controlsPanel.add(loop); 132 controlsPanel.add(loop); 133 loop.setSelected(false); 105 134 } 106 135 … … 111 140 timeline.addChangeListener(new ChangeListener() { 112 141 public void stateChanged(ChangeEvent e) { 113 if(! timeline.getValueIsAdjusting())142 if(!syncTimeline) //only if user moves the slider by hand 114 143 { 115 //recalc to 0.x percent value 116 mp.setPosition((float)timeline.getValue() / 100.0f); 144 if(!timeline.getValueIsAdjusting()) //and the slider is fixed 145 { 146 //recalc to 0.x percent value 147 mp.setPosition((float)timeline.getValue()/100.0f); 148 } 117 149 } 118 150 } … … 120 152 121 153 play.addActionListener(new ActionListener() { 154 122 155 public void actionPerformed(ActionEvent arg0) { 123 mp.play(); 124 125 } 126 }); 127 128 play.addActionListener(new ActionListener() { 129 130 public void actionPerformed(ActionEvent arg0) { 131 mp.play(); 156 if(mp.isPlaying()) mp.stop(); else mp.play(); 132 157 } 133 158 }); … … 137 162 public void actionPerformed(ActionEvent arg0) { 138 163 mp.setTime((long) (mp.getTime()-JUMP_LENGTH)); 164 //jump(600000); //10,05 139 165 140 166 } … … 152 178 153 179 public void actionPerformed(ActionEvent arg0) { 154 if(!loop.getModel().isPressed()) 180 if(!loop.isSelected()) 181 { 182 t.cancel(); 183 } 184 else 155 185 { 156 186 final long resetpoint=(long) mp.getTime()-LOOP_LENGTH/2; … … 165 195 t.schedule(ani,LOOP_LENGTH/2,LOOP_LENGTH); //first run a half looptime till reset 166 196 } 167 else168 {169 t.cancel();170 }171 197 } 172 198 }); … … 175 201 176 202 public void stateChanged(ChangeEvent arg0) { 177 // TODO get integrated with future VLCj relase203 // TODO change playback speed 178 204 179 205 } … … 181 207 182 208 } 209 210 public void finished(MediaPlayer arg0) { 211 // TODO Auto-generated method stub 212 213 } 214 215 public void lengthChanged(MediaPlayer arg0, long arg1) { 216 // TODO Auto-generated method stub 217 218 } 219 220 public void metaDataAvailable(MediaPlayer arg0, VideoMetaData arg1) { 221 // TODO Auto-generated method stub 222 223 } 224 225 public void paused(MediaPlayer arg0) { 226 // TODO Auto-generated method stub 227 228 } 229 230 public void playing(MediaPlayer arg0) { 231 // TODO Auto-generated method stub 232 233 } 234 235 public void positionChanged(MediaPlayer arg0, float arg1) { 236 237 } 238 239 public void stopped(MediaPlayer arg0) { 240 // TODO Auto-generated method stub 241 242 } 243 244 public void timeChanged(MediaPlayer arg0, long arg1) { 245 // TODO Auto-generated method stub 246 247 } 248 249 250 public void windowActivated(WindowEvent arg0) { 251 // TODO Auto-generated method stub 252 253 } 254 255 public void windowClosed(WindowEvent arg0) { 256 // TODO Auto-generated method stub 257 258 } 259 260 //we have to unload and disconnect to the VLC engine 261 public void windowClosing(WindowEvent evt) { 262 if(LOG.isDebugEnabled()) {LOG.debug("windowClosing(evt=" + evt + ")");} 263 mp.release(); 264 mp = null; 265 System.exit(0); 266 } 267 268 public void windowDeactivated(WindowEvent arg0) { 269 // TODO Auto-generated method stub 270 271 } 272 273 public void windowDeiconified(WindowEvent arg0) { 274 // TODO Auto-generated method stub 275 276 } 277 278 public void windowIconified(WindowEvent arg0) { 279 // TODO Auto-generated method stub 280 281 } 282 283 public void windowOpened(WindowEvent arg0) { 284 // TODO Auto-generated method stub 285 286 } 287 288 public void setFile(File f) 289 { 290 String mediaPath = f.getAbsoluteFile().toString(); 291 mp.playMedia(mediaPath, mediaOptions); 292 jump(8000); 293 jump(0); 294 mp.stop(); 295 pack(); 296 } 297 298 public void play() 299 { 300 mp.play(); 301 } 302 303 public void jump(long time) 304 { 305 /*float pos = (float)mp.getLength()/(float)time; 306 mp.setPosition(pos);*/ 307 mp.setTime(time); 308 } 309 310 public long getTime() 311 { 312 return mp.getTime(); 313 } 314 315 public float getPosition() 316 { 317 return mp.getPosition(); 318 } 319 320 //gets called by the Syncer to update all components 321 public void updateTime () 322 { 323 if(mp.isPlaying()) 324 { 325 setTitle(df.format(new Date(mp.getTime()))+" "+mp.getTime()); 326 syncTimeline=true; 327 timeline.setValue(Math.round(mp.getPosition()*100)); 328 syncTimeline=false; 329 } 330 } 183 331 184 332
Note:
See TracChangeset
for help on using the changeset viewer.