const plugin = wx.createPlayletPage({fail: (res) => {console.error('[createPlayletPage] failed:', res.errMsg);}});
Property | Type | Description |
playerId | String | Player Id |
playletPlugin.onPageLoad((res) => {console.log('Page loaded, Player ID:', res.playerId);});
Property | Type | Description |
playerId | String | Player ID |
playletPlugin.onPageDestory((res) => {console.log('Page destroyed, Player ID:', res.playerId);});
plugin.onPageLoad((info) => {const playletManager = plugin.PlayletManager.getPageManager(info.playerId);console.log('manager',manager);})
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 | Array | false | [] | Short drama tags |
playRate | Number | false | 1 | Playback speed |
extParam | String | false | {} | Extended parameters |
clarity | Array | 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 | 0 | Initial playback time |
data | Array | true | - | List of episode status |
interaction | Object | false | - | Drama-level interaction data (favorite / share). See table below. |
Field | Type | Required | Default | Description |
interaction.favorite.enabled | Boolean | false | - | Whether to show the favorite button. Defaults to false. |
interaction.favorite.isFavorited | Boolean | false | - | Whether currently favorited. |
interaction.favorite.count | String | false | - | Favorite count text. Formatted by the business side (e.g. "1.2w"). |
interaction.share.enabled | Boolean | false | - | Whether to show the share button. |
interaction.share.count | String | false | - | Drama-level total share count (string). |
interaction.share.title | String | false | - | Share card title. |
interaction.share.path | String | false | - | Share redirect path. |
interaction.share.imageUrl | String | false | - | Custom share image. Supports local / code-package / network images. |
Field | Type | Required | Default | 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 |
interaction | Object | false | - | Episode-level interaction data (including likes) is detailed in the table below. |
Field | Type | Required | Default | Description |
data[].interaction.like.enabled | Boolean | false | - | Whether to show the like button. |
data[].interaction.like.isLiked | Boolean | false | - | Initial like state for this episode. |
data[].interaction.like.count | String | false | - | Like count for this episode (string). |
PlayletManager.setPlaylets({id: "sid", // Drama IDserialNo: 1, // Episode ID, starting from 1title: "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 HLSdefaultClarity: {"720p": 720 * 1280}, // Default video quality'initial-time': 0,interaction: { // Drama-level interaction data (favorite / share)favorite: { enabled: true, isFavorited: false, count: "1.2w" },share: { enabled: true, count: "567", title: "Share title", path: "pages/xxx/xxx?id=1", imageUrl: "" }},data: [{license-url: "",certificate-url: "",provision-url: "",status: 0,videoUrl: "Playback URL", // Not required for paid episodescoverImg: "Cover image", // Not requiredinteraction: { // Episode-level interaction data (like)like: { enabled: true, isLiked: false, count: "2.2w" }},}]})
Field | Type | Required | Default value | Description |
List | Array<FreeItem> | true | - | Episode unlock pop-up items, supports up to four entries |
Field | Type | Required | Default value | Description |
Title | String | true | - | Name of the unlock operation |
Callback | Function | true | - | The specific unlock operation |
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)}}])
Field | Type | Required | Default value | Description |
SerialNo | Number | true | - | Episode ID |
Status | Number | true | - | Playback status |
VideoUrl | String | true | - | Playback URL |
const unlockData = [{serialNo: 6, // Episode numberstatus: 1,videoUrl: videoUrl // Playback URL}];PlayletManager.setCanPlay(unlockData);
manager.onCheckIsCanPlay((data) => {let episodes = [];if (data.episodes) {episodes = data.episodes;}// Batch check and set statusconst results = episodes.map(ep => {const serialNo = ep.serialNo;let status;if (parseInt(serialNo) <= 3) {// Assume the first 3 episodes are freestatus = 0;} else {status = 2;}return { serialNo: serialNo, status: status };});manager.setCanPlay(results);});
Property | Type | Description |
eventId | Number | Type of playback error event |
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 |
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. |
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);}});
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 |
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 | - |
manager.setInteractionState({serialNo: 1, // Episode number: required for type=like; optional for type=favorite/sharetype: 'like', // Interaction type: 'like' | 'favorite' | 'share'isActive: true, // Whether it is active (optional when type=share)count: "1.2w" // Count text, string, formatted by the business side})
Field | Type | Required | Description |
serialNo | Number | Only required for like | Episode number |
type | String | true | 'like' / 'favorite' / 'share' |
isActive | Boolean | Optional for share | Whether it is active |
count | String | false | Count text |
manager.onLikeClick((args) => {// args.playerId current player id// args.id drama id// args.serialNo episode number// args.currentState state before the tap (false = not liked previously)// args.extParam the extParam passed through in setPlaylets})
manager.onFavoriteClick((args) => {// args.playerId// args.id// args.currentState favorite state before the tap// args.extParam})
manager.onShareClick((args) => {// args.playerId// args.id// args.serialNo// args.extParam})
manager.setActivityInfo({logo: 'https://miniprogram.tcsas-superapp.com/xxx/xxx.png'})
Field | Type | Required | Description |
logo | String | true | URL of the promotional logo image (a square PNG, 24 × 24, is recommended) |
manager.onSetActivityInfo((args) => {// Triggered when the user taps the promotional logo})
manager.updateOpenArea({showLeft: true, // Whether to show the left custom areaplayerId: '<optional>', // Specify the target player idserialNo: 1, // Current episode numberext: JSON.stringify({ dramaId: 1 }) // Extra data (string) passed through to the custom component})
Field | Type | Required | Description |
showLeft | Boolean | true | true to show, false to collapse |
playerId | String | false | Specifies the target player instance in multi-player scenarios |
serialNo | Number | false | Current episode number, passed to the component as a prop |
ext | String | false | Custom pass-through data. JSON.stringify() before passing is recommended |
Prop | Type | Source |
ext | String | Passed through from updateOpenArea({ ext }) |
playerId | String | Current player id |
serialNo | Number | Current episode number |
Component({properties: {ext: { type: String, value: '' },playerId: { type: String, value: '' },serialNo: { type: Number, value: 0 }},methods: {onJoinTap() {// Business logic: navigate to the campaign page / open a popup, etc.},onCloseTap() {this.triggerEvent('close'); // Notify the plugin to close the custom area}}});
<cover-view style="display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%;"><!-- Campaign banner image --><cover-imagesrc="https://miniprogram.tcsas-superapp.com/hackthon/upload_1755932019262.jpg"style="width: 500rpx; height: 500rpx; border-radius: 16rpx;"/><!-- Campaign title --><cover-view style="margin-top: 30rpx; font-size: 36rpx; font-weight: bold; color: #fff;">Limited-time reward campaign</cover-view><!-- Campaign description --><cover-view style="margin-top: 16rpx; font-size: 26rpx; color: rgba(255,255,255,0.8); text-align: center;">Watch an ad to unlock all episodes for free</cover-view><!-- Button area --><cover-view style="display: flex; flex-direction: row; margin-top: 40rpx; width: 100%; justify-content: center;"><cover-viewstyle="width: 200rpx; height: 100rpx; line-height: 80rpx; font-size: 28rpx; background: #FF6B6B; color: #fff; border-radius: 36rpx; text-align: center; margin-right: 20rpx;"bindtap="onJoinTap">Join now</cover-view><cover-viewstyle="width: 200rpx; height: 100rpx; line-height: 80rpx; font-size: 28rpx; background: rgba(255,255,255,0.3); color: #fff; border-radius: 36rpx; text-align: center;"bindtap="onCloseTap">Close</cover-view></cover-view></cover-view>
manager.setRecommend([{ id: 'drama_2', name: 'Palace Drama: Harem Legend', imgUrl: 'https://example.com/cover.jpg' },{ id: 'drama_3', name: 'Mystery: Escape Room', imgUrl: 'https://example.com/cover.jpg' }])
Field | Type | Required | Description |
id | String | true | Unique identifier of the recommendation item, echoed back unchanged in the callback |
name | String | true | Name of the recommended drama |
imgUrl | String | true | URL of the recommendation cover image |
manager.onRecommendItemClick((args) => {// args.id — id of the recommendation item the user tapped (matches the id passed to setRecommend)})
文档反馈