插件接​​收音频文件 [英] plugin to receive Audio file

查看:170
本文介绍了插件接​​收音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的Java和Android和我试图让使用Eclipse统一的Andr​​oid插件。

I'm fairly new to Java and Android and I'm trying to make an Android plugin for Unity using Eclipse.

我们的目标是让插件播放音频文件,有效地绕过了Unity引擎的音频播放,因为统一项目的移动版本,呼吁音频播放介绍滞后。

The goal is to let the plugin play audio files, effectively bypassing the Unity Engine's audio playback since a mobile build of the unity project introduces lag in calling the audio playback.

我已经看到了它在YouTube上实现的: https://www.youtube.com/watch ?v = NyceOWbr7T4

I've seen it implemented on youtube: https://www.youtube.com/watch?v=NyceOWbr7T4

我想你可以从统一发送一个抽象的文件的插件,问题是,你怎么能跨$ P PT文件到的Soundpool对象(或资源?)$,以便它可以播放?

I figure you can send an abstract file from Unity to the plugin, the question is, how can you interpret the file into a soundpool object (or resource?) so that it can be played?

*音频文件将在Unity项目,但jar文件之外。

*The audio file would be in the Unity project, but outside of the jar file.

推荐答案

所以,我还是没能转发实际的文件(WAV),然后尝试将其转换为的Soundpool。我所做的是不同的东西:

So, I still wasn't able to forward the actual file (wav) then try to convert it to SoundPool. What I did was something different:


  1. 我把音频文件到StreamingAssets文件夹,这样当项目打包,我还是有机会获得这些原始文件(尽管在Android中,他们的COM pressed成jar文件)。 (就像在Venkat在公理工作室说,我希望我看到的答案越早虽然花了一些时间发现什么StreamingAssets者。)

  1. I put the audio files into the StreamingAssets folder so that when the project is packaged, I still have access to these raw files (although in Android, their compressed into jar files). (Just like Venkat at Axiom Studios said, I wish I saw that answer sooner though, spent some time discovering what StreamingAssets were.)

使用WWW,我能够从jar文件中检索原始文件。这是从Application.streamingAssetsPath。

Using WWW, I was able to retrieve the raw files from the jar files. This is from "Application.streamingAssetsPath".

通过这些文件,我写了他们进入一个新的目录,可以通过使用File.WriteAllBytes插件方便。我用Application.persistentDataPath目录。

With these files, I wrote them into a new directory that can be easily accessible by the plugin using File.WriteAllBytes. I used the "Application.persistentDataPath" directory.

在插件方面,是的Soundpool能够从提供的URL,这是目标目录+文件名获取资源。

In the plugin side, SoundPool is able to get the resource from a provided URL, which is the destination directory + file name.

通过这个过程中,我能够最终完成我要去了,并且在性能上的改进是激烈。而我pretty高兴。

With this process, I was able to ultimately accomplish what I was going for, and the improvement in performance is drastic. And I'm pretty happy with it.

*注:然而,这使得文件的副本从包内直到安装夹(/data/data/com.example.app/files例如)。我敢肯定,你可以选择写如果文件已经存在,只是让你可以有保留原文件供以后使用,或只是删除它们时,应用程序关闭的清理之前提供的支票。

*Note: This however, makes copies of the files from inside the package unto the install folder (/data/data/com.example.app/files for example). I'm sure you can opt to provide a check before writing if the files exists already just so you can leave the files there for future use, or just delete them when the app closes as clean up.

这篇关于插件接​​收音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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