The VideoPresentations Class

The VideoPresentations Class

The VideoPresentations class is in the VideoPresentations.cs source code module (or the VideoPresentations.vb module for the VB.NET version). The properties and their description are contained in Table 20.1.

There are a few public methods for the VideoPresentations class. They can be seen in Table 20.2.

Two things must be done to use the VideoPresentations class. The first is to instantiate the class and set its properties so that the desired behavior will result. I suggest doing this in the code behind the module, but it can be done in the ASPX code if you prefer. The second thing that must be done is to output the JavaScript and HTML code into the ASPX code.

Table 20.1. The VideoPresentations Properties

Property

Type

Description

StyleData

String

This property contains the text with the HTML style specifications for the <DIV> tags.

StartupCode

String

This property contains the text with the JavaScript code necessary for variable initialization.

LoadCode

String

This property contains the text with the JavaScript code that loads the media file.

UseMarkerCode

Boolean

This property determines whether the marker code will be emitted with all the other JavaScript code.

MarkerCode

String

This property contains the text with the JavaScript code that seeks to markers in the media file.

ScriptCommandCode

String

This property contains the text with the JavaScript code that handles the ScriptCommand() event.

UseTOC

Boolean

This property determines whether the table of contents will be output with all the other JavaScript code.

MouseControlCode

String

This property contains the text with the JavaScript code that manages the mouse interaction for the VCR control.

MarkerHitCode

String

This property contains the text with the JavaScript code that responds to a marker selection.

StatusCode

String

This property contains the text with the JavaScript code that responds to the media player's status.

PlayerObject

String

This property contains the text with the HTML code that instantiates the ActiveX media player.

VCRControl

String

This property contains the text with the HTML code for the VCR control images.

Filename

String

This property contains the file name of the media that will be displayed.

Directory

String

This property contains the directory in which the .asx file resides. This directory will always be relative to the current directory.

TOCList

DataSet

This property contains the text with the HTML code that displays the table of contents list. A DataSet was the best choice as opposed to a string array because there are multiple columns.

AnimationStart

Boolean

This property determines whether the media player displays an animation while the media is being retrieved from the server.

TransparentStart

Boolean

This property determines whether the media will perform a transparent start.

AutoStart

Boolean

This property determines whether the media will automatically start playing.

Volume

Integer

This property determines the volume of the media player.

ShowControls

Boolean

This property determines whether the media player's controls will be displayed.

PlayerWidth

Integer

This property sets the width of the displayed media player.

PlayerHeight

Integer

This property sets the height of the displayed media player.

SlideWidth

Integer

This property sets the width of the displayed slides.

SlideHeight

Integer

This property sets the height of the displayed slides.

SlideWindowCode

String

This property contains the text for the HTML code that displays the slides.

I'll talk about these steps in more detail in the section entitled "The Demonstration Application." Here, we'll take a look at how the VideoPresentations class works.

Table 20.2. VideoPresentations Public Methods

Method

Description

AddTOCEntry

This method allows a table of contents item to be added to the list. It takes a string as an argument.

GetTOCCode

This method returns a string that contains the formatted table of contents list.

GetStyleCode

This method returns the HTML-style code.

GetJavascriptCode

This method returns all JavaScript code that must be emitted for the VideoPresentations class to work correctly.

The VideoPresentations class has several private data members in which the JavaScript text is stored. The following is the string variable that contains the JavaScript startup code:

 private string m_strLoadCode =   "<script language='JavaScript'>\r\n" +   " function loadIt()\r\n" +   " {{\r\n" +   "  var pluginJavaPeerRef = document.myform.VideoPlay;\r\n" +   "  if( NS4 )\r\n" +   "  {{\r\n" +   "   if (document.myform.VideoPlay != null)\r\n" +   "   {{\r\n" +   "     objPlayer = document.myform.VideoPlay;\r\n" +   "     sBrowser = \"notIE\";\r\n" +   "     document.appObs.setByProxyDSScriptCommandObserver(" +   "pluginJavaPeerRef, true);\r\n" +   "     document.myform.VideoPlay.SetFileName ( \"{0}\" );\r\n" +   "     document.myform.VideoPlay.Play();\r\n" +   "   }}\r\n" +   "  }}\r\n" +   " }}\r\n" +   "</script>\r\n" +   "\r\n"; 

The m_strLoadCode code string variable is private, but the data can be retrieved using the VideoPresentations.LoadCode property. Notice that the string expects a single argument, identified by the {0} that can be seen within the string. This string must be formatted in the LoadCode property's accessor, as follows:

 public string LoadCode {   get   {     return( string.Format( m_strLoadCode, Filename ) );   } } 

Other private data members include m_strStyleData (accessed by the StyleData property), m_strStartupAndVars (accessed by the StartupCode property), m_strMarkerCode (accessed by the MarkerCode property), m_strScriptCommandCode (accessed by the ScriptCommandCode property), m_strMouseControlCode (accessed by the MouseControlCode property), m_strMarkerHitCode (accessed by the MarkerHitCode property), m_strStatusCode (accessed by the StatusCode property), and m_strPlayerObject (accessed by the PlayerObject property).

Listing 20.5 shows all of the code for the VideoPresentations class except for the private data members.

Listing 20.5 The VideoPresentations.cs Source Code
 public string StyleData {   get   {     return( m_strStyleData );   } } public string StartupCode {   get   {     return( m_strStartupAndVars );   } } public string LoadCode {   get   {     return( string.Format( m_strLoadCode, Filename ) );   } } public bool UseMarkerCode {   get   {     return( m_bUseMarkerCode );   }   set   {     m_bUseMarkerCode = value;   } } public string MarkerCode {   get   {     return( string.Format( m_strMarkerCode, Directory ) );   } } public string ScriptCommandCode {   get   {     return( string.Format( m_strScriptCommandCode, Directory ) );   } } public bool UseTOC {   get   {     return( m_bUseTOC );   }   set   {     m_bUseTOC = value;   } } public string MouseControlCode {   get   {     return( m_strMouseControlCode );   } } public string MarkerHitCode {   get   {     return( m_strMarkerHitCode );   } } public string StatusCode {   get   {     return( m_strStatusCode );   } } public string PlayerObject {   get   {     return( string.Format( m_strPlayerObject, Directory, Filename,       AnimationStart, TransparentStart, AutoStart, Volume,        ShowControls ) );   } } public string VCRControl {   get   {     return( m_strVCRControl );   } } public string Filename {   get   {     return( m_strFilename );   }   set   {     m_strFilename = value;   } } public string Directory {   get   {     return( m_strDirectory );   }   set   {     m_strDirectory = value;   } } public void AddTOCEntry( string strEntry ) {   m_TOCEntries.Add( strEntry ); } public DataSet TOCList {   get   {     // Create a new DataSet object.     DataSet ds = new DataSet();     // Add a table named TOCEntry.     ds.Tables.Add( "TOCEntry" );     // Add two columns, title and number.     ds.Tables[0].Columns.Add( "Title" );     ds.Tables[0].Columns.Add( "Number" );     // Loop through each TOC entry.     for( int i=0; i<m_TOCEntries.Count; i++ )     {       // Create a string array that'll be       //   used to add the wor.       string[] ThisRow = { m_TOCEntries[i],         Convert.ToString( i + 1 ) };       // Add the row.       ds.Tables[0].Rows.Add( ThisRow );     }     // Return the DataSet object to caller.     return( ds );   } } public string GetStyleCode() {   return( StyleData ); } public string GetJavascriptCode() {   string strScriptCode = StartupCode + LoadCode;   if( UseMarkerCode )   {     strScriptCode += MarkerCode;   }   strScriptCode += ScriptCommandCode;   if( UseTOC )   {     strScriptCode += ( MouseControlCode + MarkerHitCode );   }   return( strScriptCode ); } public bool AnimationStart {   get   {     return( m_bAnimationStart );   }   set   {     m_bAnimationStart = value;   } } public bool TransparentStart {   get   {     return( m_bTransparentStart );   }   set   {     m_bTransparentStart = value;   } } public bool AutoStart {   get   {     return( m_bAutoStart );   }   set   {     m_bAutoStart = value;   } } public int Volume {   get   {     return( m_nVolume );   }   set   {     m_nVolume = value;   } } public bool ShowControls {   get   {     return( m_bShowControls );   }   set   {     m_bShowControls = value;   } } public int SlideWidth {   get   {     return( m_nSlideWidth );   }   set   {     m_nSlideWidth = value;   } } public int SlideHeight {   get   {     return( m_nSlideHeight );   }   set   {     m_nSlideHeight = value;   } } public string SlideWindowCode {   get   {     return( string.Format( m_strSlideWindowCode, Directory, SlideWidth,        SlideHeight ) );   } } public string GetTOCCode() {   // Start the string off with the <table> tag,   //   and <th></th> tags.   string strRetCode = "<table border=0>\r\n <th>\r\n" +     "Table of Contents\r\n </th>\r\n";   // Loop through each TOC entrie to create the HTML.   for( int i=0; i<m_TOCEntries.Count; i++ )   {     // Start the row.     strRetCode += " <tr>\r\n";     // Start the column.     strRetCode += "  <td>\r\n";     // Create the link with all of the javascript     //   code.     strRetCode += ( "<a href=\"#\" onclick=\"GoMarker(" +       Convert.ToString( i + 1 ) +       "); return false\"><div id=\"M" +       Convert.ToString( i + 1 ) +       "\" class=\"Marker\" onmousedown=\"TOCmouseDown();" +       "\" onmouseout=\"TOCmouseOut();" +       "\" onmouseover=\"TOCmouseOver();\">" +       m_TOCEntries[i] + "</div></a>" );     // End the column.     strRetCode += "  </td>\r\n";     // End the row.     strRetCode += " </tr>\r\n";   }   // End the table.   strRetCode += "</table>\r\n";   return( strRetCode ); } 


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