Azure Media Services – Office 365
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 organization to publish their corporate videos and share with their employees. More interestingly, its 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 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 codes does not cover usage of Office 365 Video REST API, which is in preview. So I thought to share 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
- Login to Office 365 Portal ( use admin privileges if you need to configure or create channel for video)
- Navigate to the video portal and upload videos into your channel or to default community channel.
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.
For streaming an encrypted video from Office 365(Azure Media Services) to our client application, we require 2 stuffs – 1. Video playback URL 2. 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)
- On the POSTMAN app , paste URL in the below format for GET the video playback URL
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 use HLS use “0” , so that it will require extra access token to decrypt
Result will look like this
2. For getting the decryption access token, again do a GET request in the below format
The token request URL for my video is like below
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 -(UPDATE : accesstoken is expired now, if any viewers need to see it functioning Kindly do the request so can update the token.)
<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 is scrambled because of security concerns.
Hope you enjoyed the post, Feel free to ask your queries.