我们的Ionic 3应用中的MP3现场音频流可与// auth token from cortana's connected service stored as Entity object of type 'authorization' with child property 'token' holding the actual value
var token = activity.Entities.Single(e => e.Type == @"authorization").Properties.Value<string>(@"token");
using (var client = new HttpClient())
{
// The token can be used to query the Graph, but only because we know that it is from MS Identity. We couldn't query the Graph like this if we were using our own Identity provider (eg: Contoso Identity)
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(@"Bearer", token);
try
{
var response = await client.GetAsync(@"https://graph.microsoft.com/v1.0/me").ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
var resultString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
/* Response from /me looks like:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"givenName": "Brandon",
"surname": "H",
"displayName": "Brandon H",
"id": "<unique user id!>",
"userPrincipalName": "<E-MAIL ADDRESS!!>",
"businessPhones": [],
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null
}
*/
}
}
catch { }
}
一起正常使用,但在设备上运行它会在Android上提供ionic serve
,在iOS上提供net::ERR_CONNECTION_REFUSED
。
我的播放器服务:
NSURLConnection finished with error - code -1100
使用指向MP3文件的网址(例如https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3)替换实时流网址。可能这个问题与没有长度的直播流有关,但我无法弄清楚如何解决这个问题。
答案 0 :(得分:1)
我强烈建议您在此处使用Native Streaming Media Plugin。由于某些Web解决方案在本机设备上无法正常工作。
此插件允许您以全屏方式流式传输音频和视频, iOS和Android上的原生播放器。
ionic cordova plugin add cordova-plugin-streaming-media
npm install --save @ionic-native/streaming-media