interface.uts 20.5 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1
export type CreateVideoContext = (videoId: string.VideoIdString, component?: ComponentPublicInstance | null) => VideoContext | null;
2 3

export type Danmu = {
DCloud-yyl's avatar
DCloud-yyl 已提交
4 5 6 7 8 9 10 11 12 13 14 15
    /**
     * 弹幕文字
     */
    text?: string | null,
    /**
     * 弹幕颜色
     */
    color?: string | null,
    /**
     * 显示时刻
     */
    time?: number | null
16 17 18
};

export type RequestFullScreenOptions = {
DCloud-yyl's avatar
DCloud-yyl 已提交
19 20 21 22 23 24 25
    /**
     * direction
     * - 0: 正常竖向
     * - 90: 屏幕逆时针90度
     * - -90: 屏幕顺时针90度
     * @type 0 | 90 | -90
     * @uniPlatform {
DCloud-yyl's avatar
DCloud-yyl 已提交
26 27 28 29 30 31
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
DCloud-yyl's avatar
DCloud-yyl 已提交
32
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
33 34 35 36 37
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
     *     }
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
38 39 40 41
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
42
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
80 81 82 83
     *   "web": {
     *     "uniVer": "x",
     *     "unixVer": "x"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
84 85 86
     * }
     */
    direction?: number | null
87 88 89
};

export interface VideoContext {
DCloud-yyl's avatar
DCloud-yyl 已提交
90 91 92 93 94 95 96 97 98 99
    /**
     * @description 播放
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
100 101 102
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
103 104 105 106 107 108
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
109
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
110 111 112 113
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
114
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
152
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
153 154 155
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168 169
     * }
     * @uniVueVersion 2,3
     */
    play(): void;
    /**
     * @description 暂停
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
170 171 172
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
173 174 175 176 177 178
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
179
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
180 181 182 183
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
184
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
222
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
223 224 225
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
     * }
     * @uniVueVersion 2,3
     */
    pause(): void;
    /**
     * @description 跳转到指定位置
     * @param {number} position 跳转到指定位置(秒)
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
241 242 243
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
244 245 246 247 248 249
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
250
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
251 252 253 254
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
255
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
293
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
294 295 296
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
297 298 299 300 301 302 303 304 305 306 307 308 309 310
     * }
     * @uniVueVersion 2,3
     */
    seek(position: number): void;
    /**
     * @description 停止视频
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
311 312 313
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
314 315 316 317 318 319
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
320
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
321 322 323 324
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
325
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
363
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
364 365 366
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
     * }
     * @uniVueVersion 2,3
     */
    stop(): void;
    /**
     * @description 发送弹幕
     * @param {Danmu} 属性 text, color
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
382 383 384
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
385 386 387 388 389 390
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
391
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
392 393 394 395
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
396
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
434
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
435 436 437
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
     * }
     * @uniVueVersion 2,3
     */
    sendDanmu(danmu: Danmu): void;
    /**
     * @description 设置倍速播放
     * @param {number} rate, 支持倍率 0.5/0.8/1.0/1.25/1.5
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
453 454 455
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
456 457 458 459 460 461
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
462
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
463 464 465 466
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
467
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
505
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
506 507 508
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
     * }
     * @uniVueVersion 2,3
     */
    playbackRate(rate: number): void;
    /**
     * @description 进入全屏
     * @param {RequestFullScreenOptions} direction, 0|正常竖向, 90|屏幕逆时针90度, -90|屏幕顺时针90度
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
524 525 526
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
527 528 529 530 531 532
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
533
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
534 535 536 537
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
538
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
576
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
577 578 579
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
     * }
     * @uniVueVersion 2,3
     */
    requestFullScreen(direction?: RequestFullScreenOptions | null): void;
    /**
     * 退出全屏
     * @description 退出全屏
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "3.9.0"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
595 596 597
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
598 599 600 601 602 603
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
604
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
605 606 607 608
    *  "mp": {
    *    "weixin": {
    *        "hostVer": "√",
    *        "uniVer": "√",
DCloud-yyl's avatar
DCloud-yyl 已提交
609
    *        "unixVer": "4.41"
DCloud-yyl's avatar
DCloud-yyl 已提交
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
    *    },
    *    "alipay": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "baidu": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "toutiao": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "lark": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "qq": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "kuaishou": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    },
    *    "jd": {
    *        "hostVer": "√",
    *        "uniVer": "√",
    *        "unixVer": "x"
    *    }
    *  },
DCloud-yyl's avatar
DCloud-yyl 已提交
647
     *   "web": {
DCloud-yyl's avatar
DCloud-yyl 已提交
648 649 650
     *     "uniVer": "√",
     *     "unixVer": "4.0"
     *   }
DCloud-yyl's avatar
DCloud-yyl 已提交
651 652 653 654
     * }
     * @uniVueVersion 2,3
     */
    exitFullScreen(): void;
655
}
DCloud-yyl's avatar
DCloud-yyl 已提交
656 657

export interface Uni {
DCloud-yyl's avatar
DCloud-yyl 已提交
658 659 660 661 662 663 664 665 666 667
    /**
     * 创建并返回 video 上下文 videoContext 对象
     * @uniPlatform {
     *   "app": {
     *     "android": {
     *       "osVer": "4.4",
     *       "uniVer": "√",
     *       "unixVer": "√"
     *     },
     *     "ios": {
DCloud-yyl's avatar
DCloud-yyl 已提交
668 669 670
     *       "osVer": "12.0",
     *       "uniVer": "√",
     *       "unixVer": "4.11"
DCloud-yyl's avatar
DCloud-yyl 已提交
671 672 673 674 675 676
     *     },
     *    "harmony": {
     *      "osVer": "3.0",
     *      "uniVer": "4.23",
     *      "unixVer": "x"
     *    }
DCloud-yyl's avatar
DCloud-yyl 已提交
677
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
678 679 680
     *   "web": {
     *     "uniVer": "√",
     *     "unixVer": "4.0"
DCloud-yyl's avatar
DCloud-yyl 已提交
681
     *   },
DCloud-yyl's avatar
DCloud-yyl 已提交
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
         * "mp": {
     *		"weixin": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "4.41"
     *		},
     *		"alipay": {
     *			"hostVer": "1.10.0",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		},
     *		"baidu": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		},
     *		"toutiao": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		},
     *		"lark": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		},
     *		"qq": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		},
     *		"kuaishou": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		},
     *		"jd": {
     *			"hostVer": "√",
     *			"uniVer": "√",
     *			"unixVer": "x"
     *		}
     *	}
     * }
     * @uniVueVersion 2,3
     * @return {VideoContext} video组件上下文对象
     *
     * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/media/video-context.html#createvideocontext
     * @tutorial-uni-app-x https://doc.dcloud.net.cn/uni-app-x/api/create-video-context.html#createvideocontext
     * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/create-video-context.html#createvideocontext
     *
     */
    createVideoContext: CreateVideoContext
DCloud-yyl's avatar
DCloud-yyl 已提交
734 735 736 737
}

/**
 * 通用事件
DCloud-yyl's avatar
DCloud-yyl 已提交
738
 * 临时方案,规避组件Event接口无法直接继承UniEvent的问题
DCloud-yyl's avatar
DCloud-yyl 已提交
739 740
 */
interface UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
    /**
     * 是否冒泡
     */
    bubbles: boolean
    /**
     * 是否可以取消
     */
    cancelable: boolean
    /**
     * 事件类型
     */
    type: string
    /**
     * 触发事件的组件
     */
    target?: UniElement | null
    /**
     * 当前组件
     */
    currentTarget?: UniElement | null
    /**
     * 事件发生时的时间戳
     */
    timeStamp: Long
    /**
     * 阻止当前事件的进一步传播
     */
    stopPropagation(): void
    /**
     * 阻止当前事件的默认行为
     */
    preventDefault(): void
DCloud-yyl's avatar
DCloud-yyl 已提交
773 774 775 776 777 778 779
}

/**
 * timeupdate 事件
 * 播放进度变化时触发
 */
export interface UniVideoTimeUpdateEvent extends UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
780
    detail: UniVideoTimeUpdateEventDetail
DCloud-yyl's avatar
DCloud-yyl 已提交
781 782 783
}

export type UniVideoTimeUpdateEventDetail = {
DCloud-yyl's avatar
DCloud-yyl 已提交
784 785 786 787 788 789 790 791
    /**
     * 当前进度
     */
    currentTime: number,
    /**
     * 总进度
     */
    duration: number
DCloud-yyl's avatar
DCloud-yyl 已提交
792 793 794 795 796 797 798
}

/**
 * fullscreenchange 事件
 * 当视频进入和退出全屏是触发
 */
export interface UniVideoFullScreenChangeEvent extends UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
799
    detail: UniVideoFullScreenChangeEventDetail
DCloud-yyl's avatar
DCloud-yyl 已提交
800 801 802
}

export type UniVideoFullScreenChangeEventDetail = {
DCloud-yyl's avatar
DCloud-yyl 已提交
803 804 805 806 807 808 809 810
    /**
     * 是否全屏
     */
    fullScreen: boolean,
    /**
     * 横竖屏,取值 vertical 或 horizontal
     */
    direction: string
DCloud-yyl's avatar
DCloud-yyl 已提交
811 812 813 814 815 816 817
}

/**
 * error 事件
 * 视频播放出错时触发
 */
export interface UniVideoErrorEvent extends UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
818
    detail: VideoError
DCloud-yyl's avatar
DCloud-yyl 已提交
819 820 821 822 823 824 825 826 827 828 829
}

/**
 * 统一错误码
 * 100001 网络错误
 * 200001 内部错误
 * 300001 SDK错误
 */
export type VideoErrorCode = 100001 | 200001 | 300001

export interface VideoError extends IUniError {
DCloud-yyl's avatar
DCloud-yyl 已提交
830
    errCode: VideoErrorCode
DCloud-yyl's avatar
DCloud-yyl 已提交
831 832 833 834 835 836 837
}

/**
 * progress 事件
 * 加载进度变化时触发
 */
export interface UniVideoProgressEvent extends UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
838
    detail: UniVideoProgressEventDetail
DCloud-yyl's avatar
DCloud-yyl 已提交
839 840 841
}

export type UniVideoProgressEventDetail = {
DCloud-yyl's avatar
DCloud-yyl 已提交
842 843 844 845
    /**
     * 加载进度百分比
     */
    buffered: number
DCloud-yyl's avatar
DCloud-yyl 已提交
846 847 848 849 850 851 852
}

/**
 * fullscreenclick 事件
 * 视频播放全屏播放时点击事件
 */
export interface UniVideoFullScreenClickEvent extends UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
853
    detail: UniVideoFullScreenClickEventDetail
DCloud-yyl's avatar
DCloud-yyl 已提交
854 855 856
}

export type UniVideoFullScreenClickEventDetail = {
DCloud-yyl's avatar
DCloud-yyl 已提交
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872
    /**
     * 点击点相对于屏幕左侧边缘的 X 轴坐标
     */
    screenX: number,
    /**
     * 点击点相对于屏幕顶部边缘的 Y 轴坐标
     */
    screenY: number,
    /**
     * 屏幕总宽度
     */
    screenWidth: number,
    /**
     * 屏幕总高度
     */
    screenHeight: number
DCloud-yyl's avatar
DCloud-yyl 已提交
873 874 875 876 877 878 879
}

/**
 * controlstoggle 事件
 * 切换播放控件显示隐藏时触发
 */
export interface UniVideoControlsToggleEvent extends UniVideoEvent {
DCloud-yyl's avatar
DCloud-yyl 已提交
880
    detail: UniVideoControlsToggleEventDetail
DCloud-yyl's avatar
DCloud-yyl 已提交
881 882 883
}

export type UniVideoControlsToggleEventDetail = {
DCloud-yyl's avatar
DCloud-yyl 已提交
884 885 886 887
    /**
     * 是否显示
     */
    show: boolean
DCloud-yyl's avatar
DCloud-yyl 已提交
888 889 890 891 892 893 894 895 896 897 898 899
}

export type VideoTimeUpdateEvent = UniVideoTimeUpdateEvent
export type VideoTimeUpdateEventDetail = UniVideoTimeUpdateEventDetail
export type VideoFullScreenChangeEvent = UniVideoFullScreenChangeEvent
export type VideoFullScreenChangeEventDetail = UniVideoFullScreenChangeEventDetail
export type VideoErrorEvent = UniVideoErrorEvent
export type VideoProgressEvent = UniVideoProgressEvent
export type VideoProgressEventDetail = UniVideoProgressEventDetail
export type VideoFullScreenClickEvent = UniVideoFullScreenClickEvent
export type VideoFullScreenClickEventDetail = UniVideoFullScreenClickEventDetail
export type VideoControlsToggleEvent = UniVideoControlsToggleEvent
DCloud-yyl's avatar
DCloud-yyl 已提交
900
export type VideoControlsToggleEventDetail = UniVideoControlsToggleEventDetail