Multimedia
  Home arrow Multimedia arrow Page 6 - Learning To SMILe
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
MULTIMEDIA

Learning To SMILe
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 8
    2002-11-21


    Table of Contents:
  • Learning To SMILe
  • Getting The Tools
  • Anatomy 101
  • Laying It Out
  • Spending Time
  • Playing In Sync
  • A Click In Time...
  • Bedtime Reading

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Learning To SMILe - Playing In Sync
    ( Page 6 of 8 )

    Of course, in the real world, it's unlikely that you'll be using a single media clip within your SMIL file. And as the number of elements increases, so does the need for synchronization between them. Which is why SMIL includes three synchronization elements, designed to address your most common needs.

    The first of these is the <seq> element, which allows you to group a bunch of elements together and play them back sequentially. Here's an example:

    <smil xmlns="http://www.w3.org/2001/SMIL20/Language"> <head> <layout> <root-layout width="800" height="600" backgroundColor="white" /> <region id="alpha" left="20" top="20" width="250" height="100" /> <region id="beta" left="120" top="420" width="700" height="100" /> </layout> </head> <body> <seq> <audio src="bg1.wav" region="alpha" /> <audio src="bg2.wav" region="beta" /> </seq> </body> </smil>
    In this case, the two audio files are played sequentially, one after the other. Obviously, you can exert further control over the manner in which they are displayed by placing appropriate "begin", "dur" and "end" attributes for each element.

    ... <body> <seq> <audio src="bg1.wav" region="alpha" begin="5s" dur="2s" /> <audio src="bg2.wav" region="beta" /> </seq> </body> ...
    In this case, the first audio file would begin playing 5 seconds into the clip, die after 2 seconds, and would be immediately followed by the second file, which would play all the way through.

    SMIL also allows you to play back media in parallel, rather than sequentially, via the <par> grouping element. Consider the following variant of the previous example, in which both audio files are played simultaneously in their respective regions:

    <smil xmlns="http://www.w3.org/2001/SMIL20/Language"> <head> <layout> <root-layout width="800" height="600" backgroundColor="white" /> <region id="alpha" left="20" top="20" width="250" height="100" /> <region id="beta" left="120" top="120" width="600" height="100" /> </layout> </head> <body> <par> <audio src="bg1.wav" region="alpha" /> <audio src="bg2.wav" region="beta" /> </par> </body> </smil>
    Obviously, "begin" and "dur" attributes can be used here as well – consider the following example, which plays back an audio file and an image in parallel; the audio file repeats 5 times, with the image appearing on the second iteration:

    <smil xmlns="http://www.w3.org/2001/SMIL20/Language"> <head> <layout> <root-layout width="800" height="600" backgroundColor="white" /> <region id="alpha" left="20" top="20" width="250" height="100" /> <region id="beta" left="120" top="420" width="700" height="100" /> </layout> </head> <body> <par> <audio src="bg.wav" region="beta" dur="4s" repeatCount="5" /> <img src="logo.jpg" region="alpha" begin="4s"/> </par> </body> </smil>
    It must be noted that although there are time differences in the playback of the two media files in the example above, they are both loaded together.

    In SMIL, it is also possible to created nested groups of elements. Consider the following example, which demonstrates:

    <smil xmlns="http://www.w3.org/2001/SMIL20/Language"> <head> <layout> <root-layout width="800" height="800" backgroundColor="white"> <region id="vid" left ="20" top="20" width="600" height="600" /> <region id="txt" left ="20" top="700" width="300" height="100" /> </layout> </head> <body> <par> <seq> <video src="video1.rm" region="vid" begin="6s" end="8s"/> <video src="video2.rm" region="vid" begin="2s" dur="10s"/> </seq> <text src="data.txt" region="txt" /> </par> </body> </smil>
    Finally, SMIL also provides the <excl> synchronization element, which allows you to create a group of media clips and play them, one at a time, in a pre-defined order. Only one media clip within an <excl> group can be played at any time; parallel play is not permitted within such a block.

    Here's an example:

    <smil xmlns="http://www.w3.org/2001/SMIL20/Language"> <head> <layout> <root-layout width="800" height="800" backgroundColor="white"> <region id="vid1" left="20" top="20" width="600" height="600" /> <region id="vid2" left="50" top="70" width="100" height="100" /> <region id="img" left="20" top="700" width="300" height="100" /> </layout> </head> <body> <excl> <video src="video1.rm" region="vid1" begin="15s" end="10s"/> <video src="video2.rm" region="vid2" begin="10s" end="8s"/> <img src="image.jpg" region="img" begin="20s" dur="6s"/> </excl> </body> </smil>
    In the above exclusive group, the media files are run one after the other, in the order specified in the timing, and not in order of hierarchy. 

     
     
    >>> More Multimedia Articles          >>> More By icarus, (c) Melonfire
     

       

    MULTIMEDIA ARTICLES

    - Basic Lighting in OpenGL and SDL Game Progra...
    - Working with Colors in OpenGL for Game Progr...
    - Animation in OpenGL for Game Programming usi...
    - Game Programming with SDL: Getting Started w...
    - Using OpenGL with SDL for Game Programming
    - Learning Sound for Game Programming using SDL
    - Game Programming using SDL: Raw Graphics and...
    - Game Programming using SDL: Getting Started
    - Network Radio With Icecast
    - Learning To SMILe





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek