The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.
There are two ways to access document transcoding:
Registration Callback Method (Recommended for scenarios where callbacks have already been Registered in the Interactive Whiteboard Console, as it allows you to receive transcoding progress and results more promptly)
Active Polling Method (Suitable for scenarios where callbacks are not registered in the Interactive Whiteboard Console)
This document mainly introduces the basic process of initiating document transcoding using the registration callback method.
Preparations
Bucket Configuration (The resources of CFS after document transcoding rely on COS. Before using the document transcoding feature, please first perform Bucket Configuration).
Note
If the bucket is not configured, the transcoded CFS will be stored in the public bucket of the Interactive Whiteboard, with a storage validity period of 7 days. After 7 days, the transcoded files in the public bucket will be automatically deleted, and the URL file will become invalid. It is recommended to perform Bucket Configuration to store the transcoded CFS in your own bucket.
Register Transcoding Callback (To allow the transcoding server to push transcoding results to you in real-time, you need to register a callback URL. For specific methods, please refer to Console Callback Settings).
Note
Due to the time required for transcoding and queuing, it is recommended to use the server-side API to transcode in advance and the client to directly use the transcoding result. It is not recommended to directly call the Interactive Whiteboard SDK's transcoding interface applyFileTranscode on the client to avoid long waits and impact the product experience.
Interaction Process (Registration Callback Method)
1. Upload Document (for example, to Tencent Cloud COS)
To enable the Tencent Cloud transcoding server to obtain your courseware for transcoding, you need to provide a URL that the transcoding server can use to download the courseware.
Note:
1. It is recommended to use Tencent Cloud's COS service to provide download addresses. Of course, you can also upload to other storage servers or use other upload methods.
2. Here, the example uses Tencent Cloud COS with the Go language. For more language implementations, please refer to Tencent Cloud COS.
Sample code:
package main
import (
"context"
"fmt"
"log"
"net/http"
"net/url"
"github.com/tencentyun/cos-go-sdk-v5"
"os"
)
func main() {
// Initialize COS resources TODO: Replace `examplebucket-1250000000` and `COS_REGION` with the actual information
// The object key is the unique identifier of the object in the bucket.
// For example, in the access domain name `examplebucket-1250000000.cos.COS_REGION.myqcloud.com/test/objectPut.go`, the object key is `test/objectPut.go`
Since dynamic transcoding involves transcoding time and queuing time, it is recommended to use the server API to transcode in advance, and the client directly uses the transcoding result. It is not recommended to directly call the transcoding interface on the client side applyFileTranscode to avoid long waits and impact on product experience.
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
fmt.Printf("%s", response.ToJsonString())
}
3. Handle Transcoding Callback
You must ensure that the callback is successfully registered in the console or via API, and the callback URL is publicly accessible to receive transcoding data callbacks properly. If you have not configured the callback yet, please refer to Console Callback Settings.
The client sets the transcoding results into the interactive whiteboard, to achieve document previous/next, previous/next page, and other features. Refer to whiteboard interface description for whiteboard interface.
Code example (JS example)
// The client assembles parameters based on the document transcoding returned results
let config ={
url: eventData.resultUrl,
title: eventData.title,
pages: eventData.pages,
resolution: eventData.resolution
}
// Add the document transcoding results to the whiteboard