本文整理汇总了Java中uk.co.caprica.vlcj.player.direct.DirectMediaPlayer类的典型用法代码示例。如果您正苦于以下问题:Java DirectMediaPlayer类的具体用法?Java DirectMediaPlayer怎么用?Java DirectMediaPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirectMediaPlayer类属于uk.co.caprica.vlcj.player.direct包,在下文中一共展示了DirectMediaPlayer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDisplay
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void onDisplay(DirectMediaPlayer mediaPlayer, int[] data) {
if (size != data.length) {
byteBuffer = ByteBuffer.allocateDirect(data.length * 4).order(ByteOrder.nativeOrder());
size = data.length;
}
IntBuffer intBuffer = byteBuffer.asIntBuffer();
intBuffer.put(data);
try {
Gdx2DPixmap pixmapData = new Gdx2DPixmap(byteBuffer, nativeData);
pixmap = new Pixmap(pixmapData);
// System.out.println("movie pixmap created : " + mediaPlayer.getTime() + " / " + mediaPlayer.getLength()
// + " data size : " + data.length * 4);
} catch (Exception e) {
pixmap = null;
throw new GdxRuntimeException("Couldn't load pixmap from image data", e);
}
}
示例2: initialize
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
/**
* Initialize the instance and create a new player.
*
* @param factory
* the factory for creating a new player
* @param volume
* the initial volume
*/
void initialize(final MediaPlayerFactory factory, final float volume) {
final MediaRenderer instance = this;
// Release the VLC player instance in the dedicated thread
mediaManager.executeThreadSafe(new Runnable() {
@Override
public void run() {
// Create the VLC media player instance
DirectMediaPlayer player = factory.newDirectMediaPlayer("RGBA", width, height, width * 4, instance);
player.setPlaySubItems(true);
player.setRepeat(true);
player.addMediaPlayerEventListener(listener = new PlayerEventListener(instance));
player.setVolume((int) (volume * 100));
instance.player = player;
}
});
}
示例3: display
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void display(DirectMediaPlayer mediaPlayer, Memory[] nativeBuffers, BufferFormat bufferFormat)
{
ByteBuffer buffer = nativeBuffers[0].getByteBuffer(0, bufferFormat.getWidth() * bufferFormat.getHeight() * 4);
videoImage.setData(buffer);
videoTexture.setImage(videoImage);
}
示例4: display
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void display(DirectMediaPlayer mediaPlayer, Memory[] nativeBuffers, BufferFormat bufferFormat) {
if (released) {
return;
}
buffer = nativeBuffers[0].getByteBuffer(0, width * height * 4);
}
示例5: display
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void display(DirectMediaPlayer mediaPlayer, Memory[] nativeBuffers, BufferFormat bufferFormat) {
if (writableImage == null) {
return;
}
Platform.runLater(() -> {
Memory nativeBuffer = mediaPlayer.lock()[0];
try {
ByteBuffer byteBuffer = nativeBuffer.getByteBuffer(0, nativeBuffer.size());
getPixelWriter().setPixels(0, 0, bufferFormat.getWidth(), bufferFormat.getHeight(), pixelFormat, byteBuffer, bufferFormat.getPitches()[0]);
} finally {
mediaPlayer.unlock();
}
});
}
示例6: display
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void display(DirectMediaPlayer mediaPlayer,
Memory[] nativeBuffers, final BufferFormat bufferFormat) {
final Memory nativeBuffer = nativeBuffers[0];
final ByteBuffer byteBuffer = nativeBuffer.getByteBuffer(0, nativeBuffer.size());
// we just store the latest references
tmpbuffer = byteBuffer;
tmpformat = bufferFormat;
}
示例7: onDisplay
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
protected void onDisplay(DirectMediaPlayer mediaPlayer, int[] rgbBuffer) {
// Simply copy buffer to the image and repaint
img.setRGB(0, 0, width, height, rgbBuffer, 0, width);
mediaPanel.repaint();
}
示例8: start
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
StackPane stack = new StackPane();
final Canvas canvas = new Canvas(1920, 1080);
final Label label = new Label("");
final VBox vBox = new VBox();
vBox.getChildren().add(label);
label.setStyle("-fx-font: 36px \"Segoe UI Semibold\";-fx-text-fill: white;");
StackPane.setMargin(label, new Insets(0, 10, 0, 0));
stack.getChildren().addAll(canvas, vBox);
Scene scene = new Scene(stack);
final PixelWriter pixelWriter = canvas.getGraphicsContext2D().getPixelWriter();
mp = new DirectMediaPlayerComponent(formatCallback) {
private AtomicLong totalTime = new AtomicLong(0);
private long totalFrames;
@Override
public void display(DirectMediaPlayer mediaPlayer,
Memory[] nativeBuffers, final BufferFormat bufferFormat) {
final Memory nativeBuffer = nativeBuffers[0];
final ByteBuffer byteBuffer = nativeBuffer.getByteBuffer(0, nativeBuffer.size());
totalFrames++;
Platform.runLater(() -> {
long startTime = System.currentTimeMillis();
pixelWriter.setPixels(0, 0, WIDTH, HIGHT, byteBgraInstance, byteBuffer, WIDTH * 4);
long renderTime = System.currentTimeMillis() - startTime;
totalTime.set(totalTime.longValue()+renderTime);
String s = String.format("Frames: %4d Avg.time: %4.1f ms (Max)FPS: %3.0f fps\n", totalFrames, (double) totalTime.longValue() / totalFrames, 1000.0 / ((double) totalTime.longValue() / totalFrames));
label.setText(s);
}
);
}
};
mp.getMediaPlayer().playMedia(MOVIE_FILE);
primaryStage.setScene(scene);
primaryStage.show();
}
示例9: display
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
@Override
public void display(DirectMediaPlayer mediaPlayer, com.sun.jna.Memory[] nativeBuffer, BufferFormat bufferFormat) {
}
示例10: onDisplay
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
/**
* Called on render, outputs video frame to image object.
*
* @param mediaPlayer
* The VLC Media player object.
* @param rgbBuffer
* The buffer holding the current video frame.
*
*/
@Override
protected void onDisplay(DirectMediaPlayer mediaPlayer, int[] rgbBuffer) {
image.setRGB(0, 0, width, height, rgbBuffer, 0, width);
jPanel.repaint();
}
示例11: getVLCJPlayer
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer; //导入依赖的package包/类
/**
* Get the underlying VLCJ player.
*
* @return the player
*/
DirectMediaPlayer getVLCJPlayer() {
return player;
}