×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2007
    Location
    Mumbai, India
    Posts
    54

    Player p becomes null after it has started playing audio

    Hi,
    I am trying to play some audio in a j2me app. I send a request for an audio file, after I recieve the response, I start a player and play the audio file :


    ByteArrayInputStream is = new ByteArrayInputStream(b);


    p = Manager.createPlayer(is,"audio/midi");

    p.realize();
    p.prefetch();
    p.start();

    The Player p is declared globally.

    After the player starts playing the audio, the value of 'p' becomes null.

    So, in my 'keyPressed' method :

    if (p != null) {
    if (p.getState() == Player.STARTED)
    {
    p.stop();
    p.deallocate();
    }
    } catch ( Exception ex) {
    ex.printStackTrace();
    System.out.println(ex.toString());
    }

    The control never reaches p.stop, as p is always equal to null.

    Is there any other way to control audio in j2me ?

    Thanks in advance.

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Player p becomes null after it has started playing audio

    Are you sure you have not declared any variable or parameter named p in the class which contains the keyPressed method?

    Hartti

Similar Threads

  1. AMR audio streaming player
    By antix in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-03-13, 01:12
  2. 3500 (s40) playing audio problem
    By ahmadi2c in forum Mobile Java General
    Replies: 2
    Last Post: 2007-03-07, 08:03
  3. Callback after audio file stopped playing
    By gojkoa in forum Symbian
    Replies: 6
    Last Post: 2005-11-18, 09:11
  4. Audio Player / MMAPI Class
    By laukikwatve in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-07-06, 11:54
  5. Nokia Communicator, with its C++ Audio player for Symbian OS
    By mkavianpour in forum Mobile Java General
    Replies: 0
    Last Post: 2002-07-19, 14:59

Posting Permissions

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