JavaFX에는 자체 미디어 플레이어가 있지만 MP4 파일을 재생할 수 있는지 여부는 알 수 없습니다. VLCJ를 사용할 수 있더라도 VLCJ를 사용하는 편이 좋을 것입니다. VLC는 더 가까운 형식과 품격을 지원합니다.VLCJ 및 JavaFX를 사용하여 비디오 파일을 재생하는 방법은 무엇입니까?
저는 Caprical이 그의 VLCJ-JavaFX GitHub에 게시 한 예제를 따라 왔지만 아무것도하지 않았습니다. 오류는 아니지만 아무것도 수행하지 않습니다. 그것은 제안 된 것
private final EventHandler<ActionEvent> nextFrame = new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
Memory[] nativeBuffers = mediaPlayerComponent.getMediaPlayer().lock();
if (nativeBuffers != null) { //<-----This is always NULL so everything in the block is skipped . . .
// FIXME there may be more efficient ways to do this...
// Since this is now being called by a specific rendering time, independent of the native video callbacks being
// invoked, some more defensive conditional checks are needed
Memory nativeBuffer = nativeBuffers[0];
if (nativeBuffer != null) {
ByteBuffer byteBuffer = nativeBuffer.getByteBuffer(0, nativeBuffer.size());
BufferFormat bufferFormat = ((DefaultDirectMediaPlayer) mediaPlayerComponent.getMediaPlayer()).getBufferFormat();
if (bufferFormat.getWidth() > 0 && bufferFormat.getHeight() > 0) {
pixelWriter.setPixels(0, 0, bufferFormat.getWidth(), bufferFormat.getHeight(), pixelFormat, byteBuffer, bufferFormat.getPitches()[0]);
}
}
}
mediaPlayerComponent.getMediaPlayer().unlock();
};
};
내가 로그를 얻을하지만 그건 내가 할로 무의식에 걸리고 있어요로 기다려야 할 것이다 : 코드로 보면
, 문제가 타임 라인 이벤트 핸들러에 보인다 이 게시물 (내가 살아있는 땅으로 돌아 왔을 때, 나는 어떤 것을 게시하기 위해 내가 할 수있는 일을 볼 것이다). 이 일을 가능하게하는 더 좋은 방법이 있다면, 누군가가 나를지도 할 수 있다면 나는 그것을위한 것입니다. 감사 ...
비디오가 재생되지 않기 때문에 nativeBuffers는 항상 null입니다. – caprica