-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoplay audio from URL (on card side changes, no other clicks) #10346
Comments
Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing |
The TTS JS API is implemented on top of java/kotlin. It uses the TTS engine on the device.
Also autoplay can be implemented using following JS code in card template, add following code inside window.onload function autoPlayAudio() {
var audioDiv = document.getElementById('audio');
var audio = audioDiv.getElementsByTagName("*");
audio[0].click();
} |
Any real code? This doesn't work for me. <audio autoplay controls>
<source src="https://download.samplelib.com/mp3/sample-3s.mp3">
</audio>
<script>
window.onload = function() {
var audio = document.getElementsByTagName("audio");
audio[0].click();
}
</script> As a matter of fact, it says nothing in the console, nor the audio is played. No errors, just silence. In contrast, there is an error message for this. <audio autoplay controls>
<source src="https://download.samplelib.com/mp3/sample-3s.mp3">
</audio>
<script>
window.onload = function() {
var audio = document.getElementsByTagName("audio");
audio[0].play();
}
</script>
|
I tested above two code snippets. The autoplay works correctly. Also I didn't get the following Exception
May be it is device specific issues. Can you add
|
Debug Info
|
My bad. It seems that It doesn't play nor clickable on desktop, but both can be done in Android. Furthermore, I don't know if it can be manipulated with JavaScript, like Anyway, for now, my plan is |
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically |
Is your feature request related to a problem? Please describe.
It is possible to use TTS from JavaScript API, but the voice is not native. Also, sometimes
AnkiDroidJS.ankiTtsSpeak
is not defined for some reasons.I can indeed use AwesomeTTS to generate audio files, but syncing large media folder is quite problematic, as well as it is impossible to do in large batch with gTTS. Instead, I chose to run gTTS on demand on an external server, but of course, it is not uploaded to AnkiDroid that way.
HTML5 Audio element can be created, but autoplay doesn't work. Clicking via JavaScript doesn't work either unless there is an actual click.
Describe the solution you'd like
AnkiDroidJS.ankiPlayAudio
to play audio on Java/Kotlin side would pretty much be the surefire way.Describe alternatives you've considered
I can also trap the first click, so this works.
Additional context
TTS / audio files in Anki are a very big culprit of sync size, especially on the first sync. I think it is always better to allow online shared resources.
The text was updated successfully, but these errors were encountered: