The code below uses ECMAScript (JavaScript, JScript) object model to access the media player.
Here are the steps :
1. The first thing to consider is to add a reference to the below script file in your project.
2. Add a media player webpart on your page.
3. The ECMAScript for setting up the properties for the media player webpart are :
//Gets the media player.
function getMediaPlayer()
{
var p = document.getElementById(“
var obj = p.getElementsByTagName(“
return obj[0].Content.MediaPlayer;
}
//Initialize the media player object and set values for its properties. Customize MediaUrlField and PreviewURLField values for your local environment.
function init()
{
var serverStr = window.location.href;
serverStr = serverStr.substr(7);
serverStr = serverStr.substr(0, serverStr.indexOf(“/”));
document.getElementById(“
document.getElementById(“
document.getElementById(“
document.getElementById(“
}
//Set properties of the media player, including media URL, preview image URL, template URL, title, autoplay, whether to repeat, and default display mode.
function SetMediaSource()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.MediaSource = elm.value;
}
function SetPreviewImageSource()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.PreviewImageSource = elm.value;
}
function SetMediaTitle()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.MediaTitle = elm.value;
}
function SetTemplateSource()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.TemplateSource = elm.value;
}
function SetAutoPlay()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.AutoPlay = elm.checked;
}
function SetLoop()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.Loop = elm.checked;
}
function SetDisplayMode()
{
var elm = document.getElementById(“
var p = getMediaPlayer();
p.DisplayMode = elm.value;
}
No comments:
Post a Comment