<HTML>
<HEAD>
<TITLE>DirectX Media SDK DirectAnimation Tutorial</TITLE>
<LINK REL=STYLESHEET HREF="../../../../../webcd/da/tutorial.css">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso8859-1">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="ROBOTS" CONTENT="noindex">
</HEAD>
<BODY BGCOLOR="WHITE" LINK=#0033CC TOPMARGIN=0 LEFTMARGIN=20>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->

<DIV CLASS="flush">
<TABLE WIDTH=100% BORDER=0 BGCOLOR=#000000>
<TR ALIGN=RIGHT><TD VALIGN=TOP><FONT CLASS=desc1 SIZE=2>
<IMG SRC="../../../../../media/image/d_prev.gif"
 WIDTH=71 HEIGHT=16 BORDER=0 ALT="Previous Topic">
<A HREF="../../../../../webcd/da/tutorial_main.htm" TARGET="_top">
<IMG SRC="../../../../../media/image/d_home.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Tutorial Home Page"></A>
<A HREF="Section2.html" TARGET="_top">
<IMG SRC="../../../../../media/image/u_next.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Next Topic">
</A></FONT></TD><TD WIDTH=30></TD></TR></TABLE></DIV>
<FONT CLASS=title><CENTER>Section 1: Latency Mask with Asynchronous Download</CENTER></FONT>
<BR>
<FONT CLASS=desc1>
This demo makes use of Asynchronous importation APIs to mask
load time.  Here, an opening animation plays until the
media is loaded.
<BR>
</FONT><BR>
<!--<FONT CLASS=code>
<FONT CLASS=desc1>-->
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> This class constructs the image and sound behaviors for the model.</TD></TR></FONT></TABLE>
<FONT CLASS=code>class AsyncModel extends Model {<BR>
<BR>
<DIV STYLE="margin-left: 0.125in">public void createModel(BvrsToRun blist) {<BR>
</DIV><DIV STYLE="margin-left: 0.25in">try {<BR>
</DIV></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Prepare the out parameters for importMovie.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.375in">ImageBvr[] movieImg = {null};<BR>
SoundBvr[] movieSnd = {null};<BR>
NumberBvr[] progress = {null};<BR>
ModifiableBehavior progressSw = new ModifiableBehavior(toBvr(0));<BR>
URL movieURL;<BR>
</DIV></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> The location of the movie.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.5in">movieURL = buildURL(getImportBase(),"movie/movie.avi");<BR>
</DIV><DIV STYLE="margin-left: 1.25in"></FONT>
<BR>
</DIV><TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Create a stand-in image.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.375in">loadAnimation waitLogo = new loadAnimation();<BR>
ImageBvr standinImg = waitLogo.getImage((NumberBvr)progressSw.getBvr());<BR>
</DIV></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Create a movie image behavior and a movie sound behavior by
 importing an avi file.</TD></TR></FONT></TABLE>
<FONT CLASS=code><DIV STYLE="margin-left: 0.375in">importMovie(movieURL, movieImg, movieSnd,<BR>
</DIV><DIV STYLE="margin-left: 1.125in">standinImg, silence,<BR>
null, progress, null);<BR>
</DIV><BR>
<DIV STYLE="margin-left: 0.375in">progressSw.switchTo(progress[0]);<BR>
</DIV></FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Set the image and sound behaviors for this model.  The stand-in image
 will be displayed while the movie is being downloaded.  In this
 example, the stand-in sound is silence.</TD></TR></TABLE></FONT>
<FONT CLASS=code><DIV STYLE="margin-left: 0.375in">setImage(overlay(movieImg[0], solidColorImage(black)));<BR>
setSound(movieSnd[0]);<BR>
</DIV><DIV STYLE="margin-left: 0.25in">} catch(MalformedURLException ex) {}<BR>
</DIV><DIV STYLE="margin-left: 0.125in">}<BR>
</DIV>}<BR>
</FONT>
<BR>
<TABLE><TR><TD WIDTH=500><FONT CLASS=desc1> Set the model in our applet class.</TD></TR></TABLE></FONT>
<FONT CLASS=code>public class AsyncApplet extends DXMApplet {<BR>
<DIV STYLE="margin-left: 0.125in">public void init() {<BR>
</DIV><DIV STYLE="margin-left: 0.25in">super.init();<BR>
setModel(new AsyncModel());<BR>
</DIV><DIV STYLE="margin-left: 0.125in">}<BR>
</DIV>}<BR>
</TABLE><BR>
</FONT><FONT CLASS=link><A ID=cpslug HREF="../../../../../help/da/dalegal.htm" TARGET="_top">&#169; 1997 Microsoft Corporation. All rights reserved. Terms of Use.</A></FONT>
</TABLE>
<BR>
<BR>
<DIV CLASS="flush">
<TABLE WIDTH=100% BORDER=0 BGCOLOR=#000000>
<TR ALIGN=RIGHT><TD VALIGN=TOP><FONT CLASS=desc1 SIZE=2>
<IMG SRC="../../../../../media/image/d_prev.gif"
 WIDTH=71 HEIGHT=16 BORDER=0 ALT="Previous Topic">
<A HREF="../../../../../webcd/da/tutorial_main.htm" TARGET="_top">
<IMG SRC="../../../../../media/image/d_home.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Tutorial Home Page"></A>
<A HREF="Section2.html" TARGET="_top">
<IMG SRC="../../../../../media/image/u_next.gif" WIDTH=48 HEIGHT=16 BORDER=0 ALT="Next Topic">
</A></FONT></TD><TD WIDTH=30></TD></TR></TABLE></DIV>

</TABLE></BODY>
</HTML>
