Component Page /BusinessClasses/YouTubeScript.cs (C#)
1: //******************************************************************************  
2: // Module           :   YouTubeScript.cs  
3: // Author           :   Alexander Bell  
4: // Copyright        :   2009 Infosoft International Inc  
5: // Date Created     :   06/29/2009  
6: // Last Modified    :   07/18/2009  
7: // Version          :   1.0.0.1  
8: // Description      :   YouTube Player Javascript generator  
9:   
10: //******************************************************************************  
11: // DISCLAIMER: This Application is provide on AS IS basis without any warranty  
12: //******************************************************************************  
13:   
14: //******************************************************************************  
15: // TERMS OF USE     :   This module is copyrighted.  
16: //                  :   You can use it at your sole risk provided that you keep  
17: //                  :   the original copyright note.  
18: //******************************************************************************  
19:   
20: using System;  
21: using System.Text;  
22:   
23: ///*****************************************************************************  
24: /// <summary>  
25: /// Generate Javascript to embed YouTube Video Player in ASP.NET web page  
26: /// </summary>    
27: public static class YouTubeScript  
28: {  
29:     #region YouTube Player default script: no autoplay, 320x240  
30:     /// <summary>  
31:     /// YouTube Player default script: no autoplay, 320x240  
32:     /// </summary>  
33:     /// <param name="id">id</param>  
34:     /// <param name="auto">int</param>  
35:     /// <returns>string</returns>  
36:     public static string Get(string id)  
37:     { return Get(id, false, 320, 240); }  
38:     #endregion  
39:   
40:     #region YouTube Player script w/autoplay option (320x240)  
41:     /// <summary>  
42:     /// YouTube Player script w/autoplay option (320x240)  
43:     /// </summary>  
44:     /// <param name="id">id</param>  
45:     /// <param name="auto">bool</param>  
46:     /// <returns>string</returns>  
47:     public static string Get(string id, bool auto)  
48:     { return Get(id, auto, 320, 240); }  
49:     #endregion  
50:   
51:     #region YouTube Player script w/autoplay option (320x240)  
52:     /// <summary>  
53:     /// YouTube Player script w/autoplay option (320x240)  
54:     /// </summary>  
55:     /// <param name="id">id</param>  
56:     /// <param name="auto">int</param>  
57:     /// <returns>string</returns>  
58:     public static string Get(string id, int auto)  
59:     { return Get(id, ((auto == 1) ? true : false), 320, 240); }  
60:     #endregion  
61:   
62:     #region YouTube Player script w/selectable: autoplay and W/H  
63:     /// <summary>  
64:     /// YouTube Player script w/selectable: autoplay and W/H options  
65:     /// </summary>  
66:     /// <param name="id">id</param>  
67:     /// <param name="auto">bool</param>  
68:     /// <param name="W">int</param>  
69:     /// <param name="H">int</param>  
70:     /// <returns>string</returns>  
71:     public static string Get(string id, bool auto, int W, int H)  
72:     { return Get(id, auto, W, H, true); }  
73:     #endregion  
74:   
75:     #region YouTube Player script w/selectable: autoplay, W/H and default border  
76:     /// <summary>  
77:     /// YouTube Player script w/selectable: autoplay, W/H, default border color    
78:     /// </summary>  
79:     /// <param name="id">id</param>  
80:     /// <param name="auto">bool</param>  
81:     /// <param name="W">int</param>  
82:     /// <param name="H">int</param>  
83:     /// <param name="Border">bool</param>  
84:     /// <returns>string</returns>  
85:     public static string Get(string id, bool auto, int W, int H, bool Border)  
86:     { return Get(id, auto, W, H, Border, "0x2b405b", "0x6b8ab6", 0); }  
87:     #endregion  
88:   
89:     #region YouTube Player script w/selectable: autoplay, W/H and border color  
90:     /// <summary>  
91:     /// YouTube Player script w/selectable: autoplay, W/H and border color  
92:     /// </summary>  
93:     /// <param name="id">id</param>  
94:     /// <param name="auto">bool</param>  
95:     /// <param name="W">int</param>  
96:     /// <param name="H">int</param>  
97:     /// <param name="Border">bool</param>  
98:     /// <param name="C1">string</param>  
99:     /// <param name="C2">string</param>  
100:     /// <returns>string</returns>  
101:     public static string Get  
102:             (string id,  
103:             bool auto,  
104:             int W,  
105:             int H,  
106:             string C1,  
107:             string C2)  
108:     { return Get(id, auto, W, H, true, C1, C2, 0); }  
109:     #endregion  
110:   
111:     #region YouTube Player script w/selectable: autoplay, W/H and border color  
112:     /// <summary>  
113:     /// YouTube Player script w/selectable: autoplay, W/H and border color  
114:     /// </summary>  
115:     /// <param name="id">id</param>  
116:     /// <param name="auto">bool</param>  
117:     /// <param name="W">int</param>  
118:     /// <param name="H">int</param>  
119:     /// <param name="Border">bool</param>  
120:     /// <param name="C1">string</param>  
121:     /// <param name="C2">string</param>  
122:     /// <returns>string</returns>  
123:     public static string Get  
124:             (string id,  
125:             bool auto,  
126:             int W,  
127:             int H,  
128:             bool Border,  
129:             string C1,  
130:             string C2,  
131:             int Start)  
132:     {  
133:         StringBuilder sb = new StringBuilder();  
134:         sb.Append(@"<embed src='http://www.youtube.com/v/");  
135:   
136:         // select the youTube item to play  
137:         sb.Append(id);  
138:   
139:         // set autoplay options (indicates number of plays)  
140:         if (auto) sb.Append("&autoplay=1");  
141:   
142:         // no related items to display  
143:         sb.Append("&rel=0");  
144:   
145:         // set border color 1 and 2  
146:         if (Border)  
147:         {  
148:             sb.Append("&border=1");  
149:             sb.Append("&color1=" + @C1);  
150:             sb.Append("&color2=" + @C2);  
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version
161: There is a limit of 150 source code lines in the evaluation version
162: There is a limit of 150 source code lines in the evaluation version
163: There is a limit of 150 source code lines in the evaluation version
164: There is a limit of 150 source code lines in the evaluation version
165: There is a limit of 150 source code lines in the evaluation version
166: There is a limit of 150 source code lines in the evaluation version
167: There is a limit of 150 source code lines in the evaluation version
168: There is a limit of 150 source code lines in the evaluation version
169: There is a limit of 150 source code lines in the evaluation version
170: There is a limit of 150 source code lines in the evaluation version
171: There is a limit of 150 source code lines in the evaluation version
172: There is a limit of 150 source code lines in the evaluation version
173: There is a limit of 150 source code lines in the evaluation version
174: There is a limit of 150 source code lines in the evaluation version
175: There is a limit of 150 source code lines in the evaluation version
176: There is a limit of 150 source code lines in the evaluation version
177: There is a limit of 150 source code lines in the evaluation version
178: There is a limit of 150 source code lines in the evaluation version
179: There is a limit of 150 source code lines in the evaluation version
180: There is a limit of 150 source code lines in the evaluation version
181: There is a limit of 150 source code lines in the evaluation version
182: There is a limit of 150 source code lines in the evaluation version
183: There is a limit of 150 source code lines in the evaluation version
184: There is a limit of 150 source code lines in the evaluation version
185: There is a limit of 150 source code lines in the evaluation version
186: There is a limit of 150 source code lines in the evaluation version
187: There is a limit of 150 source code lines in the evaluation version
188: There is a limit of 150 source code lines in the evaluation version

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.