Comments (5)
Please show the exact code used to preload the audio files
from axmol.
Hi rh101,
Sure, not a problem. The exact layout is that you have a tableview with a number of cells. When you click on a given table cell, the sound associated to that cell will play the audio file. To help, I would like to point out that it is working without any issue on iOS (iPhone & iPad). Please see the code below and let me know if there is something wrong with the way the API is used :
bool CChatDialogLayer::playSound(ssize_t idx)
{
if (idx < 0 || idx >= m_messages.size()) return false;
CConnexionMessage::MessageType msgType = m_messages[idx].getType();
bool playSoundMsg = (msgType == CConnexionMessage::MessageTypeSound);
if (!playSoundMsg) return false;
std::string strMsg = m_messages[idx].getText();
// Check if we have a direct access to the audio file.
// If not, we need to download it and play it
std::string file = m_messages[idx].getExistingFilePath();
if (!file.empty())
{
playSoundMsg = true;
}
else
{
m_savedAudioFileName = strMsg;
m_audioIdx = idx;
requestFirebaseDownload((int)CConnexionMessage::MessageTypeSound,strMsg);
playSoundMsg = false;
}
if (playSoundMsg)
{
#if AX_TARGET_PLATFORM == AX_PLATFORM_IOS
IOSManager::ConfigureAVAudioSession();
#endif
AudioEngine::preload(file, [&, file](bool success) {
if(success)
{
int aid = AudioEngine::play2d(file, false, 1.0f, nullptr);
if (aid == AudioEngine::INVALID_AUDIO_ID) return false;
m_audioID = aid;
m_audioIdx = idx;
m_audioFile = file;
if(aid != AudioEngine::INVALID_AUDIO_ID)
{
AudioEngine::setFinishCallback(m_audioID, [&] (int audioID, std::string_view file) {
if (audioID == m_audioID)
{
ssize_t save_idx = m_audioIdx;
stopSound(false);
m_pTableView->updateCellAtIndex(save_idx);
}
});
}
}
});
}
return playSoundMsg;
}
Thank you,
Stay safe
from axmol.
@asnagni The MP3 file is not using the MP3 codec, but rather the MP4A codec, as you can see here:
The file extension is not entirely relevant, so when encoding to MP3, ensure that you're using an MP3 codec, such as this:
This is not a bug with Axmol. The reason the "Test.mp3" file is working on iOS is because the MP4A format is supported on iOS.
from axmol.
The WAV file is in the following format:
I'm not sure if the SAMR format is supported, and it does not seem to be a valid format for WAV files. The correct extension for a file encoded in that format should be .amr
or .3ga
. Once again, the file extension is not important, but the internal encoding is, so it is not playing the file because it is not actually in a supported WAV format. The "test2.wav" file doesn't play on Windows builds either.
WAV data formats that are supported can be seen here in the cpp-tests
project:
For example, PCM, u-Law etc.
In AudioCache.cpp
, you can see the supported formats:
from axmol.
Hi rh101,
Sorry for the delay in my responce. Thank you very much for all the details that you provided. I spent lot of time trying the sounds located test area and they are working. Axmol is working fine without any issue per the document (supported format). Unfortunately for our use case the supported format are a bit limited. I spent some time testing Axmol to see if I could find a solution but finaly a will be using ExoPlayer2 (it supports much more format than MediaPlayer and it is very easy to implement).
That way we will not run the risk of having some crashes due to unsorted format.
Thank you very much rh101 for your support 👍, I do appreciate.
Stay safe
from axmol.
Related Issues (20)
- Cannot capture a layout: issue with RenderTexture?
- Cannot Capture a ScrollView: Issue with RenderTexture? HOT 6
- Font rendered as white boxes HOT 10
- Downloader fails if filename with tmp extension already exists HOT 2
- Support removal of debug logging calls from builds HOT 6
- zlib download path. HOT 2
- Android Webview loadData call error function HOT 2
- Rename all AXLOG to AXLOGD (there be 417 without .\core) HOT 3
- JobSystem creates too many threads HOT 3
- ax::ui::WebView cannot display local image HOT 5
- Bug in FreeType lib for certain fonts HOT 1
- macOS Edit wrong alignment
- FastRNG seems to have problematic implementation HOT 30
- RenderTexture ContentSize Error HOT 3
- Cannot Capture properly take a screen capture of ax::ui::ImageView HOT 4
- Two rapidjson with different version cause unexpected crash problem on apple family platforms HOT 15
- MediaPlayer Video not correctly rendered for Android 11 and older devices
- [ImGui] Invalid texture data drawn on modal popups HOT 1
- ArchLinux setup dependencies always fail
- VolatileTextureMgr::addImage memory leak HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axmol.