我正在尝试使用ionic 4创建一个应用程序,该应用程序基本上只是从远程服务器流式传输音频源。一切正常,但尽管我在StreamAudioOptions中使用bgImage,但仍然出现黑屏。我的bg图片位于src / assets / bg.png
我尝试了以下对图像的引用:
/assets/bg.png
assets/bg.png
./assets/bg.png
../../assets/bg.png
这是我的代码:
import { StreamingMedia, StreamingAudioOptions } from '@ionic-native/streaming-media/ngx/';
playAudio() {
this.platform.ready().then(() => {
if (this.platform.is("cordova"))
{
let options : StreamingAudioOptions = {
bgImage: "/assets/bg.png",
bgColor: "#fff",
bgImageScale: "stretch",
successCallback: () =>
{
console.log("Successfully played audio");
},
errorCallback: (e) =>
{
console.log(e);
}
};
this.streaming.playAudio(this.mp3.url, options);
}
else
{
console.log("Must be on a mobile device to play!");
}
});
}
感谢您的帮助。谢谢!
答案 0 :(得分:0)
我通过将引用设置为“ www / assets / bg.png”来修复了该问题;
static void Main(string[] args)
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Console.WriteLine($"Current Environment : {(string.IsNullOrEmpty(environment) ? "Development" : environment)}");
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
var builder = new HostBuilder();
builder.UseEnvironment("Development");
builder.ConfigureLogging((context, b) =>
{
b.AddConsole();
});
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddAzureStorage();
// b.AddTimers();
b.AddServiceBus(c =>
{
c.ConnectionString = "[Your Connection String]";
});
}).ConfigureServices((context, services)=>
{
services.AddSingleton<INameResolver>(new QueueNameResolver(config));
});
var host = builder.Build();
using (host)
{
host.Run();
}
}
public class QueueNameResolver : INameResolver
{
private readonly IConfiguration _configuration;
public QueueNameResolver(IConfiguration configuration)
{
_configuration = configuration;
}
public string Resolve(string name)
{
return _configuration[$"AppSettings:{name}"];
}
}