fsplayer.api.IPlaybackListener Interface
There are various events occurring during presentation playback. The playback controller notifies external objects about these events via IPlaybackListener interface. This interface defines a set of methods which are invoked by playback controller when the corresponding events occur. These methods are as follows.
| Methods |
|
Method |
Description |
|
onPausePlayback():Void |
Invoked when presentation playback is suspended |
|
onStartPlayback():Void |
Invoked when presentation playback is resumed |
|
onAnimationStepChanged(stepIndex:Number):Void |
Invoked when slide animation step is changed during playback |
|
onSlidePositionChanged(position:Number):Void |
Invoked when playback position is changed during playback |
|
onCurrentSlideIndexChanged(slideIndex:Number):Void |
Invoked when slide switching occurs |
|
onSlideLoadingComplete(slideIndex:Number):Void |
Invoked when slide loading is completed |
|
onPresentationPlaybackComplete():Void |
Invoked at the end of presentation playback |
|
onKeyboardFocusStateChanged(acquireFocus:Boolean):Void |
Invoked when interactive element of the presentation (e.g. a text field of a Quiz) acquires or loses keyboard focus |
|
onPlaybackSuspended():Void |
Invoked when automatick playback is suspeneded at animation step end |
|
onPlaybackResumed():Void |
Invoked when automatic playback is resumed on user's request |
In order to receive event notifications you need to create a class which implements IPlaybackListener interface and pass the instance of this class to the addListener method of the IPresentationPlaybackController interface.
Samples
The following example illustrates the simplest implementation of IPlaybackListener interface.
Create MyPlaybackListener.as source file with the following content.
import fsplayer.api.*;
class MyPlaybackListener implements IPlaybackListener
{
function onPausePlayback():Void
{
trace("Presentation has been paused");
}
function onStartPlayback():Void
{
trace("Presentation playback was started");
}
function onCurrentSlideIndexChanged(slideIndex:Number):Void
{
trace("Current slide index has been changed to " + slideIndex);
}
function onSlideLoadingComplete(slideIndex:Number):Void
{
trace("Slide " + slideIndex + " has been just loaded");
}
function onSlidePositionChanged(position:Number):Void
{
trace("Current slide playback position was changed to " + position);
}
function onPresentationPlaybackComplete():Void
{
trace("Presentation playback has been completed");
}
function onAnimationStepChanged(stepIndex:Number):Void
{
trace("Animation step index has been changed to " + stepIndex);
}
}
Usage of MyPlaybackListener class:
import fsplayer.api.*;
import MyPlaybackListener;
var presentation:MovieClip = this.createEmptyMovieClip("presentation", 1);
var loader:CPresentationLoader = new CPresentationLoader()
loader.setPlayerListener(this);
loader.loadClip("c:\\test.swf", presentation);
function onPlayerInit(player:IPlayer)
{
var listener:MyPlaybackListener = new MyPlaybackListener();
player.getPlaybackController().addListener(listener);
}
Instead of implementing IPlaybackListener interface it is also possible to create an Object instance with a subset of IPlaybackListener functions and pass it to the addListener() method as it is shown in the following example:
import fsplayer.api.*;
var presentation:MovieClip = this.createEmptyMovieClip("presentation", 1);
var loader:CPresentationLoader = new CPresentationLoader()
loader.setPlayerListener(this);
loader.loadClip("c:\\test.swf", presentation);
function onPlayerInit(player:IPlayer)
{
var listener = new Object();
listener.onCurrentSlideIndexChanged = function(index:Number):Void
{
trace("Current slide index has been changed to " + index);
}
player.getPlaybackController().addListener(listener);
}
See also
IPresentationPlaybackController Interface
Flash Presentation ActionScript API Reference