- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我开始使用 Ionic 2 创建一个应用程序,在我尝试添加声音之前,一切进展顺利。我根据 Ionic Framework 指南安装了 NativeAudio 模块,然后添加了这些代码行。
在app.module.ts中
import { NativeAudio } from '@ionic-native/native-audio';
在游戏.ts中
@Component({
selector: 'page-game',
templateUrl: 'game.html',
})
export class GamePage {
...
constructor(public navCtrl: NavController, public alertCtrl: AlertController, public navParams: NavParams, public nativeAudio: NativeAudio) {
this.nativeAudio.preloadSimple('correctMp3', '../../assets/mp3/correct.mp3');
}
}
guessLetter(letterIn) {
this.nativeAudio.play('correctMp3');
}
}
(抱歉提前格式化)。在添加声音之前,代码运行良好,但现在当我尝试加载 GamePage 时,它会抛出此错误。
Runtime Error
Uncaught (in promise): Error: No provider for NativeAudio! Error: No
provider for NativeAudio! at injectionError
(http://localhost:8100/build/vendor.js:1590:86) at noProviderError
(http://localhost:8100/build/vendor.js:1628:12) at
ReflectiveInjector_._throwOrNull (http://localhost:8100/build/vendor.js:3129:19)
at ReflectiveInjector_._getByKeyDefault
(http://localhost:8100/build/vendor.js:3168:25) at ReflectiveInjector_._getByKey
(http://localhost:8100/build/vendor.js:3100:25) at ReflectiveInjector_.get
(http://localhost:8100/build/vendor.js:2969:21) at
AppModuleInjector.NgModuleInjector.get
(http://localhost:8100/build/vendor.js:3937:52) at resolveDep
(http://localhost:8100/build/vendor.js:11398:45) at createClass
(http://localhost:8100/build/vendor.js:11262:32) at createDirectiveInstance
(http://localhost:8100/build/vendor.js:11082:37)
还有
Stack
Error: Uncaught (in promise): Error: No provider for NativeAudio!
Error: No provider for NativeAudio!
at injectionError (http://localhost:8100/build/vendor.js:1590:86)
at noProviderError (http://localhost:8100/build/vendor.js:1628:12)
at ReflectiveInjector_._throwOrNull (http://localhost:8100/build/vendor.js:3129:19)
at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/vendor.js:3168:25)
at ReflectiveInjector_._getByKey (http://localhost:8100/build/vendor.js:3100:25)
at ReflectiveInjector_.get (http://localhost:8100/build/vendor.js:2969:21)
at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/vendor.js:3937:52)
at resolveDep (http://localhost:8100/build/vendor.js:11398:45)
at createClass (http://localhost:8100/build/vendor.js:11262:32)
at createDirectiveInstance (http://localhost:8100/build/vendor.js:11082:37)
at c (http://localhost:8100/build/polyfills.js:3:13535)
at Object.reject (http://localhost:8100/build/polyfills.js:3:12891)
at Tab.NavControllerBase._fireError (http://localhost:8100/build/vendor.js:43003:16)
at Tab.NavControllerBase._failed (http://localhost:8100/build/vendor.js:42991:14)
at http://localhost:8100/build/vendor.js:43046:59
at t.invoke (http://localhost:8100/build/polyfills.js:3:9283)
at Object.onInvoke (http://localhost:8100/build/vendor.js:4508:37)
at t.invoke (http://localhost:8100/build/polyfills.js:3:9223)
at r.run (http://localhost:8100/build/polyfills.js:3:4452)
at http://localhost:8100/build/polyfills.js:3:14076
您可以在 /image/lcBXc.png 查看我的项目结构.
最佳答案
问题是您只是在所需文件中添加了导入,但没有将其添加到提供程序文件中。
打开:
src/app/app.module.ts
在文件顶部导入插件,在本例中为 NativeAudio:
从'@ionic-native/native-audio'导入{NativeAudio};
然后添加新插件的 Providers 部分:
providers: [
StatusBar,
SplashScreen,
NativeAudio, // New provider, don't forget to add comma
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
一切准备就绪!
关于android - Ionic 2 Native Audio 在浏览器中抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45181436/
我有一个小型WordPress网站。我做了很多音频工作,并且试图在WordPress的博客条目中发布HTML5音频剪辑。由于某种原因,它不起作用。它可能与我在WordPress网站上使用的样式有关,但
我在让 html5 标签与 Web Audio API .createMediaElementSource() 方法配合使用时遇到问题。请参阅下面的 jsFiddle/代码。任何想法这里出了什么问题将
我尝试安装ffmpeg $ brew install ffmpeg 并运行 ffmpeg $ ffmpeg -i audio.m4a -ar 8000 -ab 12.2k audio.amr 我收到以
我已使用Web Audio API中的getByteFrequencyData方法使用了来自Analyzer节点的FFT数据来创建频谱可视化器,如下所示: 在这种情况下,我有256个数据箱。这个数字到
Google VR刚刚为wwise制作了一个VR插件: https://developers.google.com/vr/audio/wwise-getting-started https://git
如何将新记录追加到现有记录中的选定位置或特定位置? 例如,有一个5秒的录制,我想再次录制,但是将此录制追加到先前录制的特定位置,说出来:在3秒钟的录制长度之后追加此录制。 最佳答案 您可以使用getC
我们基于 Raspberry Pi 和 omxplayer 构建简单的网络控制视频播放器。我们遇到的问题是任何使用 ffmpeg 转码的文件都有音频不同步。在 iPad 上制作并直接上传到 Pi 的视
我正在尝试了解Web Audio API的引入对基于Web的游戏的开发意味着什么。 Flash游戏当然可以执行一些相当高级的音频处理,对于简单的游戏,音频元素也许就足够了。但是Web Audio AP
我已经在如何用简单的音频引擎循环播放声音效果方面进行了广泛的搜索,但是在cocos2d论坛上除了hello with looping sfx之外,它并没有取得太大进展,因为它存在多个问题。如何在Sim
我的任务是打开一个扩展名为 mka 的现有音频文件(Matroska 容器)并提取原始音频数据。 This示例仅显示了从 mp2 文件中提取原始数据的示例。我不知道如何使用 mka 容器执行此操作。我
我是Lync 2013 SDK的新手(现在已经使用了几周),并且能够弄清除此以外的大部分东西…… 当我加入 session 时(使用ConversationManager.JoinConference
我好奇。如何实现有史以来最简单的音频引擎?我有一些类似使用默认音频设备的音频数据流的想法。玩了很多 RtAudio,我认为如果可以放弃一些功能,这是可能的。有人知道从哪里开始吗? 最佳答案 我会这样做
我一直在玩网络音频API。 我正在使用getByteFrequencyData来显示频带的分贝数据,但是我想更改显示频带的整个范围,因为现在重要的音频都被压缩为一对频带。 有关如何执行此操作的任何想法
我想在音频 session 以NAudio开始和结束时接收回调。以下代码正在运行: private void SetupMediaSessionCallbacks() {
我可以用trackPosition,offset以某种方式记录并输出到WAV。当在浏览器中播放时,它工作正常,我只想输出到WAV文件。 for (var i = 0; i 0) {
在哪种情况下,我们可以不将Google Resonance Audio SDK与耳机配合使用,而应将其与真实的扬声器配合使用(例如,安装在360°的音圈设置中)? 还是所有算法都不适用于真实的扬声器输
AudioPannerNode是一个处理节点,用于在三维空间中定位/空间化传入的音频流。有没有一种方法可以将其用于常规LR平移,请记住它使用3D笛卡尔坐标系与侦听器结合使用,该侦听器的位置和方向与平移
我有一个带有两个源的音频对象,分别为M4A和OGG格式。 代码如下: 然后,我可以调用document.getElementById('audio1')。play()并开始播放。 它适用于所有
我正在尝试构建一个允许将时间/节奏(可能是音高)输入到 Web 音频振荡器节点的界面。实际上创建了一个“步进音序器”。 为 Web Audio API 振荡器节点触发预定 NoteOn 的最佳方式是什
是否可以使用 Core Audio 以亚毫秒级延迟播放声音? 我尝试过使用具有不同大小和缓冲区数量的 AudioQueues,也尝试过使用 AudioUnits,但我一直无法将延迟降低到 30 毫秒以
我是一名优秀的程序员,十分优秀!