Video player in custom control

Posted by Community Admin on 04-Aug-2018 13:04

Video player in custom control

All Replies

Posted by Community Admin on 03-Jul-2013 00:00

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

Posted by Community Admin on 04-Jul-2013 00:00

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 *

Posted by Community Admin on 08-Jul-2013 00:00

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

Posted by Community Admin on 08-Jul-2013 00:00

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

Posted by Community Admin on 08-Jul-2013 00:00

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

Posted by Community Admin on 11-Jul-2013 00:00

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

This thread is closed