Display files using 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.
Insert Images
Fastboard provides the insertImg
method for inserting and displaying an image in the main window of the whiteboard. You can call this method and pass in the URL, width, and height of the image to display a specified image.
Prerequisites
Before you start, make sure you meet the following requirements:
-
Integrate the Fastboard in your project, and join the room. See Join the whiteboard room.
-
Prepare the URL of the image. Make sure that your app clients can access the URL; otherwise, the image cannot be displayed properly.
-
Make sure that the image is in PNG, JPG/JPEG, or WEBP format.
Implementations
The following steps show how to implement inserting an image in the Join the whiteboard room project:
- In
ViewController.swift
, replacefastRoom.joinRoom()
with the following code: - Run the project. You can see the inserted image on the whiteboard after the app refreshes.
Fastboard does not provide a UI for insertImg
. You need to implement the UI yourself.
Play audio and video
Fastboard integrates the media player extension and provides the insertMedia
method for playing audio and video files. You can simply call insertMedia
and pass in the URL of the audio or video file and the title of the sub-window play the audio and video in a sub-window on the whiteboard.
Prerequisites
Before you start, make sure you meet the following requirements:
-
Integrate Fastboard in your project, and join the room. See Join the whiteboard room.
-
Prepare the URL of the audio or video. Make sure that your app clients can access the URL; otherwise, the audio and video cannot be loaded properly.
-
Make sure that the audio and video files are in MP3 or MP4 format.
Implementations
The following steps show how to implement playing a video in the Join the whiteboard room project:
-
In
ViewController.swift
, replacefastRoom.join()
with the following code: -
Run the project. You can see the sub-window named
test1.mp4
after the app refreshes. Click the start button to play the video.
insertMedia
. You need to implement the UI yourself.Present documents
The Agora Fastboard SDK integrates the docs viewer and slide extensions and provides the insertStaticDocument
and insertPptx
methods for presenting documents. You can simply call insertStaticDocument
or insertPptx
and pass in the information on the converted files to present a document in a paginated format in a sub-window on the whiteboard. The implementation workflow is as follows:
-
Upload the source document to a third-party cloud storage service, and call the Start file conversion (POST) API to create a file conversion task. When the call succeeds, the Agora server returns uuid in the response body, which is the unique identifier (UUID) of the file conversion task.
-
Call the Generate a task token (POST) API, and pass the uuid in the request path to generate a task token for the file conversion task.
-
Call the Query file conversion progress, and pass in the UUID and token of the conversion task to get the information on the converted files, that is, the value of the
convertedFileList
parameter in the response body. -
After joining the whiteboard room, call
insertStaticDocument
orinsertPptx
depending on the document type, and pass in the following parameters:-
pages
: The list of converted files. You need to convertconvertedFileList
to aWhitePptPage
array yourself. -
title
: The title of the sub-window. -
completionHandler
: The callback that reports the call results. Passing innil
means not registering the callback.
-
Prerequisites
Before you start, make sure you meet the following requirements:
-
Integrate Fastboard in your project and join the room. See Join the whiteboard room.
-
Understand and enable the file-conversion service.
Implementations
The following steps show how to implement presenting an animated PPTX document in the Join a Whiteboard Room project:
-
Successfully launch a dynamic-document conversion task, and call the Query file conversion progress to get the list of converted files.
-
In
ViewController.swift
, add the following line afterimport Fastboard
: -
In
ViewController.swift
, replacefastRoom.join()
with the following code: -
Run the project. You can see the sub-window named
My PPT
after the app refreshes. Click the arrow on the window to show your document page by page.