Play video in SharePoint site using jQuery

This is an article about embedding video inside the SharePoint site and play it. If a user needs to fetch video file from the SharePoint library and display in page daily based on the video uploaded and approved by an admin user. In this case, the admin user will approve a video file to display on the home page.

Create a SharePoint document library and upload a video file. Then log in as admin user and approve the video file.

In home page place video tag in div wherever you want to display.

<p>Video Demo</p>
<embed type="video/x-ms-wmv" loop="0" autostart="0" style="width: 400px; height: 240px;"></embed>

Place content editor web part inside SharePoint page (or) open the page in SharePoint designer and copy the below code:

<script src="/Shared%20Documents/jquery-1.11.0.js" type="text/javascript"></script>
<script src="/Shared%20Documents/jquery.SPServices-2013.02a.js" type="text/javascript">
</script><script type="text/javascript">
$(document).ready(function () {
$().SPServices({
operation: "GetListItems",
async: false,
webURL: "http://md-abhishekb/pawsubsite1/",
listName: "Videos",

CAMLQuery: "<Query><Where><Eq><FieldRef Name=’Approved’ /><Value Type=’Text’>1</Value></Eq></Where></Query>",
CAMLViewFields: "<ViewFields> <FieldRef Name=’EncodedAbsUrl’/></ViewFields>",
CAMLRowLimit: 1,

completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
$("embed").attr("src",url);
});
}
});
});</script>

Refer site URL and list name in the above code and then download jquery plugins from the below URL.

  • http://spservices.codeplex.com/releases/view/116626
  • http://code.jquery.com/jquery-1.11.0.min.js

Check the video is displayed on the page.

You may like following SharePoint jQuery tutorials:

This SharePoint tutorial, we learned how to play video in SharePoint site using jQuery.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

jayabharathi

The turning point in the process of growing up is when you discover the core of strength within you that survives all hurt.

>