Display files using Fastboard

Updated

Display and manage files in Fastboard.

The Agora Fastboard SDK supports inserting and displaying multiple types of files on the whiteboard, such as images, audio and video, and documents. This enables users to quickly share information in compelling ways in order to create an immersive experience.

This page describes how to call the Fastboard SDK's APIs to insert images, present documents, and play audio and video on the whiteboard.

Understand the tech

Fastboard provides APIs for displaying files in the whiteboard main window or sub-windows.

Prerequisites

  • Integrate Fastboard in your project and join the room. See Join the whiteboard room.
  • Prepare publicly accessible asset URLs.
  • Make sure file formats are supported, and enable file conversion before presenting documents.

Project setup

Insert Images

Fastboard provides the insertImg method.

fastRoom.joinRoom() {
    fastRoom.insertImg(
        URL(string: "https://test.aliyuncs.com/cloud-storage/2022-xx/15/e3xxda.png")!,
        imageSize: .init(width: 100, height: 100)
    )
}

Play audio and video

Fastboard integrates the media player extension and provides the insertMedia method.

fastRoom.joinRoom() {
    fastRoom.insertMedia(
        URL(string: "https://test.aliyuncs.com/cloud-storage/2022-xx/15/52xxx37.mp4")!,
        title: "test1.mp4",
        completionHandler: nil
    )
}

Present documents

The Agora Fastboard SDK provides the insertStaticDocument and insertPptx methods.

import UIKit
import Fastboard
import Whiteboard

fastRoom.joinRoom() {
    let jsonStr =
"""
    [{
        "width": 1280,
        "height": 720,
        "conversionFileUrl": "pptx://convertcdn.netless.link/dynamicConvert/3ce728e0954f11ec997c6580ac31fd96/1.slide",
        "preview": "https://convertcdn.netless.link/dynamicConvert/3ce728e0954f11ec997c6580ac31fd96/preview/1.png"
    }]
"""
    let dic = try! JSONSerialization.jsonObject(with: jsonStr.data(using: .utf8)!) as! [[String: Any]]
    let pages = dic.map { item -> WhitePptPage in
        let url = item["conversionFileUrl"] as? String
        let pre = item["preview"] as? String
        let w = item["width"] as? Int
        let h = item["height"] as? Int
        return WhitePptPage(src: url!, preview: pre!, size: .init(width: w!, height: h!))
    }
    fastRoom.insertPptx(pages, title: "My PPT")
}

Reference

Run the project. You can see the inserted image, media window, or converted document on the whiteboard after the app refreshes.