Monday, 10 June 2013

Video play in Youtube

HTML:
<tr id="linkContent" runat="server" visible="false">
                        <td>
                            Link Path
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <asp:TextBox ID="txtLinkPath" runat="server" TextMode="MultiLine"></asp:TextBox>
                            <asp:Button ID="btnLinkPathUpload" runat="server" Text="Upload" OnClick="btnLinkPathUpload_Click" />
                        </td>
                    </tr>
 <tr>
                        <td colspan="2">
                        </td>
                        <td>
                            <div id="videoAndMusicContent" runat="server" visible="false">
                                <asp:HyperLink ID="lnkAttachment" runat="server"></asp:HyperLink>
                                <br />
                                <br />
                                <asp:Literal ID="ltrVideoAndMusic" runat="server"></asp:Literal>
                            </div>
                        </td>
                    </tr>


C# Code:

protected void btnLinkPathUpload_Click(object sender, EventArgs e)
    {
        try
        {
            videoAndMusicContent.Visible = true;
            txtLinkPath.Text = txtLinkPath.Text.Replace("watch?v=", "v/");
            ltrVideoAndMusic.Text = "<object width='300' height='300'>             <param name='movie' value='" + txtLinkPath.Text + "'>             </param><param name='allowFullScreen' value='true'>             </param><param name='allowscriptaccess' value='always'>             </param><embed src='" + txtLinkPath.Text + "' type='application/x-shockwave-flash' allowscriptaccess='always'             allowfullscreen='true' width='425' height='344'>             </embed>         </object>";
            hdnUploadedContent.Value = txtLinkPath.Text;
        }
        catch (Exception)
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "Msg Box", "alert('Its not a Proper video or Media File')", true);
        }
    }

No comments:

Post a Comment