×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    2

    I can not play music on S60

    Hello!
    I use Eclipse3.2 + NDS3.0. The platform is S60.
    I want to play music in my application by MMAPI and the format of music files is midi.
    But when I create the player,I caught the Exception:

    MMA : Exception during remote invocation
    javax.microedition.media.MediaException: cannot create player

    codes:

    public void setMusic(Hashtable h) {
    String musicPath = (String) h.get("musicPath");
    String volume = (String) h.get("musicVolume");
    int musicVolume = Integer.parseInt(volume);
    String muted = (String) h.get("musicIsMuted");
    InputStream inputStream = getClass().getResourceAsStream("/" + musicPath);
    try {
    if (player == null) {
    player = Manager.createPlayer(inputStream, "audio/midi");
    }
    player.realize();
    vc = (VolumeControl) player.getControl("VolumeControl");
    if (vc != null) {
    if ("true".equals(muted)) {
    vc.setMute(true);
    }
    if ("false".equals(muted)) {
    vc.setMute(false);
    }
    vc.setLevel(musicVolume);
    }

    player.prefetch();
    player.start();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (MediaException e) {
    e.printStackTrace();
    }
    }

    Thanks!

  2. #2
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    Re: I can not play music on S60

    Look at the examples in the Sun Wireless Tool Kit, or the Nokia MMAPI demo. They give examples of how you open a MIDI file from with the JAR.

    For debugging purposes, it may be easier to replace
    String musicPath = (String) h.get("musicPath");
    InputStream inputStream = getClass().getResourceAsStream("/" + musicPath);
    int musicVolume = Integer.parseInt(volume);

    with
    InputStream is = getClass().getResourceAsStream("/your/full/path");
    int musicVolume = 100;


    or even simpler, place the MIDI file in the src dir and just call it directly
    InputStream is = getClass().getResourceAsStream("/yourFile.mid");

    and try again. The mistake is probably the location of the file.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    2

    Re: I can not play music on S60

    Thanks for replying.
    I try as you said,but still not work.
    I can play the music in the sonyericsson emulator,so I think maybe it is not the location error.

Similar Threads

  1. Suggestions and Complaints regarding Music Organization on Nokia E61
    By Optikalusion in forum General Development Questions
    Replies: 0
    Last Post: 2007-06-09, 14:49
  2. How can I play music to ear phone?
    By fans_yi in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2007-01-31, 02:06
  3. How can I play music to ear phone?
    By fans_yi in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-01-30, 05:17
  4. How To Make The S60 Emulator See My USB Bluetooth Dongle ?
    By Mo7ammed_01 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-07-25, 00:14
  5. What is going on with Vibration on S60?
    By amd_rikus in forum Mobile Java General
    Replies: 3
    Last Post: 2006-06-16, 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
  •  
×