Changing MediaPlayerControl MediaContentID
Hello,
I'm writing a control that provides a video to the user as well as displaying related videos. I'm using the MediaPlayerControl class to display the videos, but I've encountered an issue: If I try to change this object's MediaContentID property in a postback, the MediaPlayerControl will no longer render. I've tried creating the class in the codebehind and the display file, and there doesn't seem to be a difference. I've also made sure that ViewState is enabled as well as the RadScriptManager (and tried turning them both off). I've discovered that a line of JavaScript is emitted on normal page load but does not seem to be on postback, and I think this is the culprit:
Sys.Application.add_init(
function
()
$create(Telerik.Sitefinity.Modules.Libraries.Web.UI.Videos.MediaPlayerControl,
"_domain"
:
"http://localhost:62643"
,
"_silverlightSkin"
:
null
,
"_silverlightUrl"
:
"/ClientBin/Telerik.Sitefinity.Silverlight.xap"
,
"autoPlay"
:
false
,
"description"
:
null
,
"height"
:
""
,
"playerContainer"
:$get(
"C002_mpcVideo_ctl00_ctl00_silverlightContainer"
),
"title"
:
null
,
"url"
:
"/videos/default-video-library/tax-conformity-in-ohio.wmv"
,
"width"
:
""
,
null
,
null
, $get(
"C002_mpcVideo"
));
);
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="VideoBox.ascx.cs" Inherits="OSCPA.Web.UI.VideoBox" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sfv" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI.Videos" Assembly="Telerik.Sitefinity" %>
<
sfv:MediaPlayerControl
ID
=
"mpcVideo"
runat
=
"server"
AutoPlay
=
"false"
SetSilverlightContainerVisibility
=
"true"
Visible
=
"true"
/>
public
partial
class
VideoBox : BaseUserControlAdvanced
public
string
MediaContentID
get
;
set
;
public
VideoBox()
this
.MediaContentID =
"88d77237-7bd6-4d7c-baaf-a4a3656907d9"
;
protected
void
Page_Init(
object
sender, EventArgs e)
if
(!
string
.IsNullOrEmpty(Request.QueryString[
"NextVideo"
]))
this
.MediaContentID = Request.QueryString[
"NextVideo"
];
protected
void
Page_Load(
object
sender, EventArgs e)
pcVideo.MediaContentId =
new
Guid(
this
.MediaContentID);
mpcVideo.MediaUrl = ((Video)App.WorkWith().Video().GetManager().GetItem(
typeof
(Video), mpcVideo.MediaContentId)).MediaUrl;
Hi Jacob,
Can you also pass the media URL to the video control? The media player control is designed to work with the URL directly.
All the best,
Radoslav Georgiev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Yes, I can change the URL as well, but this also has no effect. I have tried changing only the URL, only the GUID, and both. Additionally, if the control is instantiated with a URL but no GUID, it will not load a video.
Hello Jacob,
The video URL for the media player is passed to the Silverlight media player in the GetScriptDescriptors method of the class, this executes after OnPrerender method. You can create a class which inherits from MediaPlayerControl and override OnPreRender method. From there on you can check if the MediaUrl property is correctly set and passed to the control.
All the best,
Radoslav Georgiev
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>