|
||||||||||||||||||||||||
|
|
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.
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. SamplesThe 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 alsoIPresentationPlaybackController
Interface |
||||||||||||||||||||||
|
||||||||||||||||||||||||