BIFS Tutorial - Part VI

Controling Media Objects

As said in part V, time-dependent nodes cannot be used to seek media objects, that is to start playback at a time other than the begining. In order to achieve this primordial functionality, MPEG-4 has introduced nodes interacting directly with the OTB of media objects. In VRML, although you know a media is playing, you cannot retrieve the exact timing of the playback nor modify media playback origin. MPEG-4 has all the tools needed for that, as well as some nice extensions allowing to describe segments of the media in time, much like DVD chapters.


MediaControl node:

The MediaControl node is a powerfull tool giving interactive control on an object time base. Very few players currently implement this node, and almost none of them is able to perform negative speed playback, hence we will only focus on regular (positive speed) playback. The syntax of the node is:

field

field type

event type

default value

description

mediaStartTime SFTime exposedField -1 media object time playback should start at in seconds
mediaStopTime SFTime exposedField +Infinity media object time playback should stop at in seconds
mediaSpeed SFFloat exposedField 1.0 media playback speed
loop SFBool exposedField FALSE Indicates whether playback should restart when mediaStopTime is reached
url MFString exposedField [] Object Identifier of the media / media segments
preRoll SFBool exposedField TRUE indicates whether the media object should be pre-rolled or not
mute SFBool exposedField FALSE indicates whether media composition should be skipped or not
enabled SFBool exposedField TRUE indicates whether the node controls the media object or not
isPreRolled SFBool eventOut   Indicates pre-rolling is completed


mediaStartTime and mediaStopTime indicate the playback interval of the controled media object. Let's explain their action when playing with a positive mediaSpeed:

-mediaStartTime = -1: the media object shall start from its current clock time. If the clock is stoped, this means the media object shall start from the begining, and if the clock is paused this means the media object shall resume (play from current clock time).

-mediaStartTime >= 0: the media object shall start at this specified time. If the time is greater than the object duration, playback won't occur.

-mediaStopTime < mediaStartTime: the media object is played until the end.

-mediaStopTime >= mediaStartTime: the media object is played until mediaStopTime is reached.

If mediaSpeed is negative, the behavior is the same with inversed roles of mediaStartTime and mediaStopTime.

If mediaSpeed is 0, the playback shall be paused if the media object is playing.

The loop and mediaSpeed fields over-ride any loop and speed of nodes using a media object sharing the OTB of the media object being control. For instance, assume we have a video object V and an audio object A, and we use the MediaControl node to control object V. The speed and loop field of the MovieTexture node using V are ignored, and the loop and speed field of the AudioClip/AudioSource node using A ARE ALSO IGNORED. Although this looks quite complicated (and is from an implementation point of view), what it means for content authoring is that if you want to control synchronized audio and video objects, you only need to control one and the other will automatically be controlled, which greatly simplifies authoring :)

Although media pre-rolling can be forced through MediaControl, this is more a delivery issue than an authoring one and we strongly suggest setting this field to TRUE.

There can be several media control on the same media object in the scene. However there are some restrictions on MediaControl and media objects controled due to the fact that the MediaControl modifies the behavior of the OTB: if two objects A and B use the same OTB, and there is one MediaControl node controling object A, then there shall not be any MediaControl node controling B or any other media object using the same OTB as A.

No matter what, given available implementations of this node,

THOU SHALL NOT USE MORE THAN ONE MEDIACONTROL PER OTB.

Note 1: There are cases where the media duration is not known, in which case reverse playback or looping is not possible. In these cases the related MediaControl fields shall be ignored

Note 2: there are cases where the media cannot be controled (for instance broadcast / multicast). In these cases the MediaControl does nothing.

Example:

Let's take the video example of part III (video1.xmt), and try to play video from scene time 0 to scene time 30 seconds, but only play the video interval [5s, 15s] in the media object. The movie texture will now be

<texture><MovieTexture url="'10'" startTime="0" stopTime="30"/></texture>

We will have to introduce a media control, and its syntax will be:

<MediaControl url="'10'" mediaStartTime="5.0" mediaStopTime="15.0" loop="true"/>

The final scene is video4.xmt, video4.bt, video4.mp4.

Note that the declaration's position of the MediaControl node is not important.


Media Segments and SegmentDescriptors:

Unfortunatelly the encoding tools currently available do not support segment descriptors, this tutorial's section will thus be completed later on...


MediaSensor:

The MediaSensor node is used to query timing and other information on the media it watches. It is thus usefull to retrieve the media duration and its current playback time, as well as media segments information. Its syntax is


field

field type

event type

default value

description

url MFString exposedField [] Object Identifier of the media / media segments to watch
mediaCurrentTime SFTime eventOut   indicates time ellapsed since absolute time 0 of the media
streamObjectStartTime SFTime eventOut   indicates media time at which the current segment started.
mediaDuration SFTime eventOut   indicates media duration
isActive SFBool eventOut   indicates whether one of the segments watched for is playing
info MFString eventOut   conveys information associated with the current segment.



For now we will only look at the MediaSensor without segments. It is less powerfull than when used with segments, but it can still be usefull to get some timing information or synchronize the an animation with the media. This nodes only generates events, its only field being the identifier of the media object to watch for. Hence the syntax of the node is fairly simple:

<MediaSensor DEF="MYSENSOR" url="'10'"/>

We assign an identifier in order to be able to retrieve the node information. The sample scene below based on video1.xmt shows how to get the media time of an object and display it, using a valuator and a text node. The final scene is video5.xmt, video5.bt, video5.mp4.


Exercises :

Exercise 17 : With a simple script and a MediaSensor node, try to animate a rectangle so that the animation cycle is the same as the media cycle. Then add a MediaControl node to modify the media playback interval and make sure the animation is still synchronized with the playback.

Exercise 18 : With a touch sensor, a rectangle and a script , write a seek bar that restarts playback from any point in the media object.


Conclusion :

We have seen in this part how to control a media object interactively and get its timing information. You have now all the tools needed to write content with embedded control bars and can start right away working on your next interactive presentation with all your latest vacation movies !!


[ Home ] [ Time-dependent Nodes] [ Controling Media Objects ] [ To be continued...]


Last Modified: 02/04/2005
Cyril Concolato & Jean Le Feuvre © 2002-2005