Project Description
Rich Interactive Applications (RIA) built on ASP.NET (2.0/3.5/4.0) platform, utilizing "best of both worlds": embedded YouTube™ and Silverlight™ Media Players. API, written in C# provides plenty of customization features.

Sample Silverlight™ Player screenshot is shown on Fig.1:
SampleScreenshot_SilverlightMediaPlayer.jpg
Fig.1. Silverlight™ Media Player, sample screenshot (for demo purpose only)

Sample YouTube™ Player screenshot is shown on Fig.2:
SampleScreenshot_YouTubeVideoPlayer.jpg
Fig.2. YouTube™ Video Player, sample screenshot (for demo purpose only)

NOTE: SAMPLE MOVIE/CONTENT IS SHOWN FOR INFORMATION/DEMO PURPOSE ONLY! PLEASE DO NOT COPY/DISTRIBUTE

Project contains:

1. Default Web page "Default.aspx" with corresponding code behind: both to be placed in Application root directory (ASP.NET 2.0+)
2. Silverlight Library files to be placed in Bin directory
3. Ajax Library file (AjaxControlToolkit.dll) to be placed in Bin directory
4. YouTube custom API class library file (youTubeEmbeddedPlayer.dll) to be placed in Bin directory
5. Player "Skin" files (xaml) collection, placed in "MediaPlayerSkins" folder

Demo page shows the "best of both worlds": embedded YouTube™ and Silverlight™ players placed side by side.
<%@ Page Language="C#" 
AutoEventWireup="true"  
CodeFile="Default.aspx.cs" 
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ Register Assembly="System.Web.Silverlight" 
    Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

<%@ Register assembly="AjaxControlToolkit" 
namespace="AjaxControlToolkit" 
tagprefix="cc1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>ASP.NET RIA DEMO | YouTube and Silverlight</title>
    </head>
    <body>
        <!-- ALL CONTENT IS SHOWN FOR DEMO PURPOSE ONLY-->
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />

            <!--SILVERLIGHT MEDIA PLAYER-->
            <div style="float:left; width:45%; height: 500px;
            border:solid 1px maroon; padding:2%; background-color:#dadada">
                <strong>SILVERLIGHT™ MEDIA PLAYER</strong><hr />
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="Conditional" >
               <ContentTemplate> 

                    <asp:DropDownList ID="cmbSkins" runat="server" 
                    onselectedindexchanged="cmbSkins_SelectedIndexChanged" />
                    SELECT STYLE<hr />

                    <asp:MediaPlayer ID="MediaPlayer1" runat="server" /> 
                </ContentTemplate>
                </asp:UpdatePanel>

               <h4> 
               Sample Demo running on Silverlight™ Media Player: 
               video response to "What's your name" by Boston. 
               Please do not copy/distribute!
               </h4>
            </div>
            
            <!--YOUTUBE PLAYER-->
            <div style="float:right; width:45%; height: 500px;
            border: solid 1px maroon; padding:2%; background-color:#dadada">
            <strong>YOUTUBE™ VIDEO PLAYER</strong><hr />
                <asp:UpdatePanel ID="UpdatePanel2" runat="server" updatemode="Conditional" >
                <ContentTemplate> 
                <div>
                    <asp:DropDownList ID="cmbPlaylist" runat="server" AutoPostBack="True">
                        <asp:ListItem Value="x_4CNvG1Q_M">
                        Anastasia Volochkova dancing (Adiemus)
                        </asp:ListItem>
                        
                        <asp:ListItem Value="raRaxt_KM9Q">
                        Sound Of Silence (Masters of Chant)
                        </asp:ListItem>
                        
                        <asp:ListItem Value="8qSeYLhe09s">
                        For Whom The Bell Tolls (Bee Gees)
                        </asp:ListItem>
                    </asp:DropDownList>
                    SELECT SOURCE<hr />
                    <asp:Literal ID="Literal1" runat="server"></asp:Literal>
                </div>
                </ContentTemplate>
                </asp:UpdatePanel>
                <h4>Sample Demo running on YouTube™ Media Player: 
                Anastasia Volochkova, Russian prima ballerina is dancing to "Adiemus"</h4>
            </div>
        </form>
        <br />
        More Demo available at:
        <a href="http://www.webinfocentral.com/Resources/Resources.aspx" target ="blank">
        www.webinfocentral.com</a>
    </body>
</html>

Code behind page:

//******************************************************************************
// Module           :   Default.aspx.cs
// Description      :   code behind
//******************************************************************************
// Author           :   Alexander Bell
// Copyright        :   2009 Infosoft International Inc.
// DateCreated      :   07/03/2009
// LastModified     :   10/12/2009
//******************************************************************************
// DISCLAIMER: This Application is provide on AS IS basis without any warranty
//******************************************************************************

//******************************************************************************
// TERMS OF USE     :   This module is copyrighted.
//                  :   You can use it at your sole risk provided that you keep
//                  :   the original copyright note. 
//NOTE: ALL .WMV/.JPG FILES ARE FOR DEMO PURPOSE ONLY: DO NOT COPY/DISTRIBUTE!
//******************************************************************************
using System;

public partial class _Default : System.Web.UI.Page
{

    #region Silverlight Media Player styles (skins)
    protected enum MediaPlayerSkins
    {
        AudioGray,
        Basic,
        Classic,
        Console,
        Expression,
        Futuristic,
        Professional,
        Simple
    }
    #endregion

    #region Silverlight Media Source
    private const string _domain = @"http://www.webinfocentral.com/";
    // NOTE: FOR DEMO PURPOSE ONLY: DO NOT COPY/DISTRIBUTE!
    private string _source = _domain + "VIDEO/JJ2008/WMV/JJ2008_100.wmv";
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        #region YouTube settings
        // player width
        int _W = 560;
        // player height
        int _H = 380;
        // autoplay disabled
        bool auto = false;
        #endregion
        
        if (!IsPostBack)
        {
            #region YouTube start mode customization via Web Query String
            int idx = 0;
            string qry = "";

            // Web Query to set autoplay option
            try
            {
                qry = "auto";
                qry = (Request.QueryString[qry] == null) ? "" : Request.QueryString[qry];
                if (qry != "") { auto = Boolean.Parse(qry); }
            }
            catch { }

            // Web Query to set item index
            try
            {
                qry = "item";
                qry = (Request.QueryString[qry] == null) ? "" : Request.QueryString[qry];
                if (qry != "") { idx = int.Parse(qry); }
            }
            catch { }

            // set selected index
            cmbPlaylist.SelectedIndex = idx;

            #endregion

            #region Silverlight Media Player initial settings
            MediaPlayer1.AutoPlay = true;
            MediaPlayer1.ScaleMode = System.Web.UI.SilverlightControls.ScaleMode.Stretch;
            MediaPlayer1.MediaSource = _source;
            MediaPlayer1.PlaceholderSource=_domain + @"VIDEO/JJ2008/ImgMain.JPG";
            MediaPlayer1.Width=560;
            MediaPlayer1.Height = 380;
            #endregion

            #region Adding Chapters to Silverlight Media Player

            System.Web.UI.SilverlightControls.MediaChapter mc =
            new System.Web.UI.SilverlightControls.MediaChapter();

            mc.Position = 18;
            mc.ThumbnailSource = 
            @"http://www.webinfocentral.com/VIDEO/JJ2008/ImgChapters/13P1010042.JPG";
            mc.Title = "Chapter1";
            MediaPlayer1.Chapters.Add(mc);
            mc = null;

            mc = new System.Web.UI.SilverlightControls.MediaChapter();
            mc.Position = 37;
            mc.ThumbnailSource = 
            @"http://www.webinfocentral.com/VIDEO/JJ2008/ImgChapters/18P1010048.JPG";
            mc.Title = "Chapter2";
            MediaPlayer1.Chapters.Add(mc);
            mc = null;

            mc = new System.Web.UI.SilverlightControls.MediaChapter();
            mc.Position = 70;
            mc.ThumbnailSource = 
            @"http://www.webinfocentral.com/VIDEO/JJ2008/ImgChapters/11P1010036.JPG";
            mc.Title = "Chapter3";
            MediaPlayer1.Chapters.Add(mc);
            mc = null;

            mc = new System.Web.UI.SilverlightControls.MediaChapter();
            mc.Position = 107;
            mc.ThumbnailSource = 
            @"http://www.webinfocentral.com//VIDEO/JJ2008/ImgChapters/08P1010026.JPG";
            mc.Title = "Chapter4";
            MediaPlayer1.Chapters.Add(mc);
            mc = null;

            mc = new System.Web.UI.SilverlightControls.MediaChapter();
            mc.Position = 134;
            mc.ThumbnailSource = 
            @"http://www.webinfocentral.com/VIDEO/JJ2008/ImgChapters/06P1010010.JPG";
            mc.Title = "Chapter5";
            MediaPlayer1.Chapters.Add(mc);
            mc = null;
            #endregion

            #region Silverlight Player style selector
            // populate dropdown with Media Player styles (skin): looping through enum
            foreach (MediaPlayerSkins skin in Enum.GetValues(typeof(MediaPlayerSkins)))
            { cmbSkins.Items.Add(skin.ToString()); }

            // set dropdown autopostback
            cmbSkins.AutoPostBack = true;

            // select Professional style
            cmbSkins.SelectedValue = MediaPlayerSkins.Professional.ToString(); 
            
            MediaPlayer1.MediaSkinSource =
            "~/MediaPlayerSkins/" + cmbSkins.SelectedValue + ".xaml";
            #endregion
        }

        // generate Silverlight script on page postback
        Literal1.Text = YouTubeScript.Get(cmbPlaylist.SelectedValue, auto, _W, _H);
    }

    #region User Events
    ///<summary>Select Media Player Skin</summary>
    protected void cmbSkins_SelectedIndexChanged(object sender, EventArgs e)
    {
        MediaPlayer1.MediaSkinSource =
            "~/MediaPlayerSkins/" + cmbSkins.SelectedValue + ".xaml";
    }
    #endregion
}
Related RIA CodePlex Projects by Author:

 

RIA Silverlight™ SilverLight Silverlight Player Silverlight Media Player YouTube™ YouTube YouTube API Video Player ASP.NET C# AJAX

Last edited Aug 20, 2015 at 2:54 PM by DrABELL, version 21