我试图发送一个音频文件到对话流从一个Android应用程序。
为了做到这一点,我需要音频文件的路径。根据,它是这样的:
val videouri: URI = URI.create("android.resource://$packageName/raw/tts")
val videopath: Path = Paths.get(videouri)
val inputAudio: ByteArray = Files.readAllBytes(videopath)
但是,在第二行中,当获得路径时,我会得到以下异常:
java.nio.file.filesystemnotfound
我试图播放一个.wav音频文件,为此我跟踪了这个。
我跟踪了这个答案,但我在audio.Load(stream);上得到了一条错误消息,System.NullReferenceException: Object reference not set to an instance of an object说。
在我看来,问题似乎是,audio.load()找不到音频文件,该文件位于Resource/raw路径中。
完全代码
private void Counter(object sender, EventArgs e)
{
timer_countdown = new Timer();
在一个Android项目中,我有几千个多种语言的高度动态的音频文件。高度动态,因为在开发过程中,它们可能每周都会发生变化。有些文件是重复的(在一种语言中),为了不破坏代码中的逻辑和可维护性,它们必须是重复的--但这是浪费空间!
示例(只是一个示例,不用担心语义):
raw/en/time_rep.mp3 - used as in "one more time"
raw/en/time.mp3 - used as in "it is now time for"
raw/de/time_rep.mp3 - may be translated to "mal
我正在尝试在有几个页面的片段中实现mp3播放器。我现在面临的问题是我不能让它正常工作。问题是我试图将音频文件放入一个带有页码的数组中,也就是说,并不是所有的页面都需要有音频文件。当我运行这个应用程序时,我得到这个错误:android.content.res.Resources$NotFoundException: Resource ID #0x0,我已经注释了错误发生的地方。需要有音频文件的页面有1、3、13和16
这就是我到目前为止所尝试的:
public class PageFragment_Sounds extends Fragment implements View.OnClickLi
在尝试将XML文件解析到我的Kotlin应用程序中时,我遇到了以下问题: java.io.FileNotFoundException: /src/main/res/locations.xml: open failed: ENOENT (No such file or directory) 下面是负责处理文件加载的代码: fun parseToObject() {
val thread = Thread(Runnable {
try {
val xml = File("src/main/res/locations.xml")
我试图在shared项目的模块中编写测试。在共享模块的build.gradle.kts文件中,我有以下内容:
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
//TOD
这是我保存音频文件的方法:
try (FileOutputStream out = new FileOutputStream(getFilesDir() + "/output.mp3")) {
System.out.println(getFilesDir());
out.write(audioContents.toByteArray());
System.out.println("Audio content written to file \"output.mp3\"");
}
这工作得很好,但我想播放该音频文件。所以我可