cocos2d-js3.1--Sound

Source: Internet
Author: User
Tags set background

Play background music

Cc.audioEngine.playMusic (URL , Loop ); @param {String} url sound path @param {Boolean} loop whether to loop playback Stop Background musicCc.audioengine.Stopmusic(Releasedata); * @param {Boolean} releasedata whether to release sound data, default to False
  Pause background Music
Cc.audioengine.Pausemusic ();
  Restore background music
Cc.audioengine.Resumemusic();
re-play background musicCc.audioengine.Rewindmusic ();
  Get background music volumeCc.audioengine.Getmusicvolume();
* @return {number}Values from 0 to 1.0
Set background music volumeCc.audioengine.Setmusicvolume(Volume);
* @param {number} volume range 0.0~1.0 .
gets whether the background music is in playCc.audioengine.ismusicplaying();
* @return {Boolean} is playing back true, otherwise returns false Play sound (basically similar to music) Cc.audioengine.Playeffect( URL , Loop ); * @param {String} URL Audio file path * @param {Boolean} loop whether to loop playback, the default value is False * @return {number|null} return Sound IDaudioid  Cc.audioengine.Geteffectsvolume ();//Get Sound volume
Cc.audioengine.Seteffectsvolume (volume);//Set Sound volume
Cc.audioengine.Pauseeffect (audioid);//Pause the corresponding soundCc.audioengine.pausealleffects();//Pause all sound effects
Cc.audioengine. Resumeeffect(audioid);//restore the corresponding soundCc.audioengine. resumealleffects();//restore all sound effects
Cc.audioengine. Stopeffect(audioid);//Stop the corresponding sound
Cc.audioengine. Unloadeffect(URL);//unload sound data in memory buffers

stop playing all music and sound effects filescc.audioEngine.end ();Supported platforms and formats(form from official documents)

The music formats supported by Cocosdesion are as follows:

Platform common file formats supported Notes
Android MP3, Mid, OGGG, WAV All formats supported by Android.media.MediaPlayer can be played
Ios AAC, CAF, MP3, M4A, wav All formats supported by Avaudioplayer can be played
Windows Mid, MP3, WAV No

The audio formats supported by Cocosdesion are as follows:

Platform common file formats supported Notes
Android OGGG, WAV Support for WAV is not perfect
Ios CAF, M4A All formats supported by Cocos2d-iphone Cocosdesion can be played
Windows Mid, WAV No
 

cocos2d-js3.1--Sound

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.