×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    6

    Play Sound Effect while background sound playing problem

    Hi, im developing games for nokia S40 series
    i'm currently trying to play sound effect while the background music is playing
    and i can't find how to do it.
    i try to use 2 player, and the result is either the background music is stopped
    i try to create thread, and the sound effect didn't played

    how can i play the sound effect while background music still playing?
    thanks

  2. #2
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Play Sound Effect while background sound playing problem

    Hi Subzaku,

    What device are you using to play the sounds? Audio mixing (At least two players can be used to play back audio simultaneously) is supported starting from Series 40 5th edition and Series 60 3th edition devices.

    You can check if your phone supports audio mixing with
    Code:
    System.getProperty("supports.mixing")
    -tiviinik

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    6

    Re: Play Sound Effect while background sound playing problem

    im using nokia X2-03 simulator and device
    i already try print that, and it return true
    can u give me some code example to play 2 player?

  4. #4
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Play Sound Effect while background sound playing problem

    Hi subzaku,

    Below a small code snippet how to create multiple players.

    Code:
    private Hashtable players = new Hashtable();	
    
    public void addPlayer(String fileName,String type)
    {
    	try
    	{
    		InputStream is = Manager.class.getResourceAsStream(fileName);
    		Player player = Manager.createPlayer(is, type);
    
    		if(player !=null){
    			player.realize();
    			player.prefetch();
    
    			players.put(fileName, player);
    		}
    	}
    	catch (Exception ex){}
    }
    
    public void playSound(String fileName) 
    {
    	try 
    	{
    		Player player = (Player)players.get(fileName);
    
    		if(player !=null){
    			player.start();
    		}
    	}
    	catch (Exception e) {} 
    }

    Code:
    addPlayer("/test.wav", "audio/x-wav");
    addPlayer("/test2.wav", "audio/x-wav");
    
    playSound("/test.wav");
    playSound("/test2.wav");
    Link about pooling players:http://library.developer.nokia.com/i...387423B99.html

    Here you can find some other Java ME multimedia related articles.
    http://www.developer.nokia.com/Commu...media_Articles

    -tiviinik

Similar Threads

  1. Stop sound recording if another application wants to play sound
    By pedramz in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2009-07-14, 15:17
  2. Can't play sound in Sound Tab — Series 40 Theme Studio 2.2 — says: no sound support
    By alex_inside in forum Tools and SDK Feedback (Closed)
    Replies: 0
    Last Post: 2007-09-03, 20:56
  3. 6600 - Call test during sound playback causes sound not to play any more
    By hdazza in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2004-08-27, 15:59
  4. 6600 - Call test during sound playback causes sound not to play any more
    By hdazza in forum General Development Questions
    Replies: 0
    Last Post: 2004-08-27, 15:59
  5. How to play background sound on XHTML pages?
    By kaliliu in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2004-08-10, 13:32

Posting Permissions

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