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

80
LINES

< > BotCompany Repo | #1033431 // VLCJ Player v2 (testing with new VLCJ version)

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

Download Jar. Uses 383K of libraries. Compilation Failed (8103L/47K).

!7

lib 1400522 // 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
  pnl(addMegaLibrary(myClassLoader(), #1400524);
  fixContextClassLoader();
  
  // 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 #1016320

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033431
Snippet name: VLCJ Player v2 (testing with new VLCJ version)
Eternal ID of this version: #1033431/1
Text MD5: 7d55dd6640c6d35913f8730a1fc45c54
Transpilation MD5: 9033b308301744d619d5a4f9734c08b0
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-27 13:47:24
Source code size: 2633 bytes / 80 lines
Pitched / IR pitched: No / No
Views / Downloads: 198 / 754
Referenced in: [show references]