用Media命名空间下的SoundPlay调用系统wan波形文件时,怎样才能循环播放

解决方案 »

  1.   

    //可循环里一直初始化当前的歌曲 
    如果当前需要播放的声音,已经在播放了,我们就可以在playMusic中直接返回就得了 
    String   m_curSound; public   boolean   playMusic(String   media,String   lrcMedia,String   name)   { 
    if   (player   !=   null   &&   state   ==   STARTED   &&   player.getState()   ==   Player.PREFETCHED){ 
    state   =   PREFETCHED; 
                    return   true; 
            } 
              if   (m_curSound   !=   null   &&   m_curSound.compareTo(media)   ==   0) 
    return   false; 
    try   { 
    fc   =   (FileConnection)   Connector.open(media   +   ".mp3 ", 
    Connector.READ); 
    is   =   fc.openInputStream(); 
    player   =   Manager.createPlayer(is,   "audio/mpeg "); 
    player.addPlayerListener(this); 
    player.realize(); 
    vc   =   (VolumeControl)   player.getControl( "VolumeControl "); 
    if   (vc   !=   null)   { 
    vc.setLevel(soundSize); 

    player.prefetch(); 
    player.setLoopCount(-1); 
    player.start(); 
    b   =   0; 
                                                          m_curSound   =   media;   //记录当前已经播放的music 
    }   catch(SecurityException   e){ }   catch   (Exception   e)   { 
    e.printStackTrace(); 
    player   =   null; 
    }   finally{ 
    close(); 

    // defplayer(); 
    state   =   STARTED; 
            return   false; } 
      

  2.   

    [DllImport("winmm.dll")]
            public static extern long PlaySound(string lpszName, int hModule, int dwFlags);            private void soundloop()
    {
                OpenFileDialog f = new OpenFileDialog();
                if (f.ShowDialog(this) == DialogResult.OK)
                {
                    PlaySound(f.FileName, 0, 9);
                }
    }
      

  3.   

    结贴,找到了PlayLooding方法,直接循环