DeveloperDeveloper
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Lovense Pattern Editor

Lovense Pattern Editor

Introduction

Lovense Pattern Editor is a set of SDK tools for web-based audio/video platforms. It is designed to edit and play vibration patterns on Lovense toys synced with audio and video content. Users pair their toys with the Lovense Remote app to establish connection with your audio/video platform.

Workflow

Integrate

Step 1: Integrate SDK

Integrate videoPattern.js into your website.

<script src="https://cdn.lovense-api.com/peditor/videoPattern.js"></script>
  1. Get UID and token

    See how here

  2. Initialization

    const lovensePattern = new LovensePattern()
    lovensePattern.init({
      uid: "[uid]",
      token: "[token]",
      pf: "[pf]",
      mediaId: "[mediaId]",
      duration: "[duration]",
    })
    

Step 2: Connect to Lovense Remote

Get a QR Code, app URL, or Unique Code to connect to Lovense Remote. Supports connecting to Lovense Remote from both PC and mobile-based websites.

lovensePattern.getApp((data) => {
  console.log(data) // { qrCode: "[qrCode]", appOpenUrl: "[appOpenUrl]", code: "[Unique code]" }
  // If your user is on a PC, show the QR Code and have them scan it with Lovense Remote mobile app; If your user is on mobile, display a button which can connect to the Lovense Remote app. If your user is on a VR headset, show the Unique Code and have them enter it with Lovense Remote mobile app.
})

Once Lovense Remote is connected, the event remoteConnected will be triggered.

lovensePattern.on("remoteConnected", () => {
  console.log("remoteConnected")
  // Once Lovense Remote is connected, your platform can control the toys.
})

Step 3: Load Pattern

lovensePattern.loadPattern({
  type: "lovense",
  data: [
    { v: 100, t: 0 },
    { v: 0, t: 1000 },
    //...
  ],
})

Step 4: Play Pattern

lovensePattern.on("patternLoaded", () => {
  console.log("patternLoaded")
  // The pattern is ready to be played

  // When you play the video/audio content, call this method to play the pattern.
  lovensePattern.play({
    speed: 1, // The media playback speed (1 is normal speed)
    currentTime: 1000, // The playing time duration so far (in ms)
  })
})

Note: Steps 3 & 4 are required every time your user connects Lovense Remote app to your platform, even if the audio/video is already playing.

Step 5: Sync with Video/Audio

// Pause the pattern when the media is paused or loading, so the toy's reaction matches the media content.
lovensePattern.pause()

// If the speed or progress changes while playing the media, call this method to re-sync the speed and time.
lovensePattern.change({
  speed: 1, // The media playback speed (1 is normal speed)
  currentTime: 1000, // The playing time duration so far (in ms)
})

API

Methods

lovensePattern.init

Initialize the SDK.

Note: Call this method every time you open a media page or switch media.

ParametersDescriptionTypeRequired
uidSee herestringYes
tokenSee herestringYes
pfYour platform's name. Contact us if you aren't sure about this.stringYes
mediaIdThe media's ID from your platform.videoId can also be used here.stringYes
durationThe media's total duration (in ms)numberYes
lovensePattern.init({
  uid: "[uid]",
  token: "[token]",
  pf: "[pf]",
  mediaId: "[mediaId]",
  // or videoId: "[mediaId]"
  duration: "[duration]",
})

lovensePattern.getApp

Get app connection info through QR Code, app URL, or Unique Code.

Note: If your user has already connected Lovense Remote to your platform, you don't need to call this method again when they switch to a new media. Connection persistence is supported. If you call this method again, a new QR code will be shown.

Example:

lovensePattern.getApp((data) => {
  console.log(data) // {qrCode: "[qrCode]", appOpenUrl: "[appOpenUrl]", code: "[Unique code]"}
})

lovensePattern.loadPattern

Load Patterns. This step is required every time your user connects Lovense Remote app to your platform, even when the audio/video is already playing.

ParametersDescriptionTypeRequired
typePattern type, supports patterns from funScript and lovense (patterns created in Lovense software)stringYes
dataData of patternsarrayNo
patternLinkPattern File URLstringNo
lovensePattern.loadPattern({
  type: "funScript",
  patternLink: "[pattern link]"// The funcript file download link
  data: [
    { pos: 50, at: 1000 },
    { pos: 80, at: 2000 },
    { pos: 20, at: 3000 },
  ], // FunScript data
})// If the data object is not null, this pattern data will be used first. Otherwise, pattern data is obtained from patternLink. If both are null, an error message will be returned.


lovensePattern.loadPattern({
  type: "lovense",
  patternLink: "[pattern link]"// The Lovense pattern file download link
  data: [
    { v: 10, t: 1000 },
    { v: 20, t: 2000 },
    { v: 5, t: 3000 },
  ], // Lovense Pattern data
})// If the data object is not null, this pattern data will be used first. Otherwise, pattern data is obtained from patternLink. If both are null, we will attempt to obtain patterns from our Lovense Pattern Editor(according to mediaId)), If it's null, an error message will be returned. Notice: we support third-party creating patterns from Lovense Pattern Editor according to mediaId)

lovensePattern.play

Play loaded patterns. This step is required every time your user connects Lovense Remote app to your platform, even when the audio/video is already playing.

ParametersDescriptionTypeRequired
speedThe media playback speed (1 is normal speed)floatYes
currentTimeThe playing time duration so far (in ms)initYes
lovensePattern.play({
  speed: 1, // speed
  currentTime: 10000, // ms
})

lovensePattern.pause

Call this method when the media is paused.

lovensePattern.pause()

lovensePattern.change

Call this method when the media's progress bar or speed changes.

ParametersDescriptionTypeRequired
speedThe media playback speed (1 is normal speed)floatYes
currentTimeThe playing time duration so far (in ms)initYes
lovensePattern.change({
  speed: 1, // speed
  currentTime: 10000, // ms
})

lovensePattern.exit

Call this method when you want to disconnect Lovense Remote from your platform.

lovensePattern.exit()

Events

Remote Connected

This event will be triggered when Lovense Remote is connected.

lovensePattern.on("remoteConnected", () => {
  console.log("remoteConnected")
  // Now you can forward the funscript to Lovense Pattern Editor JS
})

Pattern Loaded

This event will be triggered when Lovense Remote finishes loading Lovense patterns or patterns converted from Funscripts.

lovensePattern.on("patternLoaded", () => {
  console.log("patternLoaded")
  // Now you can play the media, the toy will sync with the media/vibration pattern. While playing the media, once you get the patternLoaded event, call the lovensePattern.play method automatically, then the toy will start syncing to the media.
})

Pattern Sync Error

Lovense Remote downloads patterns through HTTP requests. This event will be triggered when Lovense Remote fails to download a pattern.

lovensePattern.on("PatternSyncError", (data) => {
  console.log("PatternSyncError", data.msg)
  // According to the data.msg, you can check out the reasons and fix the issues.
})

Remote Disconnected

This event will be triggered when the server can't detect the heartbeat of Lovense Remote for 85 seconds. It is triggered by abnormal situations, for example, when the app is closed or there is a network disconnection.

lovensePattern.on("remoteDisconnected", () => {
  console.log("remoteDisconnected")
  // You should update the Lovense Remote connection status on your website. We recommend showing a message to users that Lovense Remote is disconnected and prompting them to reconnect.
})

Remote Exit Pattern

This event will only be triggered when the user clicks the "disconnect" button in Lovense Remote, or when you call “lovensePattern.exit” on your website. It is triggered only when there is an intentional disconnection from Lovense Remote.

lovensePattern.on("remoteExitPattern", () => {
  console.log("remoteExitPattern")
  // Now you can update the Lovense Remote connection status on your website, so the user can reconnect
})

Remote Toy Status

This event will be triggered when toys connect or disconnect. It will list all the toys connected at that moment.

lovensePattern.on("remoteToyStatus", (data) => {
  console.log("remoteToyStatus", data)
  // [
  //  {
  //     nickName:"Dolce",    //Toy nickName
  //     name:"dolce",         //Toy name
  //     id:"dd83899c34d7",   //Toy ID
  //     battery:100,         //Toy battery
  //     version:"1",         //Toy version
  //     status:"1"           //Toy status  1:connected
  //  },
  //  {
  //     nickName:"Nora",    //Toy nickName
  //     name:"nora",         //Toy name
  //     id:"dd83899c34d7",   //Toy ID
  //     battery:100,         //Toy battery
  //     version:"1",         //Toy version
  //     status:"1"           //Toy status  1:connected
  // }
  //]
})
Last Updated:
Explore our Forum or Support to get more inspiration or solve your problems.
Discord Channel
It is an online real-time channel where you can communicate directly with our official administrators or many excellent developers.
Forum
It is a place for Lovense developers to communicate, where you can find solutions to problems or get inspired for your projects.
Support
Find documents and tutorials that may be helpful to you.