The Demonstration Application

The demonstration application that I developed to show how to use the VideoPresentations class offers users three choices from its main page. The choices are three Emily Dickinson poems. When users make a selection, they're brought to a page that plays a video file in which the selected poem is read. This section discusses the demonstration program, which can be viewed at http://www.ASPNET-Solutions.com/VideoPresentationsCS.

Instantiating and Setting Up the VideoPresentations Class

It's easy to instantiate the VideoPresentations class. Just declare a VideoPresentations object and then create it with the new operator, as follows:

C#
 VideoPresentations VP = new VideoPresentations(); 
VB
 Dim VP As New VideoPresentations() 

Some minimal property setting must take place before the object is ready to use. At the very least, you must specify the directory name and the file name, as follows:

C#
 VP.Directory = "Poem1"; VP.Filename = "video.asx"; 
VB
 VP.Directory = "Poem1" VP.Filename = "video.asx" 

If you plan to leave the table of contents enabled (which is the default), you'll need to add items by calling the AddTOCEntry() method, as follows:

C#
 VP.AddTOCEntry( "Entry One" ); VP.AddTOCEntry( "Entry Two" ); 
VB
 VP.AddTOCEntry("Entry One") VP.AddTOCEntry("Entry Two") 

Listing 20.6 shows the code from the Poem1.aspx.cs file; the other two poem pages are identical except for the table of contents items that are added.

Listing 20.6 The Poem1.aspx.cs Source Code
 public class Poem1 : System.Web.UI.Page {   public VideoPresentations m_VP;   private void Page_Load(object sender, System.EventArgs e)   {     m_VP = new VideoPresentations();     m_VP.Directory = "Poem1";     m_VP.Filename = "video.asx";     m_VP.SlideWidth = 454;     m_VP.SlideHeight = 340;     m_VP.AddTOCEntry( "I Never Saw a Moor" );     m_VP.AddTOCEntry( "Never Saw Moor/Sea" );     m_VP.AddTOCEntry( "Heather/Wave" );     m_VP.AddTOCEntry( "Never Spoke With God/Visited Heaven" );     m_VP.AddTOCEntry( "Certain of the Spot" );   } 

Emitting Code into the HTML

After the VideoPresentations object is created and initialized, the JavaScript and the HTML code must be emitted into the .aspx file. Within the <HEAD> tag, the style data and the JavaScript should be emitted. Within the <BODY> tag, the player object, table of contents, VCR control, and slide window should be emitted. Listing 20.7 shows how a VideoPresentations class named m_VP (which was declared and created in the Page_Load() method) emits the code into the .aspx file.

Listing 20.7 Using the VideoPresentations Object to Emit Code into the .aspx File
 <HTML>   <HEAD>     <title>Poem1</title>     <%       Response.Write( m_VP.StyleData );       Response.Write( m_VP.GetJavascriptCode() );     %>   </HEAD>   <body bgColor="lightpink">     <DIV align="center">       <P><FONT size="5">Video Presentations Demo Application</FONT></P>       <table>         <tr>           <td align="middle">             <%              Response.Write( "<p>" + m_VP.PlayerObject + "<br>\r\n" );              Response.Write( m_VP.SlideWindowCode + "</p>\r\n" );             %>           </td>           <td valign="top" align="middle">             <%              Response.Write( "<p>" + m_VP.GetTOCCode() + "</p>\r\n" );              Response.Write( "<p>" + m_VP.VCRControl + "</p>\r\n" );             %>           </td>         </tr>       </table>       <P>&nbsp;</P>       <P><A href="Default.aspx">         Back to Video Presentations Main Page</A></P>     </DIV>   </body> 


ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ISBN: 321159659
EAN: N/A
Year: 2003
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net