Syntax - Subjects

Subjects are the main building blocks of a XIMPEL presentation. When jumping from one part of the presentation to another part of the presentation we are always jumping to another subject. In other words, a subject identifies a part of the presentation which can be requested to play at any point in time.

playlist.xml - a playlist containing two subjects

						<?xml version="1.0" encoding="utf-8"?>
						<ximpel>
						<playlist>

							<subject id="presentationStart" leadsTo="presentationEnd">
								<media>
									<video>
										<source file="welcoming_video" extensions="mp4" types="video/mp4" />
									</video>
								</media>
							</subject>

							<subject id="presentationEnd">
								<media>
									<video>
										<source file="goodbye_video" extensions="mp4" types="video/mp4" />
									</video>
								</media>
							</subject>

						</playlist>
						</ximpel>
This example will first play the subject with id presentationStart because that subject appears first in the document. When the video in that subject has finished XIMPEL will start playing the subject with id presentationEnd because the subject that ended had a leadsTo attribute with value presentationEnd. When the video of that subject has also finished, then there is nothing specified to play after it so the ximpel player stops.

Basic structure of a subject

playlist.xml

						<subject id="nameOfThisSubject" leadsTo="nameOfSomeSubject">
							<description>a description of the subject</description>
							<media>
								
							</media>
						</subject>
					
  • The id attribute specifies a unique name for the subject so that it can be referenced.
  • The leadsTo attribute is used to specify a subject name that should be played after this subject has finished playing. (the leadsTo attribute is optional)
  • The <description> tag is used to enter a description of the subject. The description is not visible in the presentation but it makes the playlist more readable.
  • The <media> tag is used to define a list of media content for this subject.


Linking subjects

There are a number of ways to jump to a subject.
  • Using the leadsTo attribute of a subject
  • Using the leadsTo attribute of a media item
  • Using the leadsTo attribute of an overlay

playlist.xml

					 
					    <subject id="overlayJump">
					    	<description>When the overlay is clicked we jump to subject "mediaJump"</description>
					        <media>
					            <video>
					                <source file="video_filename" extensions="mp4" types="video/mp4" />
					                <overlay leadsTo="mediaJump" text="Click me!" x="0" y="0" width="200" height="100" fontSize="2em" />
					            </video>
					        </media>
					    </subject>
					 
					    <subject id="mediaJump">
							<description>When the video ends we jump to subject "subjectJump"</description>
					        <media>
					            <video leadsTo="subjectJump">
					                <source file="video_filename" extensions="mp4" types="video/mp4" />
					            </video>
					        </media>
					    </subject>
					 
					    <subject id="subjectJump" leadsTo="overlayJump">
							<description>When the subject ends we jump back to subject "overlayJump"</description>
					        <media>
					            <video>
					                <source file="video_filename" extensions="mp4" types="video/mp4" />
					            </video>
					             <audio>
					                <source file="audio_filename" extensions="mp4" types="video/mp4" />
					            </audio>
					        </media>
					    </subject>
					


Jumping to subjects conditionally

It is possible to specify a conditional jump. To do this we use the <leadsTo> element with a subject and a condition attribute.

condition: The condition attribute specifies the condition that must be true for the jump to happen. The condition must be a javascript expression that results in true or false. Using conditions is most useful if you use XIMPEL variables in your playlist (see the variables section). Such a XIMPEL variable can be referenced within a condition by using a variable template like this: {{ variableName }}. This variable template will be replaced with the variable's value at the moment of evaluation.

subject: the subject attribute specifies the subject to jump to when the condition is met.

playlist.xml

						<subject id="subject1" leadsTo="subject1">
							<leadsTo subject="subject2" condition="{{score1}} > 8" />
							<leadsTo subject="subject3" condition="{{score1}} > 6" />

							<description>Repeat subject1 indefinitely untill: score1 > 6</description>
							<media>
								<!-- some media list where {{score1}} is modified -->
							</media>
						</subject>
In this case when the subject finished it will play subject1 UNLESS score1 > 8 then it will go to subject2 or score1 > 6 then it will go subject3. The first leadsTo condition listed that returns true is the leadsTo subject that will be used.

Swiping between subjects

The parameters swipeLeftTo, swipeRightTo, swipeUpTo and swipeDownTo can be used to cause subject changes upon swipe gestures. Note: For swipe gestures to work, you must include the JavaScript library Hammer.js.

playlist.xml

					    <subject id="Scene1" swipeLeftTo="Scene3" swipeRightTo="Scene2">
					        <media>
					            <image src="scene1.png" />
					        </media>
					    </subject>

					    <subject id="Scene2" swipeLeftTo="Scene1" swipeRightTo="Scene3">
					        <media>
					            <image src="scene2.png" />
					        </media>
					    </subject>

					    <subject id="Scene3" swipeLeftTo="Scene2" swipeRightTo="Scene1">
					        <media>
					            <image src="scene3.png" />
					        </media>
					    </subject>