Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User zholdas's Avatar
    Join Date
    Dec 2008
    Posts
    18
    Не воспроизводится звуковой файл на устройстве.
    Code:
    InputStream is = getClass().getResourceAsStream("/ding.wav");
              Player player = Manager.createPlayer(is,"audio/X-wav");
              
              player.realize();
              // get volume control for player and set volume to max
              VolumeControl vc = (VolumeControl) player.getControl("VolumeControl");
              if(vc != null)
              {
                vc.setLevel(100);
              }
              player.prefetch();
              player.start();
    На эмуляторе все работает и файл проигрывается. Файл лежит в самом jar файле (в корне).
    Тестирую на N97.
    ?

  2. #2
    Nokia Developer Moderator A.A.M.'s Avatar
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,308
    Попробуйте отловить ошибку:
    Code:
    private void playFromResource() {
            try {
                InputStream is = getClass().getResourceAsStream("/ding.wav");
                Player player = Manager.createPlayer(is,"audio/x-wav");
                player.realize();
     
                VolumeControl vc = (VolumeControl)player.getControl("VolumeControl");
                if(vc!=null) { 
                             vc.setLevel(100);
                             }
                player.prefetch();
                player.start();
            } catch (Exception e) {
                showException(e);
                return;
            }
            mDisplay.setCurrent(mMainScreen);
        }
        private void showException(Exception e) {
            Alert a = new Alert("Exception", e.toString(), null, null);
            a.setTimeout(Alert.FOREVER);
            mDisplay.setCurrent(a, mMainScreen);
        }
    См. также "How to play music files using JSR 135"

Similar Threads

  1. wav file to Byte[] array in J2ME (+playing it)
    By norrissmith in forum Mobile Java General
    Replies: 3
    Last Post: 2011-04-16, 14:24
  2. wav and mid file transfering from j2se server to j2me mobile
    By leenus_0071 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2007-06-15, 12:32
  3. 6280 plays wav in j2me
    By gootsing in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2007-04-12, 10:25
  4. How can the WAP browser communicate to J2ME application?
    By hbfornies in forum Mobile Java General
    Replies: 20
    Last Post: 2007-03-02, 16:32
  5. J2ME Polish Version 1.0 RC6
    By enough in forum Mobile Java General
    Replies: 1
    Last Post: 2004-07-20, 11:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved