🎨
Live2D Cubism Cookbook
  • Live2D Cubism 4.0 Cookbook
  • Common Gotchas
    • App Won't Launch
    • Import PSD Files
  • Modeling and Rigging
    • Basic Workflow
    • Deformer Hierarchy
    • Set Up Model to Follow Cursor
    • Create ArtMesh Collision Detection Areas
    • Add Lip-Sync
  • Web SDK
    • Play Audio Natively in the Browser
    • Deploy to Heroku
Powered by GitBook
On this page

Was this helpful?

  1. Web SDK

Play Audio Natively in the Browser

/**
 * @param group : motion group name
 * @param no : index number inside the motion group
 */
// Play sound
const motionSoundFileName = this._modelSetting.getMotionSoundFileName(group, no);
const sound = new Audio(`${this._modelHomeDir}/${motionSoundFileName}`);
let promise = sound.play();
if (promise) {
  // Older browsers may not return a promise, according to the MDN website
  promise.catch(function (error) { console.error(error); });
}

PreviousAdd Lip-SyncNextDeploy to Heroku

Last updated 4 years ago

Was this helpful?