@Override public void finished(MediaPlayer mediaPlayer) { // Used for YouTube videos List<String> subItems = mediaPlayer.subItems(); if (subItems != null && !subItems.isEmpty()) { String subItemURI = subItems.get(0); mediaPlayer.playMedia(subItemURI); } else { renderer.setState(RendererState.STOPPED); } }
@Override public void playing(MediaPlayer mediaPlayer) { renderer.setState(RendererState.PLAYING); long position = getSeekPosition(); if (position > 0) { mediaPlayer.setTime(position); } }
public PlayerInImage(int width, int height, JComponent frame, String media) { image = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .getDefaultConfiguration() .createCompatibleImage(width, height); image.setAccelerationPriority(1.0f); this.frame = frame; MediaPlayerFactory factory = new MediaPlayerFactory(new String[0]); mediaPlayer = factory.newDirectMediaPlayer(new TestBufferFormatCallback(), new TestRenderCallback()); mediaPlayer.setRepeat(true); // mediaPlayer.addMediaOptions(":file-caching=1500"); // mediaPlayer.setStandardMediaOptions(":file-caching=1500"); // mediaPlayer.setVolume(0); if (media != null) mediaPlayer.playMedia(media, ":file-caching=0"); System.err.println("PLAY!!! " + media); }
public void stop() { mediaPlayer.stop(); mediaPlayer.release(); }
@Override public void videoOutput(MediaPlayer mediaPlayer, int newCount) { Logger.debug("videoOutput(mediaPlayer={},newCount={})", mediaPlayer, newCount); if (newCount == 0) { return; } MediaDetails mediaDetails = mediaPlayer.getMediaDetails(); Logger.info("mediaDetails={}", mediaDetails); MediaMeta mediaMeta = mediaPlayer.getMediaMeta(); Logger.info("mediaMeta={}", mediaMeta); final Dimension dimension = mediaPlayer.getVideoDimension(); Logger.debug("dimension={}", dimension); if (dimension != null) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { videoSurface.setSize(dimension); mainFrame.pack(); } }); } // You can set a logo like this if you like... File logoFile = new File("./etc/vlcj-logo.png"); if (logoFile.exists()) { mediaPlayer.setLogoFile(logoFile.getAbsolutePath()); mediaPlayer.setLogoOpacity(0.5f); mediaPlayer.setLogoLocation(10, 10); mediaPlayer.enableLogo(true); } // Demo the marquee mediaPlayer.setMarqueeText("vlcj java bindings for vlc"); mediaPlayer.setMarqueeSize(40); mediaPlayer.setMarqueeOpacity(95); mediaPlayer.setMarqueeColour(Color.white); mediaPlayer.setMarqueeTimeout(5000); mediaPlayer.setMarqueeLocation(50, 120); mediaPlayer.enableMarquee(true); // Not quite sure how crop geometry is supposed to work... // // Assertions in libvlc code: // // top + height must be less than visible height // left + width must be less than visible width // // With DVD source material: // // Reported size is 1024x576 - this is what libvlc reports when you call // get video size // // mpeg size is 720x576 - this is what is reported in the native log // // The crop geometry relates to the mpeg size, not the size reported // through the API // // For 720x576, attempting to set geometry to anything bigger than // 719x575 results in the assertion failures above (seems like it should // allow 720x576) to me // mediaPlayer.setCropGeometry("4:3"); }
@Override public void playing(MediaPlayer mediaPlayer) { Logger.debug("playing(mediaPlayer={})", mediaPlayer); MediaDetails mediaDetails = mediaPlayer.getMediaDetails(); Logger.info("mediaDetails={}", mediaDetails); }
public void playing(MediaPlayer Player) { System.out.println("SPIELT!!"); /** Dies startet den Thread von der Klasse 'getTime' */ if (!gt.isAlive()) gt.start(); /** * Wenn der Thread durch einen Stopp angehalten wird (interrupted) so wird er wieder gestartet * wenn der Player spielt */ if (gt.isInterrupted()) gt.notifyThread(); /** * Wenn der Player eine MediaDatei abspielt so wird PlayerWindowModel.isPlaying() auf "true" * gesetzt, andernfalls auf "false" */ if (PlayerWindow.Player.isPlaying()) { PlayerWindowModel.setIsPlaying(true); } else { PlayerWindowModel.setIsPlaying(false); } DateFormat fulltime = new SimpleDateFormat("HH':'mm':'ss':'SSS"); playerwindowmodel.setFulltime(fulltime); playerwindowmodel.setPlayer(PlayerWindow.Player); /* * test2 wird false wenn i ist gleich vectorgröße * dadurch wird das weitere überprüfen verhindert */ boolean test2 = true; while (PlayerWindow.Player.isPlaying()) { boolean test = false; try { Vector<Vector<Object>> vectorbox = database.getDataVector(); importantValue = new long[vectorbox.size()]; if (i < vectorbox.size() && test2 == true) { int zaehler = 0; for (int j = 0; j < vectorbox.size(); j++) { importantValue[j] = (Long) vectorbox.elementAt(zaehler).elementAt(3); zaehler++; // System.out.println("Z�hler: " + zaehler); // System.out.println("J: " + j); } } if (getTime.tplayer() >= importantValue[i] && test2 == true) { SubTitleWindow.getNameEingabe().setText(vectorbox.elementAt(i).elementAt(0).toString()); SubTitleWindow.getTextEingabe().setText(vectorbox.elementAt(i).elementAt(1).toString()); /* Debug Ausgabe */ // System.out.println(vectorbox.size()); // System.out.println("change"); if (!test && i < vectorbox.size() - 1) { // System.out.println("vor increment" + i); i++; // System.out.println("nach increment" + i); test = true; if (i == vectorbox.size()) { test2 = false; } } } } catch (Exception e) { e.printStackTrace(); } PlayerWindowModel.setPlayTime(getTime.t()[0]); /** * Setzt die formartierte Zeit im String vom PlayerWindowModel. -3.600.000 weil sonst die * Uhr auf 12:00:00:000 stehen würde. */ PlayerWindowModel.setPlayTimeFull(fulltime.format(getTime.t()[0] - 3600000)); // TranscriptionWindowModel.setWert(PlayerWindowModel.getPlayTimeFull()); /** * Setzt den JSlider im Transkriptfenster auf die passende Stelle synchron mit der aktuellen * Position des Videos */ TranscriptionWindow.getVideo().setValue((int) (Player.getPosition() * 100)); // System.out.println("Wert: " + TranscriptionWindow.getVideo().getValue()); PlayWindow.getTimeLabel().setText(PlayerWindowModel.getPlayTimeFull()); // System.out.println(PlayWindow.getTimeLabel().getText()); /** * Holt sich die formatierte Zeit vom PlayerWindowModel und setzt sie in das Label vom * Transkriptfenster */ TranscriptionWindowModel.getZeit().setText(PlayerWindowModel.getPlayTimeFull()); } }