抖音开放平台Logo
控制台

tt.navigateToVideoView
收藏
我的收藏

基础库版本 1.40.0 开始支持本方法​
跳转到分享的视频播放页面。​

语法​

Plain Text
复制
tt.navigateToVideoView(options)

参数说明​

options 为 object 类型,属性如下:​
属性名
类型
默认值
必填
说明
最低支持版本
videoId
string
-
tt.shareAppMessage分享视频成功后返回
1.40.0
success
function
接口调用成功回调函数
1.40.0
fail
function
接口调用失败回调函数
1.40.0
complete
function
接口调用结束的回调函数(调用成功、失败都会执行)
1.40.0

回调成功​

Object 类型,属性如下:​
参数
参数类型
说明
errMsg
string
跳转成功信息,恒为'navigateToVideoView:ok'

回调失败​

Object 类型, 属性如下:​
参数
参数类型
说明
errMsg
string
跳转失败信息,以'navigateToVideoView:fail'开头
errCode
number
错误代码
errCode 的可枚举值:​
errCode
描述
1001
videoId 类型不正确
1002
视频已经被删除
1003
videoId 不正确
1004
获取视频信息错误
1005
其他错误
1006
网络错误
1007
端上其他错误
1008
端上参数错误

扫码体验​

代码示例​

js
复制
tt.shareAppMessage({
channel: "video",
title: "测试分享视频",
desc: "测试描述",
imageUrl: "",
templateId: "", // 替换成通过审核的分享ID
query: "",
extra: {
videoPath: "ttfile://temp/test.mp4", // 可替换成录屏得到的视频地址
videoTopics: ["话题1", "话题2"],
withVideoId: true,
},
success(res) {
console.log(res.videoId);
console.log("分享视频成功");
},
fail(e) {
console.log("分享视频失败");
},
});
tt.navigateToVideoView({
videoId: "xxxxxx",
success: (res) => {
console.log("done");
},
fail: (err) => {
if (err.errCode === 1006) {
tt.showToast({
title: "something wrong with your network",
});
}
},
});

Bug & Tip​

    Tip:在 IOS 下的横屏模式小游戏,目前不支持跳转​