Current Position:Home > Did you hit this error before in javafx MediaPlayer?

Did you hit this error before in javafx MediaPlayer?

Update:10-11Source: network consolidation
Advertisement
Hi,All
I 'd like to make a javafx mediaplayer to play mp3 ,and I found some of mp3 wouldn't be supported by javafx mediaplayer,I don't know how can I solve this bug?
I posted a mp3 file to the public network ,if you are interested in this issue, you can download this mp3 from this line for test.
https://www.dropbox.com/s/wk2i9amk0kczqxe/And%20the%20Cradle%20Will%20Rock.mp3
*mediaPlayer.getError() = MediaException: UNKNOWN : [[email protected]] "Error media invalid": "Error media invalid"*
Exception Message:
* Copyright (c) 2008, 2011 Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
import java.io.File;
import javafx.application.Application;
import javafx.scene.media.AudioSpectrumListener;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.stage.Stage;
* An example of an AnchorPane layout.
* @see javafx.scene.layout.AnchorPane
* @related controls/text/SimpleLabel
* @resource icon-48x48.png
public class AnchorPaneSample extends Application {
     private MediaPlayer mediaPlayer;
     private Media media;
     private AudioSpectrumListener spectrumListener;
     private void init(Stage primaryStage) {
          initializeMp3();
    public void initializeMp3()
         if (mediaPlayer != null )
            mediaPlayer.stop();
            mediaPlayer.setAudioSpectrumListener(null);
         String fullpath="C:/And the Cradle Will Rock.mp3";//please download this mp3 from this line ,https://www.dropbox.com/s/wk2i9amk0kczqxe/And%20the%20Cradle%20Will%20Rock.mp3
         File file=new File(fullpath);
          media=new Media(file.toURI().toString());
         mediaPlayer=new MediaPlayer(media);
         mediaPlayer.setAutoPlay(true);
         mediaPlayer.setAudioSpectrumNumBands(10);
        mediaPlayer.setAudioSpectrumListener(spectrumListener);
        mediaPlayer.setAudioSpectrumInterval(1d/30d);
         mediaPlayer.setOnError(new Runnable() {
             @Override public void run() {
                 System.out.println("mediaPlayer.getError() = " + mediaPlayer.getError());
         mediaPlayer.setOnEndOfMedia(new Runnable(){
               @Override public void run() {
                        //todo
    @Override public void start(Stage primaryStage) throws Exception {
        init(primaryStage);
        primaryStage.show();
    public static void main(String[] args) { launch(args); }
}Edited by: imtoocute on May 22, 2012 11:21 AM
Edited by: imtoocute on May 22, 2012 11:22 AM
Edited by: imtoocute on May 22, 2012 11:34 AM

The Best Answer

Advertisement
It appears that the file is actually encoded as aac, not mp3. Try changing the file extension and see if that doesn't help.
We'll look at handling this sort of discrepancy, but I'm not sure how reliably we will be able to detect this condition.
General / Container Stream #1
     Total Audio Streams for this File.................1
     Audio Codecs Used.................................AAC LC
     File Format.......................................MPEG-4
     Play Time.........................................3mn 0s
     Total File Size...................................6.62 MiB
     Total Stream BitRate..............................308 Kbps
     Title (Tag).......................................And the Cradle Will Rock...
     Copyright (Tag)...................................2011 Rockabye Baby! Music
Audio Stream #1
     Codec.............................................AAC
     Codec (FourCC)....................................40
     Audio Stream Length...............................3mn 0s 513ms
     Audio Stream BitRate..............................304 Kbps
     Audio Stream BitRate Mode.........................VBR
     Number of Audio Channels..........................2
     Audio Channel's Positions.........................Front: L R
     Sampling Rate.....................................44.1 KHz
     Audio Stream Size.................................6.55 MiB (99%)
     Date of Original Encoding.........................UTC 2011-11-09 18:50:15
Menu / Chapters Stream #1
  • Did you hit this error before in javafx MediaPlayer? Update:10-11

    Hi,All I 'd like to make a javafx mediaplayer to play mp3 ,and I found some of mp3 wouldn't be supported by javafx mediaplayer,I don't know how can I solve this bug? I posted a mp3 file to the public network ,if you are interested in this issue, you

  • Unattend Hit an error while pulling drivers from Network Share Update:11-30

    Hi All, I've run into an error with installing apps from network share via SynchronousCommands under Specialize pass in unattended answer file. I been trying to work on it since yesterday and haven't had any success so far. It keeps failing with an e

  • Hit 401 error Update:11-30

    Hi, Once in a while I hit 401 error on the server. On the client some of the operations dont go through. LIke cant upload document drop menu dont show... The site has both formbased and windows based login enabled. loopback check is disabled on the s

  • Running Xcode 3.2.3 for the first time, hitting an error immediately Update:10-11

    Hello. I'm learning Objective-C from a book ("Beginning Mac Programming"), and I've run into an error right out of the gate. I've checked the book's errata, as well as left a message with the author, but neither have solved the issue. Here's wha

  • CSS Error in running javafx application after move to use jdk8 Update:10-11

    Hi all, I'm running an javafx app fine with build: jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012 which uses jdk7 perfectly fine on the raspberry pi (which i also keep as backup until newer builds well, are starting to work with my app). I'm getting an exc

  • Getting GTK error while running javaFX application on linux Update:10-11

    I developed an JavaFX application that works fine on Windows. So, I tried to run this same application on Linux (ubuntu x86) and it is not working. I setup all the environment with following this article : http://docs.oracle.com/javafx/2.0/release_no

  • Java run time error while executing JavaFX code Update:10-11

    Hi I copied the code from [http://java.sun.com/javafx/1/tutorials/ui/overview/UIControls.fx|http://java.sun.com/javafx/1/tutorials/ui/overview/UIControls.fx] while reading in [http://java.sun.com/javafx/1/tutorials/ui/overview/#controls|http://java.s

  • Potential error with published JavaFX applet? Update:10-11

    Hi there This is a "strange" request. I have recently published a JavaFX app on-line and broadcast a link to it via my blog. Before doing so I successfully tested it on my machines at home (OS X and Win XP) and at work (Win XP and OS X). However

  • Hit Runtime ERROR Update:11-30

    HI, This message appears at the bottom of the screen when i execute my program.     "Runtime error TIME_OUT has occurred" When i debug the program, it seems to take longer time than expected at this FM     "HR_INFOTYPE_OPERATION" When

  • Uncaught exception: java.lang.Error: 137 in JavaFX Update:11-30

    Hi I am getting the error mentioned in subject while trying to Run a JavaFX application "Run in Mobile Emulator" mode. I am trying to use split() to separate concatenated String. The code snippet is given below : *onMouseClicked: function(e : Mo