Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my code I getting an error in two lines. I just want you to find the error and if you can please code

image text in transcribed

Here is my code I getting an error in two lines. I just want you to find the error and if you can please code the loop button for me. Thank you

package Lab3media; import java.io.File; import javafx.application.Application; import javafx.stage.Stage; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; import javafx.scene.media.Media; import javax.swing.JFileChooser; import javafx.scene.media.MediaPlayer; import javafx.scene.media.MediaView; import javafx.util.Duration; import javax.swing.filechooser.FileSystemView; import javafx.event.ActionEvent; import javafx.event.EventHandler;

public class Lab3media extends Application { private static final String MEDIA_URL = "http://cs.armstrong.edu/liang/common/sample.mp4";

@Override public void start(Stage primaryStage) { Media media; JFileChooser fc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory()); int retval = fc.showOpenDialog(null); if(retval == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); media = new Media(file.toURI().toString()); } else{ media = new Media(MEDIA_URL); } MediaPlayer mediaPlayer = new MediaPlayer(media); MediaView mediaView = new MediaView(mediaPlayer); mediaView.preserveRatioProperty(); mediaView.setFitHeight(450); mediaView.setFitWidth(450);

Button playButton = new Button("play"); playButton.setOnAction(e -> { if (playButton.getText().equals("play")) { mediaPlayer.play(); playButton.setText("pause"); } else { mediaPlayer.pause(); playButton.setText("play"); } }); Button rewindButton = new Button(" mediaPlayer.seek(Duration.ZERO));

Slider slVolume = new Slider(); slVolume.setPrefWidth(150); slVolume.setMaxWidth(Region.USE_PREF_SIZE); slVolume.setMinWidth(30); slVolume.setValue(50); mediaPlayer.volumeProperty().bind( slVolume.valueProperty().divide(100));

HBox hBox = new HBox(10); hBox.setAlignment(Pos.CENTER); hBox.getChildren().addAll(playButton, rewindButton, new Label("Volume"), slVolume);

BorderPane pane = new BorderPane(); pane.setCenter(mediaView); pane.setBottom(hBox);

// Create a scene and place it in the stage Scene scene = new Scene(pane, 650, 500); primaryStage.setTitle("MediaDemo"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage } public static void main(String[] args) { launch(args); } }

javafx- EventHanc x0133593517pdf x D Module3Notes (2 x G media playerjava/X File l C:/L CS282Lab03 (3).pdf 1/2 Build a JavaFX GUI application that will use the JavaFX AudioClip class. Your program will must contain the following features . Use the JFileChooser to allow the user to select an audio file to play 2. A label control to show the path/filename of the selected audio file 3. A Play button that will play the file one time. 4. A Loop button that will play the file in a continuous loop 5. A Stop button to stop playback 6. A Slider control to set the audio volume and appropriate control labeling. Specific layout of the user interface is up to your creative talents. You may use any of the JavaFX panes and layout the nodes however you wish. It should be reasonably clean. A sample GUl is provided below to give a general idea. Audio Player Play Loop Stop Volume: Note: With the AudioClip class, volume must be set by the user before starting playback. Changing volume while the audio clip is playing doesn't work. Don't waste your time fighting with this. A sample MP3 audio file is provided in the lab folder on Canvas. You may use any MP3 files of your own for testing. O Type here to search 3/3/2019

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

LO2 Explain the nature of the psychological contract.

Answered: 1 week ago