In this post, you will learn how to retrieve the video portal information, video channels and videos of respective channel from the Office 365 sites using REST Video APIs (Newly introduced for Video Portal).
Microsoft has introduced new APIs for working with video portal. The hierarchy of information storage will be,
- Video portal is present in an Office 365 instance.
- Video Portal consists of channels.
- Channels in turn consist of many videos.
Retrieve Video Portal Details:
First we will see how we can retrieve video portal URL of the Office 365 site using REST Video API.
The API used to get the video portal information will be “https://siteurl/_api/VideoService.Discover”. The properties which can be accessed from this operation are, Video Site Page URL, Channel Template URL, Player template URL and Video Site URL.
The following code snippet shows the JQuery Ajax call to get the video portal information from the Office 365 site.
On the Video portal, you can start creating channels. The channels are used to categorize the videos. Creating channel literally means you are going to create site collections.
To get the channels from the video portal, the video portal URL should be used with REST Video API to pull the information. The REST API URL will be https://videositeurl/_api/VideoService/Channels. Here video site URL is the component which we have identified in the above section.
Next, we will see how we can retrieve information about particular channel. Identify the channel and get the channel id manually or by using the previous operation. The operation will be very similar to the above one. Only difference is Channel id is passed to get the particular channel information.
The following code snippet shows the JQuery Ajax call to get the channel details from the Office 365 Video portal.
Retrieve Videos from Channels:
Now we will see how we can retrieve videos from a particular channel using REST Video API. With the video portal URL and channel ID identified in the above sections, get the channel videos using below API.
The operation will fetch us all the videos from the channel. Using for each, loop through the result set to get the details of each video. The properties which can be viewed are File name, video url, Author details, video download URL, view count, thumbnail url, duration, video uploaded date and channel details. The following code snippet shows the operation in detail.
Now we will see how we can retrieve particular video detail. This is again similar to the above operation. Once you identify the video id, you can pass it using query to SharePoint along with channel id to get more information about single video. The same set of properties will be retrieved here. The REST Video API will be,
The following code snippet shows the JQuery Ajax call to get the video details of a channel from the Office 365 Video portal.