iOS Phonegap媒体对象 - 如何访问WWW文件夹中的资源? [英] iOS Phonegap Media Object - How do I access a resource in the WWW folder?

查看:137
本文介绍了iOS Phonegap媒体对象 - 如何访问WWW文件夹中的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序与phonegap,我有一个声音文件,我想玩一个路径,如www / Sounds / sound.mp3,我试图访问此文件使用Media对象

I'm developing an application with phonegap, and I have a sound file I want to play that's in a path like so www/Sounds/sound.mp3, and I'm trying to access this file using the Media object of Phonegap in order to play it.

我无法找出在使用Media对象的javascript文件中访问此声音文件的路径?我试过路径像,file:///www/Sounds/sound.mp3,相对路径等,我不能访问它。我在xcode 4中继续得到以下错误

I cannot figure out the path to access this sound file within a javascript file that uses the Media object? I've tried paths like, file:///www/Sounds/sound.mp3, relative paths, etc and I cannot access it. I keep getting the following error in xcode 4

Will attempt to use file resource 'file:///www/Sounds/sound.mp3'
Unknown resource 'file:///www/Sounds/sound.mp3'

我需要使用什么路径来访问文件?或者我需要将声音文件从我的www目录复制到我的资源文件夹并访问它吗?

What path do I need to use to access the file? Or do I need to copy the sound file out of my www directory and into my Resources folder and access it there?

我的WWW文件夹被引用,不知道是否

My WWW folder is referenced, not sure if that makes a difference.

推荐答案

从Cordova 3.3+开始,其他2个答案都不正确。

As of Cordova 3.3+, the 2 other answers aren't correct. It should work even if you just pass it a file name.

但是,只有在文件扩展名为的情况下才能在iOS中使用。 .wav

But, it will only work in iOS if the file extension is .wav.

这将工作:

var media = new Media('recording.wav', ...);

这不会:

var media = new Media('recording.mp3', ...);

这篇关于iOS Phonegap媒体对象 - 如何访问WWW文件夹中的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆