List of usage examples for javafx.scene.media MediaPlayer statusProperty
public ReadOnlyObjectProperty<Status> statusProperty()
From source file:com.tesshu.subsonic.client.sample4_music_andmovie.StreamPlayApplication.java
@Override public void start(Stage stage) throws Exception { Search2Controller search2 = context.getBean(Search2Controller.class); StreamController streamController = context.getBean(StreamController.class); SuccessObserver callback = context.getBean(SuccessObserver.class); SearchResult2 result2 = search2.get("t", null, null, null, null, 1, null, null); Child song = result2.getSongs().get(0); final IRequestUriObserver uriCallBack = (subject, uri) -> { uriStr = uri.toString();/*from ww w . j a v a 2 s. c o m*/ }; streamController.stream(song, 128, // maxBitRate format, // format null, // timeOffset null, // size(Do not use it for video) true, // estimateContentLength null, // converted(Do not use it for video) null, // streamCallback uriCallBack, callback); Group root = new Group(); Scene scene = new Scene(root, 640, 480); Media media = new Media(uriStr); media.errorProperty().addListener((observable, old, cur) -> { LOG.info(cur + " : " + uriStr); }); MediaPlayer player = new MediaPlayer(media); player.statusProperty().addListener((observable, old, cur) -> { LOG.info(cur + " : " + uriStr); }); MediaView view = new MediaView(player); ((Group) scene.getRoot()).getChildren().add(view); stage.setScene(scene); stage.show(); player.play(); }
From source file:com.tesshu.subsonic.client.sample4_music_andmovie.StreamPlayMovieApplication.java
@Override public void start(Stage stage) throws Exception { Search2Controller search2 = context.getBean(Search2Controller.class); StreamController streamController = context.getBean(StreamController.class); SuccessObserver callback = context.getBean(SuccessObserver.class); SearchResult2 result2 = search2.get("CORPSE BRIDE", // query, required = true 0, // artistCount, required = false null, // artistOffset, required = false 0, // albumCount, required = false null, // albumOffset, required = false 10, // songCount, required = false null, // songOffset, required = false null // musicFolderId, required = false );/*from w w w . j av a2s. c om*/ Child movie = result2.getSongs().stream().filter(child -> MediaType.VIDEO == child.getType()) .filter(child -> format.equals(child.getSuffix())).collect(Collectors.toSet()).iterator().next(); LOG.info(ToStringBuilder.reflectionToString(movie, ToStringStyle.MULTI_LINE_STYLE)); // not valid?(Perhaps, I have not done convert setting on the server side) @SuppressWarnings("unused") String size = Integer.toString(movie.getOriginalWidth()) + "x" + Integer.toString(movie.getOriginalHeight()); final IRequestUriObserver uriCallBack = (subject, uri) -> { uriStr = uri.toString(); }; streamController.stream( movie, // id null, // maxBitRate format, // format null, // timeOffset null, // size true, // estimateContentLength false, // converted null, // streamCallback uriCallBack, callback); Group root = new Group(); Scene scene = new Scene(root, movie.getOriginalWidth(), movie.getOriginalHeight()); Media media = new Media(uriStr); media.errorProperty().addListener((observable, old, cur) -> { LOG.info(cur + " : " + uriStr); }); MediaPlayer player = new MediaPlayer(media); player.statusProperty().addListener((observable, old, cur) -> { LOG.info(cur + " : " + uriStr); }); MediaView view = new MediaView(player); ((Group) scene.getRoot()).getChildren().add(view); stage.setScene(scene); stage.show(); player.play(); }
From source file:AudioPlayer3.java
private void addListenersAndBindings(final MediaPlayer mp) { mp.statusProperty().addListener(statusListener); mp.currentTimeProperty().addListener(currentTimeListener); mp.totalDurationProperty().addListener(new TotalDurationListener()); mp.setOnEndOfMedia(new Runnable() { @Override//from w w w. ja v a 2s .c o m public void run() { songModel.getMediaPlayer().stop(); } }); volumeSlider.valueProperty().bindBidirectional(mp.volumeProperty()); }
From source file:AudioPlayer3.java
private void removeListenersAndBindings(MediaPlayer mp) { volumeSlider.valueProperty().unbind(); mp.statusProperty().removeListener(statusListener); mp.currentTimeProperty().removeListener(currentTimeListener); }