问题
I'm developing an app for Recognize speech using google cloud speech APi and recording audio simultaneously. git link
I tried to play recorded .opus audio file getting IOException
W/System.err: java.io.IOException: setDataSource failed.
Any idea?? Thanks!!
回答1:
A user on the android stack exchange mentioned being able to play opus files when they have a .ogg extension in newer versions of Android.
Rename your .opus files to .ogg.
回答2:
I don't know about that specific error, but the Supported Media Formats page says Opus is only supported in Android 5.0+, and then only in the matroska container.
Make sure you're testing on newer Android, and you may need to demux manually to feed raw packets to the decoder.
If you need Opus support everywhere you can include the C library in your app and call it directly over JNI.
来源:https://stackoverflow.com/questions/44435259/how-to-play-opus-audio-file-in-android