×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    81

    MP4 Player -- MediaException

    Code:
    FileConnection fileConnection = (FileConnection) Connector.open(absolutePath); //absolutePath = file:///C:/Data/Sounds/test.mp4
    InputStream inputStream = fileConnection.openInputStream();
    byte [] fileBytes = new byte [((int) fileConnection.fileSize())];
    int totalBytesRead = 0;
    int fileSize = fileBytes.length;
    int bytesRead = 0;
    while(totalBytesRead < fileSize){
    	bytesRead = inputStream.read(fileBytes, totalBytesRead, fileSize);
    	totalBytesRead += bytesRead;
    }
    System.out.println("total bytes read: " + totalBytesRead);
    System.out.println("file size: " + fileSize);
    
    inputStream.close();
    InputStream inStream = new ByteArrayInputStream(fileBytes);
    System.out.println("inStream OK");
    Player player = Manager.createPlayer(inStream, "video/mp4");
    System.out.println("Player OK");
    fileConnection.close();

    the code above throws the Exception: javax.microedition.media.MediaException: Could not create player.

    the print outs:
    total bytes read: 8939164
    file size: 8939164
    inStream OK
    Exception e: javax.microedition.media.MediaException: Could not create player.
    im trying to use it to create a Player Object with a video mp4 file. this same code works for music files...

    in addition, when i tried
    Code:
    Player player = Manager.createPlayer(absolutePath);
    it works. so, why i cant use an InputStream to do it? how can i fix it?

  2. #2
    Registered User
    Join Date
    Oct 2009
    Posts
    34

    Re: MP4 Player -- MediaException

    HI
    can you tell me on which handset you are running your application.May be you handset does'nt support mp4 file
    dont lose hope

  3. #3
    Regular Contributor
    Join Date
    Dec 2008
    Location
    Mumbai
    Posts
    199

    Smile Re: MP4 Player -- MediaException

    hi frnd,

    if you are testing your application onsun emulator then it will not play.because sun emulator support only mpg media file.try your application on nokia device which support mp4 file format.

    reply

    thanks
    Ajay Prajapati
    Mobile Software Developer
    Mumbai,India

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    14

    Question Re: MP4 Player -- MediaException

    Quote Originally Posted by prajapati.ajay View Post
    hi frnd,

    if you are testing your application onsun emulator then it will not play.because sun emulator support only mpg media file.try your application on nokia device which support mp4 file format.

    reply

    thanks
    Hello Ajay.

    Could you please tell me are sun emulators supporting mp3 files?
    I am using Series 40 5th edition SDK, with code similar to the Chameleon's and am trying to play audio file.
    I am getting IllegalAccessException.
    Using this code for file location
    Code:
    InputStream is = getClass().getResourceAsStream("/bark.wav");
    First i tried with mp3 file. Didnt work, buit it doesn work with wav files also.

  5. #5
    Regular Contributor
    Join Date
    Dec 2008
    Location
    Mumbai
    Posts
    199

    Smile Re: MP4 Player -- MediaException

    hi frnd

    IllegalAccessException this exception is might coming due to you r not using resurcestrea properly.

    but if you want to know supported media by your s40 phone then use this method
    It will return array(String) in that you can see which type of music and video and image supports your phone.

    Manager.getSupportedContentTypes(null)

    reply

    thanks
    Ajay Prajapati
    Mobile Software Developer
    Mumbai,India

  6. #6
    Registered User
    Join Date
    Oct 2009
    Posts
    14

    Smile Re: MP4 Player -- MediaException

    To Ajay:

    Already tried Manager.getSupportedContentTypes(null) and nothing,
    i think it works only with actual device, not with emulator, i do not know.

    I have spent too much time trying to play mp3 file, i will have to post code on forum to get some help.
    And i have tried every possible way i could find on net to play that mp3 file.
    Something is missing or i am not doing it right.

    Anyhow, thanks for your answer Ajay!

  7. #7
    Regular Contributor
    Join Date
    Dec 2008
    Location
    Mumbai
    Posts
    199

    Smile Re: MP4 Player -- MediaException

    hi frnd

    dont loose hope...
    You r also right.
    i was also stuck in same problem,but i was using S60 3rd Edition FP1.in this emulator was showing that it doesnt support any video file.but when i install that application in E61.video is playing easly..

    so try on real device

    thanks
    Ajay Prajapati
    Mobile Software Developer
    Mumbai,India

  8. #8
    Registered User
    Join Date
    Oct 2009
    Posts
    14

    Smile Re: MP4 Player -- MediaException

    Quote Originally Posted by prajapati.ajay View Post
    hi frnd

    dont loose hope...
    You r also right.
    i was also stuck in same problem,but i was using S60 3rd Edition FP1.in this emulator was showing that it doesnt support any video file.but when i install that application in E61.video is playing easly..

    so try on real device

    thanks
    Thanks for encouragement friend!
    I am never giving up.

    Best of luck!

Similar Threads

  1. Buggy AMR Audio Recording. Please Help!!
    By jhamby in forum Symbian
    Replies: 8
    Last Post: 2009-07-07, 10:34
  2. Replies: 4
    Last Post: 2009-07-07, 10:07
  3. Could Not Create Player MediaException
    By epilot in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2009-05-06, 05:07
  4. Need help of my newest MP4 player?
    By magis1 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-12-31, 08:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×