解: 我们没有处理过2个问题。首先,虚拟监视器的大小为1366x768,而用户界面的初始化大小为1300x900。因此无法到达播放/暂停按钮。 第二个错误是,媒体播放器需要更多时间在跑步者中进行初始化。因此,在媒体播放器初始化之后,并且在状态应该交换到播放之后,需要循环来等待媒体播放器交换。以下设置方法为我们解决了问题:
@Before public void setup() throws Exception { media = new Media(getClass().getResource("small.mp4").toString()); mediaPlayer1 = new MediaPlayer(media); mediaPlayer1.setOnError(() -> fail("media error" + mediaPlayer1.getError().toString())); int retries = 0; while (mediaPlayer1.getStatus() != MediaPlayer.Status.READY) { System.out .println("media player not yet READY - current status: " + mediaPlayer1.getStatus()); sleep(100); retries++; if (retries > 10) { fail("waited too long for media player to get READY"); } } mediaView1 = find("#mediaView1"); mediaView1.setMediaPlayer(mediaPlayer1); mediaPlayer1.play(); retries = 0; while (mediaPlayer1.getStatus() != MediaPlayer.Status.PLAYING) { System.out .println("media player not yet PLAYING - current status: " + mediaPlayer1.getStatus()); sleep(100); retries++; if (retries > 10) { fail("waited too long for media player to get PLAYING"); } } }
这个gitlab ci是必需的:
maven_build: image: tomsontom/oracle-java8-mvn script: - cd Code - apt-get update && apt-get upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install openjfx xserver-xorg-video-dummy xserver-xorg-input-void xinit fonts-freefont-ttf pulseaudio pulseaudio-utils libavformat-ffmpeg56 wget libswt-gtk-3-java firefox -y - wget https://xpra.org/xorg.conf -O /etc/X11/xorg.conf - service dbus start - xinit -- :0 -nolisten tcp vt$XDG_VTNR -noreset +extension GLX +extension RANDR +extension RENDER +extension XFIXES & - DISPLAY=:0 pulseaudio --exit-idle-time=-1 & - DISPLAY=:0 mvn --batch-mode package - cd target && ls -la