我一直在研究,但没有找到任何关于如何在Android应用上播放Azure Media Services音频流的教程?
我已经完成了那些教程 http://azure.microsoft.com/en-us/documentation/articles/media-services-dotnet-get-started/ http://code.msdn.microsoft.com/Windows-Azure-Media-040435f8
但是他们下载资产而不是流式传输。
似乎有一种名为PlayReady,但我需要许可它! http://www.microsoft.com/playready/features/ClientOptions.aspx
任何人都可以指导我使用任何代码/教程或从哪里开始,以便我可以播放在Azure媒体服务上上传的音频流吗?
我是否有可能从我上传的音频文件中获取azure媒体服务的流媒体网址,然后我会在Android上使用MediaPlayer API正常播放?
答案 0 :(得分:2)
您可以使用AMS REST API或SDK for .NET上传MP3文件。
然后,您可以通过使用Azure Media Encoder编码并使用AAC Good Quality Audio预设来生成MP4文件。
确保添加至少一个按需流媒体广告单元。
以下示例使用SDK for .NET Extensions。
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.MediaServices.Client;
using System.Threading;
namespace AudioTest
{
class Program
{
// Read values from the App.config file.
private static readonly string _mediaServicesAccountName =
ConfigurationManager.AppSettings["MediaServicesAccountName"];
private static readonly string _mediaServicesAccountKey =
ConfigurationManager.AppSettings["MediaServicesAccountKey"];
// Field for service context.
private static CloudMediaContext _context = null;
private static MediaServicesCredentials _cachedCredentials = null;
static void Main(string[] args)
{
// Create and cache the Media Services credentials in a static class variable.
_cachedCredentials = new MediaServicesCredentials(
_mediaServicesAccountName,
_mediaServicesAccountKey);
// Used the cached credentials to create CloudMediaContext.
_context = new CloudMediaContext(_cachedCredentials);
// 1. Create a new asset by uploading a mezzanine file from a local path.
IAsset inputAsset = _context.Assets.CreateFromFile(
@"testrecording.wma",
AssetCreationOptions.None,
(af, p) =>
{
Console.WriteLine("Uploading '{0}' - Progress: {1:0.##}%", af.Name, p.Progress);
});
IJob job = _context.Jobs.CreateWithSingleTask(
MediaProcessorNames.AzureMediaEncoder,
MediaEncoderTaskPresetStrings.AACGoodQualityAudio,
inputAsset,
"AACGoodQualityAudio",
AssetCreationOptions.None);
Console.WriteLine("Submitting transcoding job...");
// 3. Submit the job and wait until it is completed.
job.Submit();
job = job.StartExecutionProgressTask(
j =>
{
Console.WriteLine("Job state: {0}", j.State);
Console.WriteLine("Job progress: {0:0.##}%", j.GetOverallProgress());
},
CancellationToken.None).Result;
Console.WriteLine("Transcoding job finished.");
IAsset outputAsset = job.OutputMediaAssets[0];
Console.WriteLine("Publishing output asset...");
// 4. Publish the output asset by creating an Origin locator for adaptive streaming.
_context.Locators.Create(
LocatorType.OnDemandOrigin,
outputAsset,
AccessPermissions.Read,
TimeSpan.FromDays(30));
Uri hlsUri = outputAsset.GetHlsUri();
Uri mpegDashUri = outputAsset.GetMpegDashUri();
// 6. Get the asset URLs.
// Test HLS with Safari and Chrome on iOS.
Console.WriteLine(hlsUri);
// Test MPEG DASH with http://dashif.org/reference/players/javascript/
Console.WriteLine(mpegDashUri);
}
}
}

谢谢,
朱莉娅
答案 1 :(得分:0)
Azure媒体服务旨在处理和提供流式视频,并且不支持纯音频媒体。
您可能需要检查新的Azure CDN产品是否提供流畅的流式传输。
否则,真正实现此功能的唯一方法是设置可能在Azure VM上运行的适当流媒体服务器,因为网站和Web角色PaaS产品不具备烘焙流媒体功能。
如果您需要公共云解决方案,如果不这样做,您可能会查看AWS CloudFront Streaming产品。