|
| 1 | +/* |
| 2 | + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. Oracle designates this |
| 8 | + * particular file as subject to the "Classpath" exception as provided |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. |
| 10 | + * |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | + * accompanied this code). |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License version |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | + * |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | + * or visit www.oracle.com if you need additional information or have any |
| 23 | + * questions. |
| 24 | + */ |
| 25 | + |
| 26 | +import javafx.application.Application; |
| 27 | +import javafx.scene.Scene; |
| 28 | +import javafx.scene.control.Label; |
| 29 | +import javafx.scene.layout.VBox; |
| 30 | +import javafx.scene.web.WebView; |
| 31 | +import javafx.stage.Stage; |
| 32 | + |
| 33 | +public class HTML5VideoControlTest extends Application { |
| 34 | + @Override |
| 35 | + public void start(Stage primaryStage) { |
| 36 | + WebView webView = new WebView(); |
| 37 | + webView.getEngine().loadContent( |
| 38 | + "<video width=\"320\" height=\"240\" controls>\n" + |
| 39 | + " <source src=\"https://download.oracle.com/otndocs/products/javafx/oow2010-2.mp4\">\n" + |
| 40 | + " Your browser does not support the video tag.\n" + |
| 41 | + "</video>" |
| 42 | + ); |
| 43 | + |
| 44 | + VBox root = new VBox(); |
| 45 | + root.setSpacing(20); |
| 46 | + |
| 47 | + root.getChildren().addAll(createInstructionsBox(), webView); |
| 48 | + |
| 49 | + Scene scene = new Scene(root, 800, 400); |
| 50 | + primaryStage.setScene(scene); |
| 51 | + primaryStage.setTitle("HTML5 Video Player with Instructions"); |
| 52 | + primaryStage.show(); |
| 53 | + } |
| 54 | + |
| 55 | + private VBox createInstructionsBox() { |
| 56 | + VBox instructionsBox = new VBox(); |
| 57 | + instructionsBox.setStyle("-fx-background-color: #f0f0f0;"); |
| 58 | + instructionsBox.setPrefWidth(400); |
| 59 | + |
| 60 | + instructionsBox.getChildren().addAll( |
| 61 | + new Label("Instructions:"), |
| 62 | + new Label("1. Click 'Play' to start the video."), |
| 63 | + new Label("2. The media controls should be visible once the video starts playing."), |
| 64 | + new Label("3. Use the media controls to play/pause/seek the video.") |
| 65 | + ); |
| 66 | + |
| 67 | + return instructionsBox; |
| 68 | + } |
| 69 | + |
| 70 | + public static void main(String[] args) { |
| 71 | + launch(args); |
| 72 | + } |
| 73 | +} |
0 commit comments