How to: Deliver Apple HLS streaming content
This article is one in a series introducing Windows Azure Media Services programming. The previous topic was How to: Deliver Streaming Content.
This topic shows how to create a locator to Apple HTTP Live Streaming (HLS) content on a Media Services origin server. Using this approach, you can build a URL to Apple HLS content, and provide it to Apple iOS devices for playback. The basic approach to building the locator URL is the same. Build a locator to the Apple HLS streaming asset path on an origin server, and then build a full URL that links to the manifest for the streaming content.
The following code example assumes that you have already obtained a reference to an HLS streaming asset, and the variable named assetToStream is referenced in the code. After you have run this code to generate an origin locator on the asset, you can use the resulting URL to play back the streaming content in an iOS device such as an iPad or an iPhone.
To build a locator to Apple HLS streaming content:
- Get a reference to the manifest file in the asset
- Define an access policy
- Create the origin locator by calling the CreateLocator
- Build a URL to the manifest file
The following code shows how to implement the steps:
static ILocator GetStreamingHLSOriginLocator( string targetAssetID)
// Get a reference to the asset you want to stream.
IAsset assetToStream = GetAsset(targetAssetID);
// Get a reference to the HLS streaming manifest file from the
// collection of files in the asset.
var theManifest =
from f in assetToStream.AssetFiles
// Cast the reference to a true IAssetFile type.
IAssetFile manifestFile = theManifest.First();
IAccessPolicy policy = null;
ILocator originLocator = null;
// Create a 30-day readonly access policy.
policy = _context.AccessPolicies.Create("Streaming HLS Policy",
originLocator = _context.Locators.CreateLocator(LocatorType.OnDemandOrigin, assetToStream,
// Create a URL to the HLS streaming manifest file. Use this for playback
// in Apple iOS streaming clients.
string urlForClientStreaming = originLocator.Path
+ manifestFile.Name + "/manifest(format=m3u8-aapl)";
Console.WriteLine("URL to manifest for client streaming: ");
// Return the locator.
For more information about delivering assets, see:
This topic concludes the Using Windows Azure Media Services topics. We have covered setting up your machine for Media Services development and performing typical programming tasks. For more information about programming Media Services, see the following resources :