×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    14

    Player object hangs before realize()

    Hi,

    I am trying to write code in J2ME for the Nokia SDK (S60 device) and am using Eclipse.

    The code tries to play some wav files placed within the "res" directory of the project. The code is as follows:
    Code:
      InputStream in1 = null;
            System.out.println("ABout to play voice:" + i);
            try {
                System.out.println("Getting the resource as stream.");
                in1 = getClass().getResourceAsStream(getsound(i));
                System.out.println("Got the resouce. Moving to get a player");
            }
            catch(Exception e) {
                e.printStackTrace();
            }
            try {
                try {
                    player = Manager.createPlayer(in1, "audio/x-wav");
                    System.out.println("Created audio/x-wav player.");
                } catch (MediaException e) {
                    player = Manager.createPlayer(in1, "audio/wav");
                    System.out.println("Created audio/wav player.");
                }
                player.addPlayerListener(this);
                System.out.println("Created player.");
                int state = player.getState();
                if(state == player.UNREALIZED) {
                    System.out.println("System is in unrealized state. Realizing it.");
                    try{
                        player.realize();
                    } catch (MediaException e) {
                        System.out.println("Caught an error in realizing the player.");
                    } catch (IllegalStateException e) {
                        System.out.println("Illegal state exception thrown.");
                    } catch (SecurityException e) {
                        System.out.println("Security exception thrown.");
                    }
                }
                if(state == player.REALIZED) {
                    System.out.println("The player has been realized.");
                    player.prefetch();
                    System.out.println("The player was prefetched.");
                }
                System.out.println("Fetched player. Now starting to play sound.");
                player.start();
                in1.close();
            }
            catch(Exception e) {
                e.printStackTrace();
            }
    Where the function getSound returns a string that contains the name of the file to be played. It is as follows:

    Code:
    private String getSound(int i) {
       switch(i) {  
         case 1: return "/x1.wav";
         case 2: return "/x2.wav";
       }
    }
    The class also implements PlayerListener for the class. The implementation is as follows:

    Code:
    public void playerUpdate(Player player, String event, Object eventData) {
            // TODO Auto-generated method stub
            if(event.equals(PlayerListener.END_OF_MEDIA) | event.equals(PlayerListener.STOPPED)) {
                System.out.println("Media ends. Closing player.");
                player.close();
                player = null;
            }
        }
    My problem is this:
    1. The application hangs after I have played about 3-4 sounds (I have a total of 10). I then have to restart the application.

    I have tried to debug this, but have not gotten any solutions so far.

    Another question:
    1. Could this be due to the fact that the simulation environment itself introduces some latency? I mean, if I was to create a JAD and install it on a phone, would it run correctly?

    It would be great if I could get some help on this.

    Thanks,
    Sriram

  2. #2
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Player object hangs before realize()

    does it always hangs on the same step?
    have you checked the memory occupation at this moment?
    does it throw any kind of exception?

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: Player object hangs before realize()

    Hi Shankar; help required;

    My app works fine in netbeans/emulator but when i install into my mobile, it takes time to finish "realize".

    I gave displays (to Form) before & after realize; The string before realize displayed but after realize is not;
    any help - how can i debug further here ? can you pl provide yr code around these sections. Thank you.

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Player object hangs before realize()

    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. e51 media player hangs on microSD media scaning
    By antonioriva in forum Audio
    Replies: 0
    Last Post: 2009-08-09, 20:50
  2. VideoStreaming player realize takes too long
    By cristi.mota in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2008-10-03, 10:29
  3. Why doesn't player realize on N73?
    By borje.granberg in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-10-10, 10:12
  4. What are realize and prefetch exactly ?
    By minasamy in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2007-06-18, 01:19
  5. how to realize such UI?
    By yinjialiang in forum Symbian User Interface
    Replies: 3
    Last Post: 2003-09-11, 08:17

Posting Permissions

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