androidphonegap和jqtouch中声音播放和向前滑动动画闪烁问题?
我正在开发一个使用 android 手机间隙的应用程序。它由大约 25 张图像和类似数量的 mp3 文件组成。每个mp3文件的持续时间不超过10秒。应用程序的要求是每当屏幕上显示图像时,应播放其相关的 mp3 文件。我正在使用 jqtouch 滑动操作从一页移动到另一页。我在模拟器和真实设备(三星 Galaxy 3)上都面临以下问题 -
15-20 个图像后,声音在模拟器和 Galaxy 3 上停止播放。在 logcat 中,我收到以下错误
错误/AudioFlinger(34):没有足够的内存用于 AudioTrack size=49216
我正在使用以下代码来播放 mp3 文件
if(mp3file!=null){
mp3file.stop();
mp3file = null;
}
mp3file = new Media("/android_asset/www/name_of_file.mp3",
function() {
console.log("playAudio():Audio Success");
},
function(err) {
},
function(status) {
});
mp3file.play();
我认为错误是由于内存中剩余的每个 mp3 文件的phonegap api 中的audiomanager 对象造成的。 我想知道如何销毁在 javascript 中创建的媒体对象。您可以播放、停止、暂停。但是phonegap中是否有任何方法可以让android销毁它,以便它在播放完毕后不会保留在内存中。
- 我面临的另一个问题与 jqtouch 中的向左滑动操作查看下一张图像有关。如果我当前正在查看图像 1,并且尝试通过向左滑动操作查看图像 2,则图像 2 会显示很短的时间,然后图像 1 显示一会儿,然后再次显示图像 2。简而言之,从 image1 到 image2 不平滑并且有闪烁效果。但是,如果我使用右滑动从 image2 转到 image1,过渡会很平滑。
谢谢
I am developing an app using phonegap for android. It consists of around 25 images and similar number of mp3 files. Each mp3 file has duration not more than 10 seconds. The requirement of app is whenever a image is shown on screen its related mp3 file should be played. I am using jqtouch swipe action to move from one page to another. I am facing following problems both on emulator and real device(samsung galaxy 3)-
After 15-20 images sound stops playing both on emulator and galaxy 3. In logcat I got following error
ERROR/AudioFlinger(34): not enough memory for AudioTrack size=49216
I am using following code to play mp3 files
if(mp3file!=null){
mp3file.stop();
mp3file = null;
}
mp3file = new Media("/android_asset/www/name_of_file.mp3",
function() {
console.log("playAudio():Audio Success");
},
function(err) {
},
function(status) {
});
mp3file.play();
I think error is due to audiomanager objects from phonegap api of each mp3 file remaining in memory.
I want to know how to destroy media object created in javascript. You can play, stop, pause. But is there any method in phonegap for android to destroy it so that it does not remain in memory after it has done playing.
- Another problem that I am facing is related with left swipe action in jqtouch to view next image. If I am currently viewing image1 and if I try to view image2 by left swipe action, image2 is shown for short amount of time and after that image1 is shown for a moment and after that again image2 is shown. In short the transition from image1 to
image2 is not smooth and it has flickering effects. However if i go from image2 to image1 using right swipe transition is smooth.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这方面得到了另一位开发人员的帮助。诀窍是让一个函数在函数外部声明 mp3file,然后在其上调用 stopRecord()。(即使您没有进行录音)。我用一个简单的按钮播放来测试了这一点一遍又一遍地发出声音,它工作了 75 次之后我就厌倦了。
让我知道它对你有用。
I got some help with another developer on this.The trick is to make a function declare mp3file outside the function then call stopRecord() on it.(even though you're not doing recording).I tested this with a simple button playing the sound over and over and it worked 75 times before I got tired of playing with it.
Let me know it works for you.