Before reading this article, please read the server-side documentation: document to picture、 document to web page , Make sure that the corresponding service has been activated in console.
The SDK encapsulates the interaction of the SDK server into a Converter
class, and the developer does not need to care about the interaction with the SDK server on the client side.
For pptx documents, each page will correspond to a scene on the whiteboard.
A pptx file with 24 pages will create 24 scenes on the whiteboard. For the concept of scenes, please see Scene Management for details.
Converter c = new Converter(this.roomToken);
c.startConvertTask("{pptx url}", Converter.ConvertType.Dynamic, new ConverterCallbacks(){
@Override
public void onFailure(ConvertException e) {
}
@Override
public void onFinish(ConvertedFiles ppt, ConversionInfo convertInfo) {
if (ppt.getScenes() != null) {
room.putScenes("dynamic", ppt.getScenes(), 0);
room.setScenePath("dynamic/1");
}
}
@Override
public void onProgress(Double progress, ConversionInfo convertInfo) {
}
});
You can play the dynamic PPT by calling the following method. When all the animations of the PPT on the current page are executed, when you call this method again, it will automatically enter the next page scene.
room.pptNextStep(); // Next page (next step)
room.pptPreviousStep(); // Previous (previous step)
2.9.13 New API
WhiteSdk
adds commonCallbacks
property, after setting commonCallbacks
, the audio and video playback in dynamic ppt will call back the corresponding method.
/**
* Part of the general callback, whether it is a playback room or a real-time room, there are some notifications
* @since 2.9.13
*/
public interface CommonCallbacks {
/**
* When an uncaught global error occurs in the SDK, it will be thrown here
* @param args
*/
void throwError(Object args);
/**
* Audio and video media in dynamic ppt, play notification
*/
void onPPTMediaPlay();
/**
* Audio and video media in dynamic ppt, pause notification
*/
void onPPTMediaPause();
}
If your pptx contains fonts that are not in our default font list, you can support it by configuring a custom font list. First, you need to upload the font file to your own server or object storage platform. Then, configure the URL of the font file with the following code when sdk is initialized.
WhiteSdkConfiguration config = new WhiteSdkConfiguration(DeviceType.touch, 10, 0.1);
HashMap<String, String> map = new HashMap();
map.put("Calibri", "https://your-cdn.com/Calibri.ttf");
map.put("宋体","https://your-cdn.com/Songti.ttf");
map.put("Kaiti", "https://your-cdn.com/Kaiti.ttf");
//When initializing the SDK, bring in config
sdkConfiguration.setFont(map);