×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    43

    Playing audio file from resource....

    Hi sir,
    i am vinay, i want to play any audio file which is given by me...could u please help me ...
    1. How can i add my audio file to my application
    2. Is there any base code for this to help me....

    i have this code...my audio file name is "ring.MP3"

    public void run()
    {
    try
    {
    InputStream is = getClass().getResourceAsStream("/ring.mp3");
    player = Manager.createPlayer(is,"audio/mpeg");

    player.realize();
    // get volume control for player and set volume to max
    vc = (VolumeControl) player.getControl("VolumeControl");
    if(vc != null)
    {
    vc.setLevel(100);
    }
    player.prefetch();
    player.start();
    }
    catch(Exception e)
    {}
    }



    how should i give the path....

    please help....

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

    Thumbs up Re: Playing audio file from resource....

    Hello,
    put the file in the res folder and add this folder to the project, depends upon the IDE you are using.
    And then you can read information over these links,
    http://developers.sun.com/mobility/m...mmapioverview/
    http://www.java2s.com/Tutorial/Java/...E/PlayMIDI.htm
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Ahemdabad
    Posts
    80

    Re: Playing audio file from resource....

    Quote Originally Posted by srinivasreddy501 View Post
    Hi sir,
    i am vinay, i want to play any audio file which is given by me...could u please help me ...
    1. How can i add my audio file to my application
    2. Is there any base code for this to help me....

    i have this code...my audio file name is "ring.MP3"

    public void run()
    {
    try
    {
    InputStream is = getClass().getResourceAsStream("/ring.mp3");
    player = Manager.createPlayer(is,"audio/mpeg");

    player.realize();
    // get volume control for player and set volume to max
    vc = (VolumeControl) player.getControl("VolumeControl");
    if(vc != null)
    {
    vc.setLevel(100);
    }
    player.prefetch();
    player.start();
    }
    catch(Exception e)
    {}
    }



    how should i give the path....

    please help....
    hello

    you just putting your mp3 file in res folder of your project directory ok then use this
    code line in your code

    InputStream is = getClass().getResourceAsStream("/res/ring.mp3");

  4. #4
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Smile Re: Playing audio file from resource....

    Put the audio file in res folder so that it can be a part of jar file. For the reference code to play the file you can refer to the sample project "MobileMediaApi" that is supplied with Wireless Toolkit 2.5.1

  5. #5
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Playing audio file from resource....

    place the media file in resource, add the resource(if using netbeans). Lots of examples over web. Have a search on web.
    thanks,
    jitu_goldie..

    KEEP TRYING..

Similar Threads

  1. Problem in Playing Audio file from Descriptor!
    By manish.agarw in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-09-12, 10:18
  2. [split] mbm build error
    By mando222 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2009-03-29, 12:32
  3. How to edit resource file (.rss) in CW 3.1
    By madsum in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 8
    Last Post: 2009-01-16, 15:00
  4. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  5. Problem in playing in an audio file.
    By PankajNeve in forum Symbian
    Replies: 3
    Last Post: 2007-03-09, 13:52

Posting Permissions

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