tencent cloud

Short Drama
Last updated:2026-02-10 19:37:49
Short Drama
Last updated: 2026-02-10 19:37:49

createPlayletPage

This API is called using wx.createPlayletPage().
Feature description:Initializes the player and returns the corresponding player instance PlayletPlugin.
Return value: PlayletPlugin.

PlayletPlugin

PlayletPlugin is the player instance created using wx.createPlayletPage().

.onPageLoad(Function func)

This API is called using PlayletPlugin.onPageLoad(Function func).
Feature description:onPageLoad corresponds to the short drama page’s onLoad event, listening for when the short drama page finishes loading.
Parameter and description:
function func:Operations to execute when the short drama page loads.
Callback function parameter: Object res.
Property
Type
Description
playerId
string
Player Id
Example
playletPlugin.onPageLoad((res) => {
console.log('Page loaded, Player ID:', res.playerId);
});

.onPageDestroy(Function func)

This API is called using PlayletPlugin.onPageDestroy(Function func).
Feature description:Listens for the short drama page’s destroy event.
Parameter and description:
function func:Operations executed when the short drama page is destroyed.
Callback function parameter: Object res.
Property
Type
Description
playerId
string
Player ID
Example
playletPlugin.onPageDestory((res) => {
console.log('Page destroyed, Player ID:', res.playerId);
});

.getPluginVersion()

This API is called using PlayletPlugin.getPluginVersion().
Feature description:Retrieves the plugin version information.
Return value: String res version information.

playletPlugin.PlayletManager

Feature description:PlayletManager is a class that manages the player. It controls the core functions of short drama playback and can be accessed through playletPlugin.PlayletManager.getPageManager(playerId). Most APIs are provided on this instance, such as getInfo, setPlaylets, and more.
Parameters and descriptions: number playerId: Player ID.
Return value: PlayletManager, the player management instance.
Example

plugin.onPageLoad((info) => {
const playletManager = plugin.PlayletManager.getPageManager(info.playerId);
console.log('manager',manager);
})
In many APIs, you can obtain the playerId—for example, from the onPageLoad event, and then use the playerId to get the PlayletManager instance. Below is a detailed introduction to more APIs for the PlayletManager instance:

PlayletManager.setPlaylets (Object object)

Feature description:Initialize the episode status.
Parameter and description: Object object.
Field
Type
‍Required
Default value
Description
id
string
true
-
Drama ID
serialNo
number
true
-
Episode ID
title
string
true
-
Drama name
imgUrl
string
false
''
Drama cover image
introduction
string
false
''
Short drama description
tags
list
false
[]
Short drama tags
playRate
number
false
1
Playback speed
extParam
string
false
{}
Extended parameters
clarity
list
false
[
{ clarity: 240 * 426, title: "360P" },
{ clarity: 480 * 852, title: "480P" },
{ clarity: 720 * 1280, title: "720P" },
{ clarity: 1080 * 1920, title: "1080P" }
]
Video quality options
defaultClarity
object
false
{ clarity: 480 * 852, title: "480P" }
Default video quality
initial-time
number
false
Initial playback time
data
list
true
-
List of episode status
Definition of the data field:
Field
Type
‍Required
Default value
Description
status
number
true
-
Playback status: 0 = free; 1 = unlocked; 2 = locked
VideoUrl
string
false
''
Video URL; not required for paid episodes
coverImg
string
false
-
Cover image; shown if imgUrl is not set
license-url
string
false
''
The license URL for playback
certificate-url
string
false
''
Certificate URL
provision-url
string
false
''
Device provisioning URL
Example
PlayletManager.setPlaylets({
id:"sid", // Drama ID
serialNo:1 // Episode ID, starting from 1
title:"Name",
imgUrl:"Image URL",
introduction:"Short drama introduction",
tags: ["Friendship", "Fantasy"],
playRate: 1
extParam:"{{xxx}}"
clarity:[{"360p": 240 * 426},{"480p":480 * 852},"720p":720 * 1280,"1080p":1080 * 1920] // Effective only under HLS
defalutClarity: {"720p":720 * 1280 }// Default video quality
'initial-time': 0,
data: [{
license-url:"",
certificate-url:"",
provision-url:"",
status: 0,
videoUrl: "Playback URL" // Not required for paid episodes
coverImg: "Cover image" // Not required
}]
})

PlayletManager.setLockMenu( Object object )

Feature description:Sets the popup window for unlocking episodes. When playback reaches a locked episode, this popup will appear.
Parameter and description: Object object.
Field
Type
‍Required
Default value
Description
List
Array<FreeItem>
true
-
Episode unlock pop-up items, supports up to four entries
Definition of FreeItem fields:
Field
Type
‍Required
Default value
Description
Title
string
true
-
Name of the unlock operation
Callback
function
true
-
The specific unlock operation
Example

PlayletManager.setLockMenu([
{
title: "Watch ad to unlock",
callback: (data) => {
if (!data.serialNo) {
return;
}
PlayletManager.setCanPlay(data.serailNo, 1)
}
},
{
title: "Purchase single episode",
callback: (data) => {
if (!data.serialNo) {
return;
}
PlayletManager.setCanPlay(data.serailNo, 1)
}
}
])
Note:
PlayletManager.setLockMenu() only sets the buttons shown in the unlock popup window. It does not control the display or hiding of the unlock page itself. You must use setCanPlay to actually control the visibility of the unlock page.

PlayletManager.hideLockMenu()

This API is called using PlayletManager.hideLockMenu().
Feature description:Hides the locked menu.

PlayletManager.setCanPlay(object object)

Feature description:Sets the unlock status of episodes.
Parameter and description: Object object.
Field
Type
‍Required
Default value
Description
SerialNo
number
true
-
Episode ID
Status
number
true
-
Playback status
VideoUrl
string
true
-
Playback URL
Example

const unlockData = [{
serialNo: 6, // Episode number
status: 1,
videoUrl: videoUrl // Playback URL
}];
PlayletManager.setCanPlay(unlockData);


PlayletManager.onCheckIsCanPlay(Function func)

Feature description:Event triggered when playback reaches an episode that requires unlocking.
Parameter and description:
function func:A callback function that listens for whether an episode can be played.
Example

manager.onCheckIsCanPlay((data) => {
let episodes = [];
if (data.episodes) {
episodes = data.episodes;
}

// Batch check and set status
const results = episodes.map(ep => {
const serialNo = ep.serialNo;
let status;

if (parseInt(serialNo) <= 3) {
// Assume the first 3 episodes are free
status = 0;
} else {
status = 2;
}
return { serialNo: serialNo, status: status };
});
manager.setCanPlay(results);
});


PlayletManager.onBack(Function func)

Feature description:Event triggered when clicking the back button in the top-left corner of the player.
Parameter and description:
function func:The callback function to listen for the back button click event.
Note:
Clicking the back button in the top-left corner of the short drama playback interface will trigger PlayletManager.onBack(). After returning, the player will be destroyed.

PlayletManager.play()

Feature description:Plays the episode.

PlayletManager.onPlay(Function func)

Feature description:Listens for the short drama play event.
Parameter and description:
function func:The callback function for when the short drama starts playing.

PlayletManager.pause()

Feature description:Pauses the video.

PlayletManager.onPause(Function func)

Feature description:Listen for the short drama video pause event.
Parameter and description:
function func:The callback function for when the short video is paused.

PlayletManager.onError(Function func)

Feature description:Listens for playback error events.
Parameter and description:
function func:The callback function for playback failure events.
Callback parameter:
Property
Type
Description
eventId
number
Type of playback error event

PlayletManager.destroy()

Feature description:Destroys the short drama player.

PlayletManager.getInfo()

Feature description:Retrieves information about the current episode. Returns an object with the following fields:
Property
Type
Description
serialNo
number
Episode ID
playerId
string
Player ID
exParam
string
Sharing extension parameters
duration
string
Total duration of the current episode
playtime
string
Current playback time

PlayletManager.onCustomEvent(Function func)

Feature description:Receives native player status events, including user actions like switching episodes, changing playback speed, etc.
Parameter and description:
Function func:A callback function listening for user interactions with the native player.
Callback parameter:
Property
Type
Description
EventType
string

'CHANGE_SERIAL': Episode changed. Example: { slideType: 1 }. slideType values:
1: Auto-switch after playback ends (regardless of completion).
2: Switched by gesture slide.
3: Switched via episode selection popup.
'CHANGE_SPEED': Playback speed changed. Example: { source: 1, speedType: 1.5 }, source: Currently fixed at 1; speedType: Current playback speed.
'CHANGE_CLARITY': Playback clarity changed; returns the current clarity level.
Example
manager.onCustomEvent((data) => {
if (data.eventType === 'CHANGE_CLARITY') {
console.log('User changed clarity:', data.clarity);
}
if (data.eventType === 'CHANGE_SERIAL') {
console.log('User switched episode:', data.slideType);
}
if (data.eventType === 'CHANGE_SPEED') {
console.log('User changed playback speed:', data.speedType, data.source);
}
});

PlayletManager.onDataReport (Function func)

Feature description:Developers can register a callback function via this method to receive data reporting callbacks. Each event represents a reporting point, where event is an enum with the following possible values. Each reporting event includes some common fields sent back to the developer:
Field
Description
playerId
Player Id
extParam
Sharing extension parameters
serialNo
Current episode index, starting from 1
playTime
Current playback time
duration
Total duration of the current episode
totalCount
Total number of episodes
Additional fields specific to each event:
Field
Description
Description of additional fields
LOAD
Enter the player page
-
SHOW
Player page show
-
START_PLAY
Start to play
-
UNLOAD_OR_HIDE
Leave the page or return to the background
Example: {{type}} 1 }. Where type 1 = unload, type 2 = hide.
video.play()
Play event
-
VIDEO_TIME_UPDATE
Time update event
Parameters correspond to video component’s timeupdate event.
VIDEO_END
Video playback ended
-
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback