JavaFX MediaPlayer:MP4不会在Windows 7上循环播放 [英] JavaFX MediaPlayer: MP4 Won't Loop on Windows 7

查看:522
本文介绍了JavaFX MediaPlayer:MP4不会在Windows 7上循环播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个基本的JavaFX媒体播放器。在我的Windows 10操作系统上,一切正常,它的功能完全符合预期。

I've created a basic JavaFX Media Player. On my Windows 10 OS, everything works fine, and it functions exactly as it's supposed to.

private MediaPlayer initializeMediaPlayer(){
    Media media = new Media(getClass().getResource("1-1.mp4").toString());
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setAutoPlay(true);
    mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
    mediaPlayer.setRate(1.25);
    mediaPlayer.setMute(true);
    return mediaPlayer;
}

然而,当我在Windows 7上运行此代码时,视频不会循环:它播放五秒钟,在视频结束时,视频就会冻结。鉴于视频只有5秒长,循环对于此程序正常工作绝对必不可少。

Yet, when I run this code on Windows 7, the video doesn't loop: it plays for five seconds and at the end of the video, the video just freezes. Given that the video is only 5 seconds long, the loop is absolutely essential for this program to work properly.

以下是我对此问题的了解:

Here is what I know about this problem:


  • 问题仅存在于Windows 7上的mp4文件中。当使用oracle的示例.flv文件运行程序时(即 http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv ),它运作良好。将我的mp4文件转换为flv不是一个选项。

  • 该程序在我运行它的所有Windows 10计算机上都能正常工作。此问题仅发生在Windows 7中,但我没有在任何其他操作系统上测试它。我需要最终在只有Windows 7计算机的实验室中运行该程序。

  • 所有其他MediaPlayer参数(即set autoplay,setMute和setRate)在Windows 10和Windows中均可正常运行7.它只是在Windows 7上似乎不起作用的setCycleCount属性。

  • 在所有测试计算机上,我确保Java已更新到最新版本。我正在使用Java 8更新144。

  • The problem ONLY persists for mp4 files on Windows 7. When ran the program with oracle's example .flv file (i.e. http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv), it worked fine. Converting my mp4 files to flv is not an option.
  • The program works fine on all the Windows 10 computers I've run it on. This problem only occurs in Windows 7, but I have not tested it on any other operating systems. I need to eventually run this program in a lab with only Windows 7 computers.
  • All the other MediaPlayer parameters (i.e. set autoplay, setMute, and setRate) work fine in both Windows 10 and Windows 7. It's just the setCycleCount attribute that doesn't seem to work on Windows 7.
  • On all the test computers, I made sure the Java was updated to the most recent version. I am using Java 8 update 144.

推荐答案

JavaFX MediaPlayer不是那么好,我建议使用像LWJGL这样的外部库来获取声音。这在所有操作系统上都运行良好。

The JavaFX MediaPlayer isn't that good, I would recommend using an external library like LWJGL for sounds. That works really well on all operation systems.

在此处下载: https://www.lwjgl.org/

这篇关于JavaFX MediaPlayer:MP4不会在Windows 7上循环播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆