This topic describes how to obtain the page number, save the document, and enable autoplay when you use a presentation document.
JS-SDK V1.1.15 and later support these features.
Marker
Display the marker toolbar
Syntax
Expression.ActivePresentation.SlideShowWindow.View.MarkerEditVisibleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Display the marker toolbar. view.MarkerEditVisible = true; setTimeout(() => { // Hide the marker toolbar after 3,000 milliseconds. view.MarkerEditVisible = false; }, 3000) }
Display marker content
Syntax
Expression.ActivePresentation.SlideShowWindow.View.PointerVisibleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Listen to the marker content display events. app.Sub.SlideInkVisible = async (e) => { const { Data } = e; console.log(Data.showmark); setTimeout(() => { // Hide the marker content after 3,000 milliseconds. view.PointerVisible = !Data.showmark; }, 3000) } }
Listen to marker content display events
Syntax
Expression.Sub.SlideInkVisible = eventHandleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View // Listen to the marker content display events. app.Sub.SlideInkVisible = ({Data}) => { console.log ('Whether marker content is displayed:', Data); if(Data.showmark){ setTimeout(() => { view.PointerVisible = false; }, 2000) } }; }
Play
Play a presentation document
Syntax
Expression.ActivePresentation.SlideShowWindow.View.Play(slideIndex, animateIndex)Expression: the document type application object.
Parameters
Parameter
Data type
Description
slideIndex
Number
The index of the current slide.
animateIndex
Number
The index of the current animation.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain slide show settings. const SlideShowSettings = await app.ActivePresentation.SlideShowSettings; // Run slide show. await SlideShowSettings.Run(); // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Play from the first animation of the first slide. await view.Play(1, 1); }
Jump to a specified animation
Syntax
Expression.ActivePresentation.SlideShowWindow.View.GotoClick(number)Expression: the document type application object.
Parameters
Parameter
Data type
Description
number
Number
The index of the current animation.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain slide show settings. const SlideShowSettings = await app.ActivePresentation.SlideShowSettings; // Run slide show. await SlideShowSettings.Run(); // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Jump to the second animation of the slide. await view.GotoClick(2); }
Disable slide change
Syntax
Expression.ActivePresentation.SlideShowWindow.View.IsBanSlideChangeExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Disable slide change. view.IsBanSlideChange = true; setTimeout(() => { // Enable slide change 3,000 milliseconds. view.IsBanSlideChange = false; }, 3000) }
Stop autoplay
Syntax
Expression.ActivePresentation.SlideShowWindow.View.StopAutoPlay()Expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain slide show settings. const SlideShowSettings = await app.ActivePresentation.SlideShowSettings; // Run slide show. await SlideShowSettings.Run(); // Stop autoplay. await SlideShowSettings.StopAutoPlay(); }
Set the preview mode
Syntax
Expression.ActivePresentation.SlideShowWindow.View.CoreReadonlyExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; view.CoreReadonly = true; }
Set full screen
Syntax
Expression.ActivePresentation.SlideShowWindow.IsFullScreenExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Set full screen. SlideShowWindow.IsFullScreen = true; setTimeout(() => { // Exit full screen after 3,000 milliseconds. SlideShowWindow.IsFullScreen = false; }, 3000) }
Listen to the playback status
Syntax
Expression.Sub.SlidePlayerChange = eventHandleExpression: the document type application object.
Example
//@file=base.ppt async function example() { await instance.ready(); const app = instance.Application; // Listen to the playback status. app.Sub.SlidePlayerChange = ({Data}) => { console.log ('Listen to the playback status:', Data); }; }
Listen to the playback status of videos
Syntax
Expression.Sub.SlideMediaChanged = eventHandleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the playback status of videos. app.Sub.SlideMediaChanged = ({Data}) => { console.log ('Listen to the playback status of videos:', Data); }; }
Synchronize the playback status of videos with viewers
Syntax
Expression.ActivePresentation.SlideShowWindow.View.SetMediaObj(Data)Expression: the document type application object.
Parameters
Parameter
Data type
Description
Data
Object
The video playback information.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Listen to the playback status of videos. app.Sub.SlideMediaChanged = async (e) => { const { Data } = e; console.log(Data); // Synchronize the playback status of videos with viewers. await view.SetMediaObj(Data); } }
Destroy the video player on a mobile device
Syntax
Expression.ActivePresentation.SlideShowWindow.View.DestroyMediaPlayer()Expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Listen to the playback status of videos. app.Sub.SlideMediaChanged = async (e) => { const { Data } = e; console.log(Data); setTimeout(async () => { // Destroy the video player after 3,000 milliseconds. await view.DestroyMediaPlayer(Data); }, 3000); } }
Laser pointer
Synchronize laser pointer information
Syntax
Expression.ActivePresentation.SlideShowWindow.View.SetLaserPenData(Data)Expression: the document type application object.
Parameters
Parameter
Data type
Description
Data
Object
The information about the laser pointer.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; // Listen to the ink position changes of the laser pointer. app.Sub.SlideLaserPenInkPointsChanged = async (e) => { const { Data } = e; console.log(Data); // Synchronize the information of the laser pointer. await view.SetLaserPenData(Data); } }
Listen to the ink position changes of the laser pointer
Syntax
Expression.Sub.SlideLaserPenInkPointsChanged = eventHandleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the ink position changes of the laser pointer. app.Sub.SlideLaserPenInkPointsChanged = ({Data}) => { console.log ('Listen to the ink position changes of the laser pointer:', Data); }; }
Listen to the use of the laser pointer and marker
Syntax
Expression.Sub.SlideInkToolbarVisible = eventHandleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View // Listen to the use of the laser pointer and marker. app.Sub.SlideInkToolbarVisible = ({Data}) => { console.log ('Listen to the use of the laser pointer and marker:', Data); }; // Display the markup toolbar. view.MarkerEditVisible = true; }
Display or hide a specified toolbar
Syntax
Expression.ActivePresentation.SlideShowWindow.View.SetToolVisible(toolName, flag)Expression: the document type application object.
Parameters
Parameter
Data type
Description
toolName
String
The name of the tool you want to configure.
flag
Boolean
Specifies whether to display the specified tool. Valid values:
false: hide the tool.
true: display the tool.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain slide show settings. const SlideShowSettings = await app.ActivePresentation.SlideShowSettings; // Run slide show. await SlideShowSettings.Run(); // Obtain the window object. const SlideShowWindow = await app.ActivePresentation.SlideShowWindow; // Obtain the view object. const view = await SlideShowWindow.View; const linkTip=app.Enum.PpToolType.pcPlayHoverLink // Hover hyperlink. const imageTip=app.Enum.PpToolType.pcImageHoverTip // Hover image. const menu=app.Enum.PpToolType.pcPlayingMenu // Right-click menu. // Hide the tool after 2,000 milliseconds. setTimeout(() => { // Hide specified tools in play mode. view.SetToolVisible(linkTip, false); view.SetToolVisible(imageTip, false); view.SetToolVisible(menu, false); }, 2000) }
Meeting synchronization
Listen to the document changes triggered by the operations of a user
Syntax
Expression.ApiEvent.AddApiEventListener('OnDocViewChange', ({ Data, Type, UserActive }) => { console.log('OnDocViewChange') })Expression: the document type application object.
Parameters
Parameter
Data type
Description
Data
Object
The information about the document changes triggered by the operations of a user.
Type
String
The type of the document changes triggered by the operations of the user.
UserActive
Boolean
Whether the document changes are triggered by the operations of the user. Meeting participants can determine whether they need to cancel synchronization based on UserActive.
Example
async function example() { await instance.ready(); const apiEvent = instance.ApiEvent; apiEvent.AddApiEventListener('OnDocViewChange', (e) => { console.log ('Listen to the document changes triggered by the operations of a user:', e); }); }
Synchronize the document changes triggered by the operations of a user with meeting participants
Syntax
Expression.SetDocView({ Type, Data })Expression: the document type application object.
Parameters
Synchronization content parameters are obtained by listening to the document changes triggered by the operations of a user.
Parameter | Data type | Description |
Type | String | The type of the document changes triggered by the operations of a user. |
Data | Object | The information about the document changes triggered by the operations of the user. |
Example
async function example() { await instance.ready(); const app = instance.Application; const apiEvent = instance.ApiEvent; apiEvent.AddApiEventListener('OnDocViewChange', (Data) => { console.log ('Listen to the document changes triggered by the operations of a user:', Data); // Synchronize the document changes triggered by the operations of a user. app.SetDocView(Data); }); }
Obtain the current document operation status
Syntax
Expression.DocViewStateExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; const apiEvent = instance.ApiEvent; // Listen to the document changes triggered by the operations of a user. apiEvent.AddApiEventListener('OnDocViewChange', (e) => { console.log ('Listen to the document changes triggered by the operations of a user:', e); }); // Obtain the current document operation status. const docViewState = await app.DocViewState; }
Example for the speaker side of meeting synchronization
Main scenarios for the speaker side:
Scenario 1. Listen to the document operations of a speaker, obtain the operation information, and then synchronize the operation information to the meeting participants in real time.
Scenario 2. Obtain the current document operation status of a speaker. Then, synchronize it to the participants who need to follow the synchronization after entering the meeting for the first time or the meeting participants who require synchronization again after they cancel synchronization.
Example
async function example() { await instance.ready(); const app = instance.Application; const apiEvent = instance.ApiEvent; // Synchronize the information on the speaker side with the meeting participants. const sendMessage = (Data) => { // You need to send the information on the speaker side to the meeting participants by using the information sending method provided by the developer. console.log ('Send information to the meeting participants for synchronization', Data); } // Synchronize the document changes triggered by the operations of a user in real time. apiEvent.AddApiEventListener('OnDocViewChange', (Data) => { console.log ('Listen to the document changes triggered by the operations of a user:', Data); sendMessage(Data); }); // Synchronization for the participants who enter the meeting for the first time or the meeting participants who require synchronization again after they cancel synchronization. const docViewState = await app.DocViewState; sendMessage(docViewState); }
Example for the meeting participant side of meeting synchronization
Main scenarios for the meeting participant side:
Scenario 1. Synchronize the synchronization information sent by a speaker, including real-time information and initial information.
Scenario 2. Determine whether they need to cancel synchronization.
Example
async function example() { await instance.ready(); const app = instance.Application; const apiEvent = instance.ApiEvent; // Synchronize the operation information on the speaker side to the meeting participants by using the information sending method provided by the developer. onMessage((Data) => { // Synchronize the synchronization information sent from the speaker side. app.SetDocView(Data); }) // Cancel synchronization. apiEvent.AddApiEventListener('OnDocViewChange', (Data) => { console.log ('Listen to the document changes triggered by the operations of a user:', Data); // When the user performs operations on a document, meeting participants can determine whether to cancel synchronization based on UserActive. if (Data.UserActive) { console.log ('Cancel synchronization'); } }); }