创建 Live 带看实例
这是一个工厂函数,用于创建 Live 实例。在创建新实例前,会先清理全局的旧实例(如果存在)。
// 定义帧数据类型interface MyKeyframes { camera: { position: [number, number, number] } annotation: { text: string; position: [number, number] }}// 创建 Live 实例const live = createLive<MyKeyframes>({ url: 'wss://example.com/live', getTicket: async () => { const response = await fetch('/api/get-ticket') return response.json().ticket }, getVoiceSign: async (params) => { const response = await fetch('/api/get-voice-sign', { method: 'POST', body: JSON.stringify(params) }) return response.json() }, useBuiltInRTC: true})// 连接带看await live.connect() Copy
// 定义帧数据类型interface MyKeyframes { camera: { position: [number, number, number] } annotation: { text: string; position: [number, number] }}// 创建 Live 实例const live = createLive<MyKeyframes>({ url: 'wss://example.com/live', getTicket: async () => { const response = await fetch('/api/get-ticket') return response.json().ticket }, getVoiceSign: async (params) => { const response = await fetch('/api/get-voice-sign', { method: 'POST', body: JSON.stringify(params) }) return response.json() }, useBuiltInRTC: true})// 连接带看await live.connect()
帧数据快照类型,必须是一个对象类型
带看配置选项,详见 LiveOptions
Live 实例
创建 Live 带看实例
这是一个工厂函数,用于创建 Live 实例。在创建新实例前,会先清理全局的旧实例(如果存在)。
Example