Ionic 4:bgImage没有出现在StreamingAudioOptions上

问题描述 投票:0回答:1

我正在尝试使用离子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!");
      }
  });
}

任何帮助表示赞赏。谢谢!

ionic-framework ionic4 ionic-native
1个回答
0
投票

我把它修改为“www / 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: "www/assets/bg.png",
          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!");
      }
  });
}
© www.soinside.com 2019 - 2024. All rights reserved.