7.0 Module Builder and RadMediaPlayer

Posted by Community Admin on 04-Aug-2018 14:55

7.0 Module Builder and RadMediaPlayer

All Replies

Posted by Community Admin on 05-May-2014 00:00

Since the SF 7.0 video widget seems to be able only to display one video type I created a module with module builder where the user can administrate videos. 

For each video he can choose 3 pathes to videos (mp4, webm, ogg)

Phase 1
Display one selected video with RadMediaPlayer

   <telerik:RadMediaPlayer ID="RadMediaPlayer1" runat="server" ResolvedRenderMode="Classic" AutoPlay="True" Height="353px" Width="790px">
    <Sources>
        <telerik:MediaPlayerSource IsHD="False" MimeType="video/mp4" Path="~/from_module.mp4" />
        <telerik:MediaPlayerSource IsHD="False" MimeType="video/webm" Path="~/from_module.webm" />
        <telerik:MediaPlayerSource IsHD="False" MimeType="video/ogg" Path="~/from_module.ogv" />
    </Sources>
<PlaylistSettings Mode="Scrollbar" ButtonsTrigger="Hover"></PlaylistSettings>
</telerik:RadMediaPlayer>

Phase 2
Random picking a video

 --------

Anyone has the right link to the API so that I can use the videos that are spit out. Like in images it would be such a help if one simply could get the URL to be used.

 

Markus

<div class="sfitemDetails sfdetails" data-sf-provider='<%# Eval("Provider.Name")%>' data-sf-id='<%# Eval("Id")%>' data-sf-type="Telerik.Sitefinity.DynamicModules.Model.DynamicContent">
           <sf:MediaPlayerControl runat="server" Title="Video MP4" UrlKeyPrefix=""  ProviderName="OpenAccessDataProvider" >
             <RelatedDataDefinition RelatedFieldName="MP4" RelatedItemType="Telerik.Sitefinity.DynamicTypes.Model.VideoverwaltungHomepage.Video" RelationTypeToDisplay="Child" RelatedItemSource="DataItemContainer">
             </RelatedDataDefinition>
         </sf:MediaPlayerControl>
        <sf:MediaPlayerControl runat="server" Title="Video WebM" UrlKeyPrefix=""  ProviderName="OpenAccessDataProvider" >
             <RelatedDataDefinition RelatedFieldName="WebM" RelatedItemType="Telerik.Sitefinity.DynamicTypes.Model.VideoverwaltungHomepage.Video" RelationTypeToDisplay="Child" RelatedItemSource="DataItemContainer">
             </RelatedDataDefinition>
         </sf:MediaPlayerControl>
        <sf:MediaPlayerControl runat="server" Title="Video OGV" UrlKeyPrefix=""  ProviderName="OpenAccessDataProvider" >
             <RelatedDataDefinition RelatedFieldName="OGV" RelatedItemType="Telerik.Sitefinity.DynamicTypes.Model.VideoverwaltungHomepage.Video" RelationTypeToDisplay="Child" RelatedItemSource="DataItemContainer">
             </RelatedDataDefinition>
         </sf:MediaPlayerControl>
         
     </div>

Posted by Community Admin on 07-May-2014 00:00

Hi Markus,

Here in the documentation you can find similar approach explained with code snipped related to the Media field. You can use the same approach in your case.

Follow the “1. Eval Method with Related Media Items” article.

It is shown how to retrieve the MediaUrl for each of the related items.

Regards,
Georgi Georgiev
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 07-May-2014 00:00

Thanks Georgi

 I have a look at it.

Markus

Posted by Community Admin on 08-May-2014 00:00

Dear Georgi

 I decided to create my own. ascx instead of using the widge and build my player by code.

Can you tell me,/help me  how to get the ULR of the Related Media (Video) of the MP4 Field?
I could not understand/find the way to go in the provided link.

 Markus

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.Utilities.TypeConverters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.DynamicTypes;
using Telerik.Sitefinity.RecurrentRules;
using Telerik.Sitefinity.Libraries.Model;
using Telerik.Sitefinity.Utilities.TypeConverters;
 
namespace SitefinityWebApp.UserControls
    public partial class videos : System.Web.UI.UserControl
    
        protected void Page_Load(object sender, EventArgs e)
        
            
            // Fetch a collection of "live" and "visible" video items.
            var myCollection = GetDataItems();
 
         // ************************************************************
         // I need the URL of the Related Media (Video) in Field "MP4"
         // *************************************************************
 
            foreach (Telerik.Sitefinity.DynamicModules.Model.DynamicContent videoType in myCollection)
            
                //MP4 is a Related Media Field Type Video -> need to get the ULR of that video to build my HTML5 video player
                Literal1.Text += videoType.GetValue("VideoTitel") +  " / " + videoType.GetValue("MP4").ToString() + "<br /><br />";
            
 
            //here I will build my player
            BuildPlayer();
            
        
 
        // Gets a collection of "live" and "visible" video items.
        public IQueryable<Telerik.Sitefinity.DynamicModules.Model.DynamicContent> GetDataItems()
        
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type videoType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.VideoverwaltungHomepage.Video");
 
            // Fetch a collection of "live" and "visible" video items.
            var myCollection = dynamicModuleManager.GetDataItems(videoType)
                .Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);
 
            return myCollection;
        
 
  
 
        public RadMediaPlayer player;
        private void BuildPlayer()
        
            var myCollection = GetDataItems();
 
            player = new RadMediaPlayer()
               
                   ID = "RadMediaPlayer1",
                   EnableViewState = false,
                   Height = Unit.Pixel(353),
                   Width = Unit.Pixel(790),
                   AutoPlay = true,
                   FullScreen = false
                    
               ;
 
            player.Load += (s, a) =>
            
                player.TitleBar.ShareButton.Visible = false;
                player.ToolBar.HDButton.Visible = false;
                player.ToolBar.Visible = false;
                player.TitleBar.Visible = false;
                player.PlaylistSettings.Mode = MediaPlayerPlaylistMode.Buttons;
                player.PlaylistSettings.Position = MediaPlayerPlaylistPosition.VerticalInside;
 
            ;
          
             
 
            MediaPlayerVideoFile file;
            for (int i = 0; i < 15; i++)
            
                file = new MediaPlayerVideoFile()
                
                    //Poster = string.Format("~/VideoPosters/poster0.jpg",),
                    //Title = string.Format("Title 0 for video 1", videoID, i, videoID)
                ;
                 
                player.Playlist.Add(file);
            
 
            PlaceHolder1.Controls.Add(player);
        
 
    

Posted by Community Admin on 08-May-2014 00:00

This did the trick

 videoType.GetRelatedItems<MediaContent>("MP4").First().MediaUrl.ToString();

Thank's to Steve

Markus

This thread is closed