Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

77
LINES

< > BotCompany Repo | #1016320 // VLCJ Player v2 (WORKS on Linux & Windows if VLC is installed)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 0K of libraries. Click here for Pure Java version (1775L/12K).

!7

lib 1400035 // vlcj player

import static uk.co.caprica.vlcjplayer.Application.application;

import uk.co.caprica.vlcj.player.embedded.*;
import uk.co.caprica.vlcjplayer.event.*;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
import uk.co.caprica.vlcj.log.NativeLog;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.runtime.streams.NativeStreams;
import uk.co.caprica.vlcjplayer.view.debug.DebugFrame;
import uk.co.caprica.vlcjplayer.view.effects.EffectsFrame;
import uk.co.caprica.vlcjplayer.view.main.MainFrame;
import uk.co.caprica.vlcjplayer.view.messages.NativeLogFrame;

static NativeStreams nativeStreams;
static JFrame mainFrame, messagesFrame, effectsFrame, debugFrame;
static NativeLog nativeLog;

p/*-subst*/ { // fullscreen still has a frame with Substance
  // This will locate LibVLC for the vast majority of cases
  new NativeDiscovery().discover();
  startPlayer();
  
  if (nempty(args)) {
    S fileToPlay = first(args);
    if (fileExists(fileToPlay)) {
      application().addRecentMedia(fileToPlay);
      application().mediaPlayerComponent().getMediaPlayer().playMedia(fileToPlay);
    }
  }
  
  hideConsole();
}

svoid startPlayer {
  swing {
    final EmbeddedMediaPlayerComponent mediaPlayerComponent = application().mediaPlayerComponent();
  
    mainFrame = new MainFrame();
    onWindowClosingDoOnly(mainFrame, r {
      mediaPlayerComponent.getMediaPlayer().stop();
      mediaPlayerComponent.release();
      if (nativeStreams != null) nativeStreams.release();
      application().post(ShutdownEvent.INSTANCE);
      cleanKillInNewThread();
    });
    
    EmbeddedMediaPlayer embeddedMediaPlayer = mediaPlayerComponent.getMediaPlayer();
    embeddedMediaPlayer.setFullScreenStrategy(new VlcjPlayerFullScreenStrategy(mainFrame));

    nativeLog = mediaPlayerComponent.getMediaPlayerFactory().newLog();

    messagesFrame = new NativeLogFrame(nativeLog);
    effectsFrame = new EffectsFrame();
    debugFrame = new DebugFrame();
    
    mainFrame.setVisible(true);
  }
}

sclass VlcjPlayerFullScreenStrategy extends DefaultAdaptiveRuntimeFullScreenStrategy {
  *(Window window) { super(window); }

  @Override
  protected void beforeEnterFullScreen() {
      application().post(BeforeEnterFullScreenEvent.INSTANCE);
  }

  @Override
  protected  void afterExitFullScreen() {
      application().post(AfterExitFullScreenEvent.INSTANCE);
  }
}

Author comment

Began life as a copy of #1016053

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016320
Snippet name: VLCJ Player v2 (WORKS on Linux & Windows if VLC is installed)
Eternal ID of this version: #1016320/13
Text MD5: 36937e9cbf7a959c2eff92c2b6462b34
Transpilation MD5: 13bf432ab8b65461ae16db91a81d903f
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-15 20:31:54
Source code size: 2551 bytes / 77 lines
Pitched / IR pitched: No / No
Views / Downloads: 602 / 1464
Version history: 12 change(s)
Referenced in: #1016314 - dm_showVideo
#1016326 - VLCJ Player (external frame, Dyn Module, dev.)
#1033431 - VLCJ Player v2 (testing with new VLCJ version)