×

Discussion Board

Results 1 to 3 of 3

Thread: media exception

  1. #1
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    75

    Smile media exception

    when i try to execute the the below code i am getting the exception of type

    javax.microedition.media.MediaException: Can not acquire device
    at com.sun.mmedia.DirectPlayer.acquireDevice(), bci=52
    at com.sun.mmedia.DirectPlayer.doPrefetch(), bci=5
    at com.sun.mmedia.BasicPlayer.prefetch(), bci=26
    at com.sun.mmedia.PlayerImpl.prefetch(), bci=52
    at com.sun.mmedia.PlayerImpl.start(), bci=37
    at audioMidlet.OpenConnection(audioMidlet.java:119)
    at audioMidlet.startApp(audioMidlet.java:31)
    at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
    at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
    at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
    at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
    at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
    /=====================================================================

    StreamConnection connection = null;
    InputStream in = null;
    ByteArrayInputStream ain1 = null;
    StringBuffer buf=new StringBuffer();
    try{
    connection = (StreamConnection) Connector.open("http://172.17.14.67:8080/Nokia/res/obesity.amr");
    in= connection.openInputStream();
    //in=getClass().getResourceAsStream("http://172.17.14.67:8080/ThreeGVAS/english2.amr");
    String str=in.toString();
    byte[] b3=str.getBytes();
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(b3);
    in = new ByteArrayInputStream(b3);
    // in = new openByteArrayInputStream(byteArrayInputStream);
    int ch;
    while((byteArrayInputStream.read())!= -1)
    {
    mediaplayer = Manager.createPlayer(in,"audio/amr");
    // mediaplayer.start();
    System.out.println(byteArrayInputStream.read());
    }
    if((byteArrayInputStream.read())== -1){
    // mediaplayer = Manager.createPlayer(in,"audio/amr");
    if(mediaplayer!=null)
    mediaplayer.start();

    System.out.println("inside of read check");
    }
    System.out.println(buf.toString());

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    1

    Re: media exception

    I have exactly the same error for the same code. I tried many different codes first, however I realized soon enough that the problem is not in the code.
    Because when I tried this code (final jar and jad) on 2 different PCs, it worked great!
    So the problem is somewhere in the environment.
    I must say that I am a senior J2ME developer and configured successfully lots of J2ME environments in the past (even 4-5 month ago for 2 of my team members).
    But 2 weeks ago I had to switch my laptop (lenovo to a new one) and from this point and on I couldn't run simple j2me applications that plays amr or mp3 sound types.
    MIDI and WAV do work (I know strange...). I tried using Java ME 3.0 SDK and The old and verified WTK 2.5.2 but no luck.
    Also tried Nokia, Samsung and Sony Ericsson SDKs but all of them produced the same behavior - no sound is played (exception is thrown).
    I thought maybe there is something wrong with my JAVA/JRE/JDK installation but I reinstalled it couple of times with no success.

    I really don't understand what could cause the problem... Maybe it is some compatibility of software?

    I got:
    Lenovo W500 4GB
    Windows XP 32bit
    JDK 6 update 20 (tried also with older)
    WTK 2.5.2, Java ME SDK 3.0 and other emulators.

    IDE is not required to reproduce the error...

    Please help, I must use amr or mp3 in my projects and have no clue.

  3. #3
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: media exception

    have you tried to realize and prefetch the player instead of just starting it ?

Similar Threads

  1. Media Exception in playing a video
    By dhiraj.deka in forum Mobile Java General
    Replies: 3
    Last Post: 2009-12-09, 11:50
  2. s60 3rd ed emulator crash
    By Kimau in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-06-18, 22:12
  3. VS.Net 2003 Carbide 2.01 and epoc32.exe
    By ValentinK in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2007-01-12, 12:31
  4. SIP content type
    By hlothman in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2006-05-17, 09:26
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

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