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

64
LINES

< > BotCompany Repo | #1019320 // VLCJ Video Surface Test [Dyn Module, sometimes works (why?), needs VLC installed]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 0K of libraries. Click here for Pure Java version (14505L/102K).

!7

static LS _stickyLibs_vlcj = ll(#1400035);
lib 1400035 // vlcj player

import uk.co.caprica.vlcjplayer.Application;
import uk.co.caprica.vlcjplayer.event.*;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
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;

module VLCJTest > DynSCP {
  transient EmbeddedMediaPlayerComponent mediaPlayerComponent;
  transient EmbeddedMediaPlayer mediaPlayer;
  transient float position;
  
  start {
    doEvery(1000, r {
      if (mediaPlayer != null)
        if (setField(position := mediaPlayer.getPosition()))
          print("Video position: " + position);
    });
  }
  
  JComponent visualize2() {
    ret jcenteredbutton("Play a video...", r {
      selectFile("Video to play", voidfunc(final File f) { thread { playVideo(f); } })
    });
  }
  
  void playVideo(final File f) {
    temp enter();
    
    // This will locate LibVLC for the vast majority of cases
    new NativeDiscovery().discover();
    
    mediaPlayerComponent = Application.application().mediaPlayerComponent();
    setComponent(centerAndSouth(mediaPlayerComponent,
      withMargin(centeredButtons(
        "Play", r { if (mediaPlayer != null) mediaPlayer.play() },
        "Pause", r { if (mediaPlayer != null) mediaPlayer.pause() },
        "Stop", r { if (mediaPlayer != null) mediaPlayer.stop() },
    ))));
    
    mediaPlayer = mediaPlayerComponent.getMediaPlayer();
    
    swing {
      mediaPlayer.playMedia(f2s(f));
      mediaPlayer.play();
      mediaPlayer.setVolume(100);
      print("Audio descriptions: " + mediaPlayer.getAudioDescriptions());
    }
  }
  
  void cleanMeUp_vlcj {
    if (mediaPlayer != null) {
      mediaPlayer.release();
      mediaPlayer = null;
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019320
Snippet name: VLCJ Video Surface Test [Dyn Module, sometimes works (why?), needs VLC installed]
Eternal ID of this version: #1019320/27
Text MD5: 458e95daafa1940ac209c35c104b3b39
Transpilation MD5: 4b08748ba132ffccf8c9da5ca34c7765
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-11 01:49:42
Source code size: 2005 bytes / 64 lines
Pitched / IR pitched: No / No
Views / Downloads: 462 / 1242
Version history: 26 change(s)
Referenced in: #1019971 - Download video from YouTube & play in VLCJ frame