Package javafx.scene.media

Examples of javafx.scene.media.Media


    final Group root = new Group();
    root.autosize();
    MediaUtils.activeMedia = sourceURL;
    final String trailer = MediaUtils.getMediaURL(sourceURL);
    try {
      media = new Media(trailer.trim());
    } catch (final Exception e) {
      MediaUtils.handleEndOfStream();
    }

    player = new MediaPlayer(media);
View Full Code Here


    public void loadMediaFile(String key, File file, boolean isMusic) {
        String uri = file.toURI().toString();
//        System.out.println("loading: " + file.toURI().toString() + " keyed as " + key);
        if (isMusic) {
            mediaMap.put(key, new Media(uri));
        } else {
            clipMap.put(key, new AudioClip(uri));
        }
    }
View Full Code Here

     * of the tracks without their extension.
     *
     * @param key
     */
    public void playMusic(String key) {
        Media temp = (mediaMap.get(key));
        if (temp == null) {
            System.out.println("Track key not found: " + key);
            return;//track not found, continue current music selection
        }

View Full Code Here

            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        JFXPanel fxPanel = new JFXPanel();
        Media media=new Media(mp3.toURI().toString());
        MediaPlayer mediaPlayer=new MediaPlayer(media);
        mediaPlayer.play();
        if(mp3.exists()){
            mp3.setWritable(true);
            System.out.println(mp3.delete());
View Full Code Here

    checkArgument(rate > 0);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Going to play " + mp3File);
    }
    try {
      final Media mp3Media = new Media(mp3File.toURI().toURL().toString());
      final MediaPlayer mediaPlayer = new MediaPlayer(mp3Media);
      synchronized (mediaPlayer) {
        mediaPlayer.setAutoPlay(false);
        mediaPlayer.setRate(rate);
        mediaPlayer.setOnEndOfMedia(new Runnable() {
View Full Code Here

    String[] strings = file.split("/");
    this.soundFile = strings[strings.length - 1];
    new Thread() {
      public void run() {
        try {
          sound = new MediaPlayer(new Media(soundFile.toURI().toString()));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }.start();
View Full Code Here

    public Clip(File sourceFile) {
    setClipLocation(sourceFile);
  }

    public void setClipLocation(File sourceFile) {
    media = new Media(sourceFile.toURI().toString());
    mediaPlayer = new MediaPlayer(media);
        if(media.getDuration() == Duration.UNKNOWN) {
            media.durationProperty().addListener((observable, oldValue, newValue) -> {
                length.set(media.getDuration().toMillis());
                fadeBeginTime.set(media.getDuration().toMillis());
View Full Code Here

        return VIDEO_ICON;
    }
    SoftReference<Media> mediaRef;

    public Media getMedia() throws IOException, MediaException {
        Media media = null;
        if (mediaRef != null) {
            media = mediaRef.get();
        }
        if (media != null) {
            return media;
        }
        final File cacheFile = getCacheFile(this.getId());
        if (cacheFile.exists() == false) {
            ContentUtils.writeToFile(this.getAbstractFile(), cacheFile);
        }
        try {
            media = new Media(Paths.get(cacheFile.getAbsolutePath()).toUri().toString());
            mediaRef = new SoftReference<>(media);
            return media;
        } catch (MediaException ex) {
            throw ex;
        }
View Full Code Here

         * @param mediaUri the location of the media.
         *
         * @return a MediaPlayer
         */
        private MediaPlayer createMediaPlayer(String mediaUri) {
            Media media = new Media(mediaUri);

            MediaPlayer player = new MediaPlayer(media);
            player.setOnReady(READY_LISTENER);
            player.setOnPaused(NOT_PLAY_LISTENER);
            player.setOnStopped(NOT_PLAY_LISTENER);
View Full Code Here

TOP

Related Classes of javafx.scene.media.Media

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.