Changeset 28924 in osm for applications
- Timestamp:
- 2012-11-11T22:00:32+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/videomapping
- Files:
-
- 5 added
- 5 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/videomapping/.classpath
r25796 r28924 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry kind="src" path="test"/> 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> 6 <classpathentry kind="lib" path="/core/dist/josm-custom.jar"/> 7 <classpathentry kind="lib" path="lib/jna.jar"/> 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 8 6 <classpathentry kind="lib" path="lib/log4j.jar"/> 9 <classpathentry kind="lib" path="lib/vlcj- 1.1.5.1.jar" sourcepath="C:/Dokumente und Einstellungen/Matthias/Desktop/vlcj/vlcj-1.1.5.1-javadoc.jar">7 <classpathentry kind="lib" path="lib/vlcj-2.1.0.jar" sourcepath="lib/vlcj-2.1.0-sources.jar"> 10 8 <attributes> 11 <attribute name="javadoc_location" value="jar: file:/D:/Projekte/Studium/BA Arbeit/working/plugins/videomapping/lib/vlcj-1.1.5.1-javadoc.jar!/"/>9 <attribute name="javadoc_location" value="jar:platform:/resource/VideoMapping/lib/vlcj-2.1.0-javadoc.jar!/"/> 12 10 </attributes> 13 11 </classpathentry> 14 <classpathentry combineaccessrules="false" kind="src" path="/core"/> 15 <classpathentry kind="lib" path="lib/platform.jar"/> 12 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 13 <classpathentry kind="lib" path="lib/jna-3.4.0.jar"/> 14 <classpathentry kind="lib" path="lib/platform-3.4.0.jar"/> 16 15 <classpathentry kind="output" path="bin"/> 17 16 </classpath> -
applications/editors/josm/plugins/videomapping/.settings/org.eclipse.jdt.core.prefs
r21226 r28924 1 #Fri Apr 30 14:06:39 CEST 20102 1 eclipse.preferences.version=1 3 2 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1. 53 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 4 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 org.eclipse.jdt.core.compiler.compliance=1. 55 org.eclipse.jdt.core.compiler.compliance=1.6 7 6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 7 org.eclipse.jdt.core.compiler.debug.localVariable=generate … … 10 9 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 10 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 org.eclipse.jdt.core.compiler.source=1. 511 org.eclipse.jdt.core.compiler.source=1.6 -
applications/editors/josm/plugins/videomapping/README
r21295 r28924 5 5 icon: http://www.openclipart.org/detail/16349 6 6 7 VLCj binding ( 1.1.0f):7 VLCj binding (2.1.0): 8 8 http://code.google.com/p/vlcj/ 9 9 10 for use with VLC 1.1.x11 http:// download.videolan.org/pub/videolan/testing/vlc-1.1.0-pre4/win32/10 for use with VLC 2.0.x 11 http://www.videolan.org/vlc/#download -
applications/editors/josm/plugins/videomapping/build.xml
r28808 r28924 42 42 <import file="../build-common.xml"/> 43 43 44 <property name="vlcj" value="${plugin.lib.dir}/vlcj- 1.1.5.1.jar"/>45 <property name="jna" value="${plugin.lib.dir}/jna .jar"/>46 <property name="platform" value="${plugin.lib.dir}/platform .jar"/>44 <property name="vlcj" value="${plugin.lib.dir}/vlcj-2.1.0.jar"/> 45 <property name="jna" value="${plugin.lib.dir}/jna-3.4.0.jar"/> 46 <property name="platform" value="${plugin.lib.dir}/platform-3.4.0.jar"/> 47 47 <property name="log4j" value="${plugin.lib.dir}/log4j.jar"/> 48 48 <!-- classpath --> -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPlugin.java
r28289 r28924 2 2 3 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.marktr; 6 7 import java.awt.BorderLayout; 8 import java.awt.Panel; 6 9 7 import java.awt.event.ActionEvent; 10 8 import java.awt.event.KeyEvent; 11 import java.beans.PropertyChangeListener;12 9 import java.io.File; 13 10 import java.text.ParseException; … … 16 13 import java.util.Date; 17 14 18 import javax.swing.Action;19 import javax.swing.Box;20 15 import javax.swing.InputVerifier; 21 import javax.swing.JButton;22 16 import javax.swing.JCheckBoxMenuItem; 23 17 import javax.swing.JComponent; 24 import javax.swing.JDialog;25 18 import javax.swing.JFileChooser; 26 19 import javax.swing.JFormattedTextField; … … 29 22 import javax.swing.JMenuItem; 30 23 import javax.swing.JOptionPane; 31 import javax.swing.JPanel;32 24 import javax.swing.JRadioButtonMenuItem; 33 25 import javax.swing.SwingUtilities; … … 35 27 36 28 import org.openstreetmap.josm.Main; 37 import org.openstreetmap.josm.plugins.*; 29 import org.openstreetmap.josm.actions.JosmAction; 30 import org.openstreetmap.josm.gui.MapView; 31 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 32 import org.openstreetmap.josm.gui.layer.GpxLayer; 33 import org.openstreetmap.josm.gui.layer.Layer; 34 import org.openstreetmap.josm.plugins.Plugin; 35 import org.openstreetmap.josm.plugins.PluginInformation; 38 36 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideoPlayer; 39 37 import org.openstreetmap.josm.plugins.videomapping.video.VideoEngine; 40 38 import org.openstreetmap.josm.tools.Shortcut; 41 import org.openstreetmap.josm.actions.JosmAction; 42 import org.openstreetmap.josm.gui.MapView; 43 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 44 import org.openstreetmap.josm.gui.layer.*; 45 46 import uk.co.caprica.vlcj.runtime.windows.WindowsRuntimeUtil; 47 48 import com.sun.jna.LastErrorException; 49 import com.sun.jna.NativeLibrary; 39 40 import uk.co.caprica.vlcj.player.DeinterlaceMode; 50 41 51 42 /** … … 66 57 private final String PROP_JUMPLENGTH="videomapping.jumplength"; 67 58 private final String PROP_LOOPLENGTH="videomapping.looplength"; 68 private String deinterlacer;59 // private String deinterlacer; 69 60 private boolean autoCenter; 70 61 private Integer jumpLength,loopLength; … … 91 82 importVideoFile(); 92 83 } 93 94 84 }; 95 85 VRemove= new JosmAction(tr("Remove Video"),"videomapping",tr("removes current video from layer"),null,false) { … … 98 88 public void actionPerformed(ActionEvent arg0) { 99 89 } 100 }; 90 }; 101 91 VStart = new JosmAction(tr("Play/Pause"), "audio-playpause", tr("starts/pauses video playback"), 102 92 Shortcut.registerShortcut("videomapping:startstop",tr("Video: {0}", tr("Play/Pause")),KeyEvent.VK_NUMPAD5, Shortcut.DIRECT), false, "vm_play_pause",false) { 103 93 public void actionPerformed(ActionEvent e) { 104 gpsVideoPlayer.pause(); 94 if (gpsVideoPlayer != null) { 95 gpsVideoPlayer.pause(); 96 } 105 97 } 106 98 }; … … 108 100 Shortcut.registerShortcut("videomapping:backward",tr("Video: {0}", tr("Backward")),KeyEvent.VK_NUMPAD4, Shortcut.DIRECT), false, "vm_prev",false) { 109 101 public void actionPerformed(ActionEvent e) { 110 gpsVideoPlayer.backward(); 102 if (gpsVideoPlayer != null) { 103 gpsVideoPlayer.backward(); 104 } 111 105 } 112 106 }; … … 114 108 Shortcut.registerShortcut("videomapping:forward",tr("Video: {0}", tr("Forward")),KeyEvent.VK_NUMPAD6, Shortcut.DIRECT), false, "vm_next",false) { 115 109 public void actionPerformed(ActionEvent e) { 116 gpsVideoPlayer.forward(); 117 110 if (gpsVideoPlayer != null) { 111 gpsVideoPlayer.forward(); 112 } 118 113 } 119 114 }; … … 122 117 123 118 public void actionPerformed(ActionEvent e) { 124 gpsVideoPlayer.setSpeed(gpsVideoPlayer.getSpeed()+20); 125 119 if (gpsVideoPlayer != null) { 120 gpsVideoPlayer.setSpeed(gpsVideoPlayer.getSpeed()+20); 121 } 126 122 } 127 123 }; … … 130 126 131 127 public void actionPerformed(ActionEvent e) { 132 gpsVideoPlayer.setSpeed(gpsVideoPlayer.getSpeed()-20); 133 128 if (gpsVideoPlayer != null) { 129 gpsVideoPlayer.setSpeed(gpsVideoPlayer.getSpeed()-20); 130 } 134 131 } 135 132 }; … … 144 141 Shortcut.registerShortcut("videomapping:loop",tr("Video: {0}", tr("Loop")),KeyEvent.VK_NUMPAD7, Shortcut.DIRECT), false) { 145 142 public void actionPerformed(ActionEvent e) { 146 gpsVideoPlayer.toggleLooping(); 143 if (gpsVideoPlayer != null) { 144 gpsVideoPlayer.toggleLooping(); 145 } 147 146 } 148 147 }; … … 151 150 VCenterIcon = new JCheckBoxMenuItem(new JosmAction(tr("Keep centered"), (String)null, tr("follows the video icon automaticly"),null, false,"vm_keepcentered",false) { 152 151 public void actionPerformed(ActionEvent e) { 153 videoPositionLayer.setAutoCenter(VCenterIcon.isSelected()); 152 if (videoPositionLayer != null) { 153 videoPositionLayer.setAutoCenter(VCenterIcon.isSelected()); 154 } 154 155 } 155 156 }); … … 157 158 VSubTitles = new JCheckBoxMenuItem(new JosmAction(tr("Subtitles"), (String)null, tr("Show subtitles in video"),null, false,"vm_subtitles",false) { 158 159 public void actionPerformed(ActionEvent e) { 159 gpsVideoPlayer.setSubtitles(VSubTitles.isSelected()); 160 if (gpsVideoPlayer != null) { 161 gpsVideoPlayer.setSubtitles(VSubTitles.isSelected()); 162 } 160 163 } 161 164 }); … … 182 185 VIntNone= new JRadioButtonMenuItem(new JosmAction(tr("none"), (String)null, tr("no deinterlacing"),null, false,"vm_deinterlacer",false) { 183 186 public void actionPerformed(ActionEvent e) { 184 gpsVideoPlayer.setDeinterlacer("none"); 187 if (gpsVideoPlayer != null) { 188 gpsVideoPlayer.setDeinterlacer(null); 189 } 185 190 } 186 191 }); 187 192 VIntBob= new JRadioButtonMenuItem(new JosmAction("bob", (String)null, tr("deinterlacing using line doubling"),null, false,"vm_bobdeinterlace",false) { 188 193 public void actionPerformed(ActionEvent e) { 189 gpsVideoPlayer.setDeinterlacer("bob"); 194 if (gpsVideoPlayer != null) { 195 gpsVideoPlayer.setDeinterlacer(DeinterlaceMode.BOB); 196 } 190 197 } 191 198 }); 192 199 VIntLinear= new JRadioButtonMenuItem(new JosmAction("linear", (String)null, tr("deinterlacing using linear interpolation"),null, false,"vm_lineardeinterlace",false) { 193 200 public void actionPerformed(ActionEvent e) { 194 gpsVideoPlayer.setDeinterlacer("linear"); 201 if (gpsVideoPlayer != null) { 202 gpsVideoPlayer.setDeinterlacer(DeinterlaceMode.LINEAR); 203 } 195 204 } 196 205 }); … … 212 221 VMenu.add(VDeinterlacer); 213 222 VMenu.add(VSubTitles); 214 215 223 } 216 224 … … 218 226 JFileChooser fc = new JFileChooser(mostRecentFolder); 219 227 fc.setSelectedFile(new File(mostRecentFolder)); 220 if(fc.showOpenDialog(Main.main.parent)!=JFileChooser.CANCEL_OPTION) 221 { 228 if (fc.showOpenDialog(Main.parent) != JFileChooser.CANCEL_OPTION) { 222 229 mostRecentFolder=fc.getSelectedFile().getAbsolutePath(); 223 230 saveProperties(); 224 if(videoPositionLayer==null) 225 { 226 videoPositionLayer= new VideoPositionLayer(gpsLayer); 231 if (videoPositionLayer == null && gpsLayer != null) { 232 videoPositionLayer = new VideoPositionLayer(gpsLayer); 227 233 gpsVideoPlayer = new GPSVideoPlayer(new SimpleDateFormat("hh:mm:ss") ,videoPositionLayer); 228 234 gpsVideoPlayer.setJumpLength(jumpLength); 229 235 gpsVideoPlayer.setLoopLength(loopLength); 230 236 enableVideoControlMenus(true); 231 } 232 gpsVideoPlayer.addVideo(fc.getSelectedFile()); 237 } 238 if (gpsVideoPlayer != null) { 239 gpsVideoPlayer.addVideo(fc.getSelectedFile()); 240 } 233 241 } 234 242 } … … 244 252 } 245 253 246 private void setDefaults() 247 { 254 private void setDefaults() { 248 255 autoCenter=false; 249 deinterlacer="";256 // deinterlacer=""; 250 257 jumpLength=1000; 251 258 loopLength=6000; … … 276 283 } 277 284 278 279 285 private void showJumpTo() 280 286 { 281 String s;282 287 try { 283 288 JOptionPane d=new JOptionPane(tr("Jump to"), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); … … 301 306 } 302 307 }); 303 if (d.showConfirmDialog(Main.main.panel,inp, tr("Jump to GPS time"),JOptionPane.OK_CANCEL_OPTION)==JOptionPane.OK_OPTION)308 if (JOptionPane.showConfirmDialog(Main.panel,inp, tr("Jump to GPS time"),JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) 304 309 { 305 310 //add the day to the time … … 342 347 343 348 } 344 345 346 347 349 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoPositionLayer.java
r25896 r28924 2 2 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.Color; 7 import java.awt.Graphics2D; 8 import java.awt.Point; 9 import java.awt.Rectangle; 10 import java.awt.event.MouseEvent; 11 import java.awt.event.MouseListener; 12 import java.awt.event.MouseMotionListener; 4 13 import java.text.DateFormat; 5 14 import java.text.SimpleDateFormat; … … 8 17 import java.util.LinkedList; 9 18 import java.util.List; 10 import java.awt.Color; 11 import java.awt.Cursor; 12 import java.awt.Graphics2D; 13 import java.awt.Point; 14 import java.awt.Rectangle; 15 import java.awt.event.MouseEvent; 16 import java.awt.event.MouseListener; 17 import java.awt.event.MouseMotionListener; 18 import java.io.File; 19 20 import javax.swing.*; 21 22 import static org.openstreetmap.josm.tools.I18n.*; 19 20 import javax.swing.Action; 21 import javax.swing.Icon; 22 import javax.swing.ImageIcon; 23 23 24 24 import org.openstreetmap.josm.Main; … … 35 35 import org.openstreetmap.josm.gui.layer.GpxLayer; 36 36 import org.openstreetmap.josm.gui.layer.Layer; 37 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideo;38 37 import org.openstreetmap.josm.plugins.videomapping.video.GPSVideoPlayer; 39 import org.openstreetmap.josm.plugins.videomapping.video.Video;40 38 41 39 //Basic rendering and GPS layer interaction … … 107 105 g.drawString(gpsTimeFormat.format(iconPosition.getTime()),p.x-15,p.y-15); 108 106 } 109 107 /* 110 108 private void paintInterpolatedSegment(Graphics2D g) { 111 109 g.setColor(Color.CYAN); … … 142 140 return ls; 143 141 } 144 142 */ 145 143 //creates a waypoint for the corresponding time 146 144 public WayPoint interpolate(Date GPSTime) -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideo.java
r25896 r28924 1 1 package org.openstreetmap.josm.plugins.videomapping.video; 2 import java.awt.Canvas;3 2 import java.io.File; 4 import java.util.Calendar;5 3 import java.util.Date; 6 4 import java.util.List; … … 11 9 import org.openstreetmap.josm.data.gpx.WayPoint; 12 10 import org.openstreetmap.josm.plugins.videomapping.VideoPositionLayer; 11 12 import uk.co.caprica.vlcj.player.MediaPlayerFactory; 13 13 14 14 // a specific synced video … … 24 24 private VideoPositionLayer videoPositionLayer; 25 25 26 public GPSVideo(File filename, String id ) {27 super(filename,id );26 public GPSVideo(File filename, String id, MediaPlayerFactory mediaPlayerFactory) { 27 super(filename,id,mediaPlayerFactory); 28 28 } 29 29 30 30 public GPSVideo(Video video) 31 31 { 32 super(video.filename, video.id);33 this.player =video.player;32 super(video.filename, video.id, video.mediaPlayerFactory); 33 this.player = video.player; 34 34 } 35 35 -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoPlayer.java
r25896 r28924 1 1 package org.openstreetmap.josm.plugins.videomapping.video; 2 import java.awt.BorderLayout; 2 import static org.openstreetmap.josm.tools.I18n.tr; 3 3 4 import java.awt.Color; 4 import java.awt.FlowLayout;5 5 import java.awt.HeadlessException; 6 6 import java.awt.event.ActionEvent; … … 9 9 import java.io.File; 10 10 import java.text.DateFormat; 11 import java.util.Calendar;12 11 import java.util.Date; 13 import java.util.Iterator;14 12 import java.util.LinkedList; 15 13 import java.util.List; 16 import java.util.Timer;17 import java.util.TimerTask;18 14 19 15 import javax.swing.JButton; 20 import javax.swing.JCheckBoxMenuItem;21 import javax.swing.JPanel;22 16 23 import org.openstreetmap.josm.Main;24 import org.openstreetmap.josm.data.gpx.WayPoint;25 import org.openstreetmap.josm.plugins.videomapping.VideoObserver;26 17 import org.openstreetmap.josm.plugins.videomapping.VideoPositionLayer; 27 28 import static org.openstreetmap.josm.tools.I18n.*;29 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;30 18 31 19 //extends video playback, major control has the video player -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/Video.java
r25896 r28924 9 9 10 10 import uk.co.caprica.vlcj.player.MediaPlayer; 11 import uk.co.caprica.vlcj.player.MediaPlayerFactory; 12 import uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface; 11 13 12 14 //basic informations about one single video playback instance 13 15 public class Video { 14 public File filename;15 public String id; //unique id to make it easy to identify16 public final File filename; 17 public final String id; //unique id to make it easy to identify 16 18 public MediaPlayer player; 17 19 public Canvas canvas; 18 public JPanel panel; 20 public CanvasVideoSurface videoSurface; 21 public final JPanel panel; 22 public final MediaPlayerFactory mediaPlayerFactory; 19 23 20 public Video(File filename, String id) { 21 this.filename=filename; 22 this.id=id; 23 canvas=new Canvas(); 24 panel=new JPanel(); 25 panel.setLayout(new FlowLayout()); 26 panel.add(canvas,BorderLayout.CENTER); 24 public Video(File filename, String id, MediaPlayerFactory mediaPlayerFactory) { 25 this.filename = filename; 26 this.id = id; 27 this.mediaPlayerFactory = mediaPlayerFactory; 28 this.canvas = new Canvas(); 29 this.videoSurface = mediaPlayerFactory.newVideoSurface(canvas); 30 this.panel = new JPanel(); 31 this.panel.setLayout(new FlowLayout()); 32 this.panel.add(videoSurface.canvas(), BorderLayout.CENTER); 27 33 } 28 34 29 public long getCurrentTime() 30 { 35 public long getCurrentTime() { 31 36 return player.getTime(); 32 37 } 33 34 35 38 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoEngine.java
r28289 r28924 1 1 package org.openstreetmap.josm.plugins.videomapping.video; 2 2 3 import java.awt.Canvas;4 import java.awt.Dimension; 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 5 import java.awt.Window; 6 import java.io.File;7 6 import java.util.LinkedList; 8 7 import java.util.List; 9 8 10 import com.sun.jna.NativeLibrary; 11 12 import uk.co.caprica.vlcj.binding.internal.libvlc_media_player_t; 9 import uk.co.caprica.vlcj.binding.internal.libvlc_media_t; 10 import uk.co.caprica.vlcj.player.DeinterlaceMode; 13 11 import uk.co.caprica.vlcj.player.MediaPlayer; 14 12 import uk.co.caprica.vlcj.player.MediaPlayerEventListener; 15 13 import uk.co.caprica.vlcj.player.MediaPlayerFactory; 16 import uk.co.caprica.vlcj.player.VideoMetaData;17 14 import uk.co.caprica.vlcj.player.embedded.DefaultFullScreenStrategy; 18 15 import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer; 19 16 import uk.co.caprica.vlcj.player.embedded.FullScreenStrategy; 20 import uk.co.caprica.vlcj.runtime. windows.WindowsCanvas;17 import uk.co.caprica.vlcj.runtime.RuntimeUtil; 21 18 import uk.co.caprica.vlcj.runtime.windows.WindowsRuntimeUtil; 22 19 23 import static org.openstreetmap.josm.tools.I18n.*; 20 import com.sun.jna.NativeLibrary; 21 import com.sun.jna.platform.win32.Advapi32Util; 22 import com.sun.jna.platform.win32.WinReg; 24 23 25 24 //concrete Player library that is able to playback multiple videos 26 public class VideoEngine implements MediaPlayerEventListener {25 public class VideoEngine implements MediaPlayerEventListener { 27 26 private FullScreenStrategy fullScreenStrategy; 28 p rivateMediaPlayerFactory mediaPlayerFactory;27 public MediaPlayerFactory mediaPlayerFactory; 29 28 private List<Video> videos; 30 29 private List<VideosObserver> observers; … … 32 31 private final String[] standardMediaOptions = {""}; 33 32 private final static String[] deinterlacers = {"bob","linear"}; 34 private final float initialCanvasFactor = 0.5f;33 //private final float initialCanvasFactor = 0.5f; 35 34 private boolean singleVideoMode; //commands will only affect the last added video 36 35 private Video lastAddedVideo; 37 36 38 37 //called at plugin start to setup library 39 public static void setupPlayer() 40 { 41 NativeLibrary.addSearchPath("libvlc", WindowsRuntimeUtil.getVlcInstallDir()); 38 public static void setupPlayer() { 39 String vlcInstallDir = null; 40 41 if (RuntimeUtil.isWindows()) { 42 vlcInstallDir = WindowsRuntimeUtil.getVlcInstallDir(); 43 String arch = System.getProperty("os.arch"); 44 if (vlcInstallDir == null && arch.equals("amd64")) { 45 try { 46 vlcInstallDir = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, 47 WindowsRuntimeUtil.VLC_REGISTRY_KEY.replaceFirst("\\\\", "\\\\Wow6432Node\\\\"), 48 WindowsRuntimeUtil.VLC_INSTALL_DIR_KEY); 49 } catch (RuntimeException e) { 50 System.err.println(e.getMessage()); 51 } 52 } 53 } else if (RuntimeUtil.isMac()) { 54 // TODO 55 } else if (RuntimeUtil.isNix()) { 56 // TODO 57 } 58 59 if (vlcInstallDir != null) { 60 System.out.println("videomapping: found VLC install dir: "+vlcInstallDir); 61 NativeLibrary.addSearchPath("libvlc", vlcInstallDir); 62 } else { 63 System.err.println("videomapping: unable to locate VLC install dir"); 64 } 42 65 } 43 66 … … 47 70 videos = new LinkedList<Video>(); 48 71 observers = new LinkedList<VideosObserver>(); 49 try 50 { 72 try { 51 73 mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs); 52 74 fullScreenStrategy = new DefaultFullScreenStrategy(parent); 53 } 54 catch (NoClassDefFoundError e) 55 { 75 } catch (NoClassDefFoundError e) { 56 76 System.err.println(tr("Unable to find JNA Java library!")); 77 } catch (UnsatisfiedLinkError e) { 78 System.err.println(tr("Unable to find native libvlc library!")); 79 } catch (Throwable t) { 80 System.err.println(t.getMessage()); 57 81 } 58 catch (UnsatisfiedLinkError e)59 {60 System.err.println(tr("Unable to find native libvlc library!"));61 }62 82 } 63 83 … … 66 86 try 67 87 { 68 EmbeddedMediaPlayer mp; 69 mp = mediaPlayerFactory.newMediaPlayer(fullScreenStrategy); 88 EmbeddedMediaPlayer mp = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy); 70 89 video.player=mp; 71 90 mp.setStandardMediaOptions(standardMediaOptions); 72 91 videos.add(video); 73 92 lastAddedVideo=video; 74 mp.setVideoSurface(video. canvas);93 mp.setVideoSurface(video.videoSurface); 75 94 mp.addMediaPlayerEventListener(this); 76 95 String mediaPath = video.filename.getAbsoluteFile().toString(); … … 87 106 } 88 107 } 89 108 /* 90 109 private Video getVideo(MediaPlayer mp) 91 110 { … … 95 114 return null; 96 115 } 97 116 */ 98 117 public List<Video> getVideos() { 99 118 return videos; … … 246 265 247 266 248 public void setDeinterlacer ( Stringdeinterlacer)267 public void setDeinterlacer (DeinterlaceMode deinterlacer) 249 268 { 250 269 if (singleVideoMode) … … 282 301 video.player.release(); 283 302 video.player=null; 303 video.videoSurface=null; 284 304 video.canvas=null; 285 305 } … … 302 322 303 323 } 304 324 /* 305 325 public void buffering(MediaPlayer arg0) { 306 326 307 327 } 308 328 */ 309 329 public void error(MediaPlayer arg0) { 310 330 … … 322 342 323 343 } 324 344 /* 325 345 public void mediaChanged(MediaPlayer arg0) { 326 346 … … 332 352 notifyObservers(VideoObserversEvents.resizing); 333 353 } 334 354 */ 335 355 public void opening(MediaPlayer arg0) { 336 356 … … 386 406 } 387 407 408 @Override 409 public void mediaChanged(MediaPlayer mediaPlayer, libvlc_media_t media, String mrl) { 410 // TODO Auto-generated method stub 411 412 } 413 414 @Override 415 public void buffering(MediaPlayer mediaPlayer, float newCache) { 416 // TODO Auto-generated method stub 417 418 } 419 420 @Override 421 public void videoOutput(MediaPlayer mediaPlayer, int newCount) { 422 // TODO Auto-generated method stub 423 424 } 425 426 @Override 427 public void mediaMetaChanged(MediaPlayer mediaPlayer, int metaType) { 428 // TODO Auto-generated method stub 429 430 } 431 432 @Override 433 public void mediaSubItemAdded(MediaPlayer mediaPlayer, libvlc_media_t subItem) { 434 // TODO Auto-generated method stub 435 436 } 437 438 @Override 439 public void mediaDurationChanged(MediaPlayer mediaPlayer, long newDuration) { 440 // TODO Auto-generated method stub 441 442 } 443 444 @Override 445 public void mediaParsedChanged(MediaPlayer mediaPlayer, int newStatus) { 446 // TODO Auto-generated method stub 447 448 } 449 450 @Override 451 public void mediaFreed(MediaPlayer mediaPlayer) { 452 // TODO Auto-generated method stub 453 454 } 455 456 @Override 457 public void mediaStateChanged(MediaPlayer mediaPlayer, int newState) { 458 // TODO Auto-generated method stub 459 460 } 461 462 @Override 463 public void newMedia(MediaPlayer mediaPlayer) { 464 // TODO Auto-generated method stub 465 466 } 467 468 @Override 469 public void subItemPlayed(MediaPlayer mediaPlayer, int subItemIndex) { 470 // TODO Auto-generated method stub 471 472 } 473 474 @Override 475 public void subItemFinished(MediaPlayer mediaPlayer, int subItemIndex) { 476 // TODO Auto-generated method stub 477 478 } 479 480 @Override 481 public void endOfSubItems(MediaPlayer mediaPlayer) { 482 // TODO Auto-generated method stub 483 484 } 485 388 486 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/VideoPlayer.java
r28289 r28924 1 1 package org.openstreetmap.josm.plugins.videomapping.video; 2 import static org.openstreetmap.josm.tools.I18n.tr; 3 2 4 import java.awt.Adjustable; 3 4 import org.apache.log4j.Logger;5 import org.apache.log4j.helpers.DateTimeDateFormat;6 7 5 import java.awt.BorderLayout; 8 import java.awt.Canvas;9 6 import java.awt.Dimension; 10 7 import java.awt.FlowLayout; … … 14 11 import java.awt.event.WindowEvent; 15 12 import java.awt.event.WindowListener; 16 import java.beans.PropertyChangeListener;17 13 import java.io.File; 18 import java.sql.Time;19 14 import java.text.DateFormat; 20 import java.text.SimpleDateFormat; 21 import java.util.Date; 22 import java.util.HashSet; 23 import java.util.Hashtable ; 15 import java.util.Hashtable; 24 16 import java.util.LinkedList; 25 17 import java.util.List; 26 import java.util.Set;27 import java.util.TimeZone;28 18 import java.util.Timer; 29 19 import java.util.TimerTask; 30 import java.util.concurrent.TimeUnit; 31 import java.util.concurrent.Executors; 32 import java.util.concurrent.ScheduledExecutorService; 33 34 import javax.swing.Action; 20 35 21 import javax.swing.JButton; 36 import javax.swing.JComponent;37 22 import javax.swing.JFrame; 38 23 import javax.swing.JLabel; … … 40 25 import javax.swing.JSlider; 41 26 import javax.swing.JToggleButton; 42 import javax.swing.SwingUtilities;43 27 import javax.swing.event.ChangeEvent; 44 28 import javax.swing.event.ChangeListener; 45 29 46 import org.openstreetmap.josm.Main; 47 import org.openstreetmap.josm.plugins.videomapping.VideoObserver; 48 import static org.openstreetmap.josm.tools.I18n.*; 49 50 import uk.co.caprica.vlcj.binding.LibVlc; 51 import uk.co.caprica.vlcj.player.MediaPlayer; 52 import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter; 53 import uk.co.caprica.vlcj.player.MediaPlayerEventListener; 54 import uk.co.caprica.vlcj.player.MediaPlayerFactory; 55 import uk.co.caprica.vlcj.player.VideoMetaData; 56 import uk.co.caprica.vlcj.player.embedded.*; 57 import uk.co.caprica.vlcj.runtime.RuntimeUtil; 58 import uk.co.caprica.vlcj.runtime.windows.WindowsRuntimeUtil; 30 import uk.co.caprica.vlcj.player.DeinterlaceMode; 59 31 60 32 //basic UI of a videoplayer for multiple videos incl. notifications 61 public class VideoPlayer extends JFrame implements WindowListener, VideosObserver, VideoPlayerObserver {33 public class VideoPlayer extends JFrame implements WindowListener, VideosObserver, VideoPlayerObserver { 62 34 private static final int notificationIntervall = 500; 63 35 protected JPanel screenPanel,controlsPanel,canvasPanel; … … 66 38 private JToggleButton loop,mute; 67 39 private JSlider speed; 68 private DateFormat videoTimeFormat;40 // private DateFormat videoTimeFormat; 69 41 private VideoEngine videoengine; 70 42 private long jumpLength; … … 77 49 public VideoPlayer(DateFormat videoTimeFormat) throws HeadlessException { 78 50 super(); 79 this.videoTimeFormat=videoTimeFormat;51 // this.videoTimeFormat=videoTimeFormat; 80 52 //setup playback notifications 81 53 videoengine=new VideoEngine(this); … … 94 66 } 95 67 96 public Video addVideo(File Videofile, String id)97 { 98 Video video = new Video(Videofile,id );68 public Video addVideo(File Videofile, String id) 69 { 70 Video video = new Video(Videofile,id,videoengine.mediaPlayerFactory); 99 71 canvasPanel.add(video.panel); 100 72 video.canvas.setSize(new Dimension(300, 300)); // will be updated by the video engine itself … … 111 83 112 84 113 public void pause() {85 public void pause() { 114 86 videoengine.pause(); 115 87 if (videoengine.isNoVideoPlaying()) … … 143 115 } 144 116 145 public void setDeinterlacer( Stringdeinterlacer)117 public void setDeinterlacer(DeinterlaceMode deinterlacer) 146 118 { 147 119 videoengine.setDeinterlacer(deinterlacer); -
applications/editors/josm/plugins/videomapping/test/videotest.java
r25894 r28924 1 1 2 import java.awt.Canvas;3 import java.awt.Dimension;4 import java.awt.event.ActionEvent;5 import java.awt.event.ActionListener;6 2 import java.io.File; 7 3 import java.text.SimpleDateFormat; 8 4 9 import javax.swing.JButton;10 import javax.swing.JFileChooser;11 import javax.swing.JFrame;12 import javax.swing.JPanel;13 import javax.swing.JSlider;14 import javax.swing.event.ChangeEvent;15 import javax.swing.event.ChangeListener;16 17 5 import org.openstreetmap.josm.plugins.videomapping.video.VideoEngine; 18 6 import org.openstreetmap.josm.plugins.videomapping.video.VideoPlayer; 19 20 import uk.co.caprica.vlcj.player.*;21 22 7 23 8 //simple app to test videoplayer alone … … 31 16 testplayer.addVideo(new File("C:\\TEMP\\aoe-drachen_dvdscr.avi"),"2"); 32 17 testplayer.enableSingleVideoMode(true); 33 34 18 } 35 36 19 }
Note:
See TracChangeset
for help on using the changeset viewer.