banner art

priorityClass element

The priorityClass element controls how one media element interrupts the playback of another element and the playback state of the interrupted media element. If you simply want to configure one element to interrupt playback of another, you can use an excl or seq element with a begin attribute set to start one element while another element is playing.

The priorityClass element, however, enables you to specify whether the interrupted element stops, pauses, or can never be interrupted. If a media element is set to Pause when interrupted, it will continue to stream from the point at which it was paused when the element that interrupted it ends. If it is set to Stop, it will not stream when the element that interrupted it ends. Using the priorityClass element, you can also specify whether an interruption is deferred until the current media element finishes or ignored altogether. Furthermore, the child elements in a priorityClass element and the priorityClass elements contained within an excl element container are prioritized by the order in which they are listed in the playlist. The ability to adjust the priority further enables you to control the behavior of child elements.

Keep the following points in mind when working with priorityClass elements:

The following example features each of the three attributes that are exclusive to the priorityClass element: peers, higher, and lower. In practical use, you would probably choose a simpler playlist design, but this example illustrates how the priorityClass element and its attributes control the interruption and flow of a playlist.

The playlist consists of three priorityClass elements contained within an excl element. Since its begin attribute is set to 0 seconds (0s), the media element named media1 plays first. After 10 seconds, media2 interrupts media1. Media2 is within the same priorityClass element as media1, meaning that they are peers. Because the peers attribute of media1's priorityClass is set to Stop, media1 stops when media2 interrupts it.

The media element named media4 is set to begin four seconds into the playlist. However, the lower attribute of the priorityClass element named Priority1 is set to Defer. Therefore, because media4 is in a lower-ranking priorityClass element (Priority3) than the media elements in Priority1, media4 cannot start until all the media elements in Priority1 finish.

Ten seconds after media4 begins, the media element named media3 begins (because its begin attribute is set to media4.begin+10s). The element named media3 is in the priorityClass element named Priority2, which has a higher priority than Priority3. Because the higher attribute in Priority3 is set to Pause, media4 pauses until media3 has finished playing. After media3 is finished, media4 continues playing back from the point at which it was paused.

<?wsx version='1.0'?>
		<priorityClass id="Priority1" peers="Stop" lower="Defer">
			<media id="media1" src="Media1.wmv" begin="0s"/>
			<media id="media2" src="Media2.wmv" 
		<priorityClass id="Priority2">
			<media id="media3" src="Media3.wmv" begin="media4.begin+10s"/>
		<priorityClass id="Priority3" higher="Pause">
			<media id="media4" src="Media4.wmv" begin="4s"/>

There are many ways to use priorityClass elements in playlists to insert ads or other digital media content. In the following example playlist, script commands embedded in a stream from an encoder (which is the media element named media1) trigger different media elements in the playlist. The begin attributes of the advertisements in the playlist have values of Ad1Event, Ad2Event, and Ad3Event. When the server detects a FIRE_EVENT script command that has a value that matches one of the begin attribute values, the corresponding media element interrupts the live stream. Playback returns to the encoder stream (media1) after the element finishes because the peers attribute of media1 is set to Pause. For example, if a script command contains the text strings FIRE_EVENT and Ad2Event, media1 pauses and Ad2 plays back. When Ad2 is completed, media1 resumes playback.

<?wsx version='1.0'?>
		<priorityClass peers="Pause">
			<media id="media1" src="http://encoder/livestream:1000" 
			<media id="Ad1" src="Comml1.wma" begin="Ad1Event"/>
			<media id="Ad2" src="Comml2.wma" begin="Ad2Event"/>
			<media id="Ad3" src="Comml3.wma" begin="Ad3Event"/>

When switching from a live encoder stream, you can precede the FIRE_EVENT command with a CUE_EVENT command. When the server receives this command, it prepares the media element specified in the script command and buffers the beginning portion of the content. This way, when the FIRE_EVENT command is received, the switch to the media element is seamless. For example, sending the script command type CUE_EVENT and value Ad2Event prepares the file Comm2.wma for broadcast.


Attributes modify the properties of a playlist element. You can use the following optional attributes with a priorityClass element.

Name Description
syncEvent Provides a string used to trigger the beginning or end of an element in a wrapper playlist. For more information, see syncEvent attribute.
higher Controls how child elements within a priorityClass element behave when interrupted by child elements in higher priority priorityClass elements. For more information, see higher attribute.
id Provides a name for the priorityClass element that can be referenced by other elements. For more information, see id attribute.
lower Controls how child elements within a priorityClass element behave when interrupted by child elements in lower priority priorityClass elements. For more information, see lower attribute.
peers Controls how child elements behave when interrupted by child elements within the same priorityClass element. For more information, see peers attribute.

Note Image Notes

Related topics

© 2005 Microsoft Corporation. All rights reserved.