MP3音频播放与科尔多瓦3.5 iOS上的工作 [英] mp3 audio playback not working with Cordova 3.5 on iOS

查看:154
本文介绍了MP3音频播放与科尔多瓦3.5 iOS上的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级了我们的iOS项目从科尔多瓦3.3到3.5。

Recently I upgraded our iOS Project from Cordova 3.3 to 3.5.

MP3文件(分别为previously下载到iOS的标准文件夹)将无法播放使用媒体API /插件。这code已经在iOS可靠地工作了很多版本,并包括科尔多瓦3.3 ...的MP3文件下载到一个标准iOS应用程序文件文件夹,名为'下载'子目录。

mp3 files (that were previously downloaded into the iOS standard documents folder) will not play using the media API / plugin. This code has been working reliably on iOS for many versions up and including Cordova 3.3... The mp3 files have been downloaded into a subdirectory called 'Downloads' in the standard iOS App 'documents' folder..

在X $ C $。c控制台我得到以下错误:

In XCode console I get the following error:

未知资源'file://localhost/Users/weeasle/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/{App-ID}/Documents/Downloads/testsound.mp3'

Unknown resource 'file://localhost/Users/weeasle/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/{App-ID}/Documents/Downloads/testsound.mp3'

在我的code(后code的文件插件API的几个街区)我用得到的目录:downloadDirFullPath = window.appRootDir.toURL();

In my code (after a few blocks of code for the File Plugin API) I get the directory using: downloadDirFullPath = window.appRootDir.toURL();

要符合3.5的文件API的新变化,我最近改变了这个从
downloadDirFullPath = window.appRootDir.fullPath;

To comply with the new changes in 3.5's file API, I recently changed this from downloadDirFullPath = window.appRootDir.fullPath;

是科尔多瓦3.5媒体插件API从iOS应用程序Documents目录???

Is the Media Plugin API for Cordova 3.5 broken for audio playback from the iOS App Documents directory???

还是我真的累了,并缺少明显的东西...任何建议或信息大大AP preciated。

Or am I just really tired and missing something obvious... Any suggestions or info greatly appreciated.

克里斯
又名weeasle

Chris aka weeasle

更新20 /月/ 14:解决发现。现在我可以让我下载的.mp3的在iOS 3.5科尔多瓦打......显然与新科尔多瓦3.5文件系统entry.fullPath方法不再起作用,是由entry.toURL(替换)按<一个href=\"https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md\">https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md

UPDATE ON 20/Jun/14: Fix Found. I can now get my downloaded .mp3's to play on iOS Cordova 3.5... Apparently with the new Cordova 3.5 filesystem the entry.fullPath method no longer works and is replaced by entry.toURL() as per https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md

这与调用科尔多瓦影像时,但出现了与媒体插件怪癖iOS上相当长的一段时间正常工作:对于声音的播放,它不接受的网址开头的file:///只需要绝对路径就像在/ var /移动/应用/ {GUID} /文件/

This works fine when calling images with Cordova, However there has been a quirk with the Media Plugin on iOS for quite some time: For sound playback, it does not accept URLs starting with file:/// it only takes absolute paths like /var/mobile/Applications/{GUID}/Documents/

答案和解决方法是使用一种叫做内的输入从fileSystem.root.getDirectory返回新toInternalURL()方法。我使用的确切调用downloadDirFullPath = window.appRootDir.toInternalURL(); (称为从fileSystem.root.getDirectory传递的条目)。

The answer and fix is to use the new toInternalURL() method called within the entry returned from fileSystem.root.getDirectory. The exact call I use is downloadDirFullPath = window.appRootDir.toInternalURL(); (called from the entry passed by fileSystem.root.getDirectory).

这将返回:cdvfile://本地主机/永久/下载/,当pre-挂起为.mp3或其他音频文件在iOS中成功的扮演。

This returns: cdvfile://localhost/persistent/Downloads/ which when pre-pended to .mp3 or other audio files plays successfully in iOS..

这也适用于所以它是科尔多瓦的iOS 3.5及以上的单一可靠的解决方案显示图像和媒体。

This also works for displaying images and media so it is a single reliable solution for Cordova iOS 3.5 and up..

这是迄今为止preferred解决方案,因为它比使用相对路径(仿佛在未来使得苹果使用iOS版本显著文件结构的改变,文件的访问可能会破坏)...

This is by far the preferred solution since it is safer than using relative paths (as if in future Apple makes significant file structure changes with an iOS release, file access could break)...

一个进一步音符 - 除了呼叫/上述方法中,downloadDirName = window.appRootDir.name;还设置cdvfile://本地主机/永久/基本路径

One further note - in addition to the calls/methods above, downloadDirName = window.appRootDir.name; also sets cdvfile://localhost/persistent/ base path

Weeasle

推荐答案

只有用最新科尔多瓦3.5版本为我工作的事情是存在的:
http://www.raymondcamden.com/2014/06/23 /科尔多瓦 - 媒体API-例

The only thing that worked for me with latest cordova 3.5 version is there: http://www.raymondcamden.com/2014/06/23/Cordova-Media-API-Example

请确保安装此插件:
科尔多瓦插件添加 https://开头的git-WIP-US。 apache.org/repos/asf/cordova-plugin-device.git

这篇关于MP3音频播放与科尔多瓦3.5 iOS上的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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