Click here to Skip to main content
15,886,919 members
Articles / Desktop Programming / MFC

Office 365 Video & Office 365 APIs

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
4 Jun 2015CPOL3 min read 13.4K   2
Office 365 Video & Office 365 APIs

SharePointers & Other O365 Folks,

Recently, MSFT has released its video streaming service for Office 365, that is basically an intranet site for video portal. Just for curiosity, I tried available preview version from my Office 365 and happily created multiple channels and uploaded videos into it. I liked it very much because this can be used in many organizations to publish their corporate videos and share with their employees. More interestingly, it's backed by Azure Media services, so that we can leverage the features like video encryption, HLS (http live streaming) and many more. So after making my hands dirty with configuration of this new thingy, I was excited to extend this service to other client application. For this purpose, MSFT have released a set of APIs which enable developers to manipulate their data from any client applications. Say, Android Apps, IOS Apps & ASP.NET applications, etc. A bunch of sample code is available on MSDN for office 365 API integration with Mail, Files(OneDrive), Contacts, etc .

But as of now, this available sample code does not cover usage of Office 365 Video REST API, which is in preview. So I thought of sharing information about usage of Video REST API. In this post, I am not providing huge blocks of code to explain contrary to what I have done on my previous posts, rather I am using POSTMAN client to show the video REST API functionality.

Initial steps to do:

  1. Login to Office 365 Portal (use admin privileges if you need to configure or create channel for video)
  2. Navigate to the video portal and upload videos into your channel or to default community channel.

Image 1

Image 2

movie

Once the video is uploaded, try to view video from portal so that we can grab the channelID and videoID from the browser URL for the future REST API calls. The below URL highlights the channelID and videoID respectively.

/portals/hub/_layouts/15/PointPublishing.aspx?app=video&p=p&chid=a4dc2759-a618-4bc8-bd94-edd12294c0d7&vid=1d956f3a-e4e0-4eb0-877d-cbb798423abd

For streaming an encrypted video from Office 365(Azure Media Services) to our client application, we require 2 things:

  • Video playback URL
  • Access token for decryption of video

Install and open POSTMAN Client – I prefer CHROME for this because we can utilize chrome app of POSTMAN. (Make sure you open a tab for POSTMAN on the same browser instance of chrome where video portal is open, so that authentication will work without any extra effort).

  1. On the POSTMAN app, paste URL in the below format for GET the video playback URL

    {VideoPortalURL}/_api/VideoService/Channels(‘{channelId}’)/Videos(‘{videoId}’)/GetPlaybackUrl(‘{streamingFormatType}’)

    For my video service, playback video request URL is like below, I have used StreamingFormatType as “1” which is for “MPEG-DASH” format. If you want to use HLS use “0” , so that it will require extra access token to decrypt

    Result will look like this:

    Image 4

  2. For getting the decryption access token, again do a GET request in the below format:
    {VideoPortalURL}/_api/VideoService/Channels(‘{channelId}’)/Videos
    (‘{videoId}’)/GetStreamingKeyAccessToken

    The token request URL for my video is like below:

    https://spsparta.sharepoint.com/portals/hub/_api/VideoService/Channels(‘{a4dc2759-a618-4bc8-bd94-edd12294c0d7}’)/Videos(‘{1d956f3a-e4ea-4eb0-877d-cbb798423abd}’)/GetStreamingKeyToken

    Image 5

    Now we have both PlaybackURL and decryption token to stream the video from Office 365 (Azure media service). I used http://amsplayer.azurewebsites.net/ to test my video streaming or else we can directly use IFRAME (see below) or video tag to stream the video. Click here to open my video in amsplayer.

    HTML
    <iframe src="//aka.ms/azuremediaplayeriframe?url=%2F%2Fcdn
    -cvprhkn01m01.streaming.mediaservices.windows.net%2Ff30630fa-4e1d-40bf-bdc4-fb20fd70e875%2F19074820
    -245b-412e-95d7-96be9693c352.ism%2FManifest&protection=playready&
    token=Bearer%3Durn%253amicrosoft%253aazure%253amediaservices%253acontentkeyidentifier%3D057c9a97-5d2d-4744-
    bfe1-d9bb30737b47%26urn%253amicrosoft%253aazure%253amediaservices%253akeyacquisitionhostname
    %3Dcvprhkn01m01.keydelivery.mediaservices.windows.net%26http%253a%252f%252fschemas.microsoft.com
    %252faccesscontrolservice%252f2010%252f07%252fclaims%252fidentityprovider%3Dhttps%253a%252f
    %252fnimbuslkgglobacs.accesscontrol.windows.net%26urn%253aServiceAccessible%3Dservice%26Audience
    %3Durn%253aNimbus%26ExpiresOn%3D1433202410%26Issuer%3Dhttps%253a%252f%252fnimbuslkgglobacs.
    accesscontrol.windows.net%252f%26HMACSHA256%3D2ji3D8SXf5OORXaZSxIbtpvAQr2h3r%252fGBTz1Nd6Wh1c
    %253d&autoplay=false" name="azuremediaplayer" scrolling="no" 
    frameborder="no" align="center" height="280px" 
    width="500px" allowfullscreen></iframe>

Note: Office 365 Video API is still in preview, so kindly keep in mind that MSFT may change the procedures in future. Also GUIDs & Access tokens used in this post are scrambled because of security concerns.

Hope you enjoyed the post. Feel free to ask your queries.

Image 6 Image 7

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
I am Abin Jaik Antony, working as a Software Developer.My technology background area extends to MOSS 2007,Microsoft BI,.NET Framework etc.
Visit my blog for more details http://www.abinjaik.com

Comments and Discussions

 
QuestionVideo is not playing in Azure Media Player. Pin
Punam Satpute18-Jan-18 21:57
Punam Satpute18-Jan-18 21:57 
QuestionHow to create folder into Portal Office Video via REST or JSOM Pin
Member 1239503715-Mar-16 18:46
Member 1239503715-Mar-16 18:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.