+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Video player in custom control

Video player in custom control

6 posts, 1 answered
  1. Bill
    Bill avatar
    31 posts
    Registered:
    08 Apr 2013
    03 Jul 2013
    Link to this post
    Hello All,

       I am very new to sitefinity and have been tasked with creating a custom control in Visual Studio 2010 for use on a sitefinity implementation.  One of the requirements is that the custom control play a video.  Can anyone tell me how I can add the media player from sitefinity to the ascx file of my custom control and play a movie that is part of the data module I have created for the site?  Sample code would be much appreciated.

    Thanks very much,
    Bill
  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    04 Jul 2013 in reply to Bill
    Link to this post
    Hi Bill,

    It really depends on what kind of media you want to playback?
    I think that if you could implement like a HTML5 player, you should go for that. For example you could use the JWPlayer or JPlayer. Depending on how you set up your data module, you could use the Sitefinity API to get the right media files and link them to one of these players.

     If you need the Silverlight player from Sitefinity, you can just add it inside a UserControl and bind it from e.g. code-behind.

    VideoPlayer.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VideoPlayer.ascx.cs" Inherits="SitefinityWebApp.Widget.Videos.VideoPlayer" %>
    <%@ Register Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI.Videos" TagPrefix="sf" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sitefinity" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>
      
    <sitefinity:ResourceLinks id="resourcesLinks" runat="server">
        <sitefinity:ResourceFile Name="Telerik.Sitefinity.Resources.Scripts.Silverlight.js" Static="true" />
    </sitefinity:ResourceLinks>
     
    <sf:MediaPlayerControl ID="mediaPlayer" runat="server"></sf:MediaPlayerControl>

    VideoPlayer.ascx.cs
    using System;
    using System.Linq;
    using SitefinityWebApp.Base;
    using Telerik.Sitefinity.Modules.Libraries;
     
    namespace SitefinityWebApp.Widget.Videos {
         
    public partial class VideoPlayer : WidgetBaseClass {
     
            protected override void OnPreRender(EventArgs e) {
     
                Telerik.Sitefinity.Web.RouteHelper.SetUrlParametersResolved(true);
                base.OnPreRender(e);
     
                // Get route data
                var urlParameterString = System.Web.UI.ControlExtensions.GetUrlParameterString(this, true).Substring(1);
                if (urlParameterString == "undefined")
                    return;
     
                var video = LibrariesManager.GetManager().GetVideos().FirstOrDefault(x => x.UrlName == urlParameterString);
                if (video != null) {
                    mediaPlayer.MediaContentId = video.Id;
                    mediaPlayer.MediaUrl = video.MediaUrl;
                    mediaPlayer.AutoPlay = true;
                }
     
                Page.Title = video.Title;
            }
        }
    }


    Hope this helps?

    Kind regards,
    Daniel

    * If this post answered your question, please mark it as resolved *
  3. Bill
    Bill avatar
    31 posts
    Registered:
    08 Apr 2013
    08 Jul 2013
    Link to this post
    Daniel,

       Thanks for the reply.  I am tearing my hair out here.  I have no idea what I am doing wrong as I have almost no experience with SiteFinity.  How can I post my code so that you could look at it and tell me where I am messing up?

    Thanks,
    Bill

  4. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    08 Jul 2013 in reply to Bill
    Link to this post
    Hey Bill,

    You can put in inside a post to this thread, or just mail me at: daniel (at) damar dot nl.
    Either way is fine.

    Kind regards,
    Daniel
  5. Bill
    Bill avatar
    31 posts
    Registered:
    08 Apr 2013
    08 Jul 2013
    Link to this post
    Daniel,
       Thank you.  I just got the video to display in the MediaPlayerControl about 45  minutes ago.  My only remaining issue at this point.
    1:  Hide the slider on the MediaPlayerControl so that the users can not fast forward through the video.
    2: Trap and respond in my code behind to an event that should be fired when the playback of the video is completed.
    I am doing the code behind in VB.

    Any help would be greatly appreciated.

    Thanks again
  6. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    11 Jul 2013
    Link to this post
    Hello Bill,

    In order to help you you could open a support ticket, send us your control and some detailed information about it.

    Thank you Danie for sharing your solutions.

    Regards,
    Stefani Tacheva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
6 posts, 1 answered