This is a tricky problem. I needed to write a class to be able to play from file lists, but I had to specify their names.
Class start:
window.audioSWebManager = {
audio: null, // Current player
playlist: [], // Play queue
currentIndex: 0,
playlistId: 0, // Playlist ID for tracking relevance
isPlaying: false,
loop: false,
shuffleN: 0, // after how many cycles will the mixture be mixed
loopN: 0, // current cycle number
initAudio() {
I needed the ability to set the playback speed of files and file blocks: words and translations.
I simply implemented the idea of ​​being able to play a file slowly at first, then another word, and then back to normal speed.
I also have the ability to view the most recent word-translation pairs and start automatic pronunciation if you’re having trouble remembering them. I use the code like this:
// Function for playing a list of files
function playAudioList(files, loop = false, shuffleN = 0) {
/* files - array of objects or strings: ['file1.mp3', 'file2.mp3']
или
[
{filename: 'file1.mp3', speed: 1.0},
{filename: ':1000', speed: 1.0}, // pause 1 second
{filename: 'file2.mp3', speed: 1.5},
{filename: ':0', speed: 1.0} // end of block file mark (for shuffling)
]
shuffleN - after how many cycles will the mixture be mixed
*/
In general, this entire code will be open source. Although it’s ready, it’s not yet publicly available, and I still need to debug the issues.
For now, I’ve made a couple of decks from www.goethe-verlag.com, one in each direction, and I’ll probably have to finish some more, as the available ones contain phrases, but not words, and the language isn’t quite right. ankiweb.net/shared/decks?search=book2
There’s a lot of code, it’s complex, and not for ordinary people.
Of course, when you have a template, it’s easier to use it for your own words, and only if it works.
If there were code libraries, a player like this would be useful. I almost have a fully developed idea for a player with more functionality, but it’s huge, and I don’t see any point in implementing it here for words yet, but for phrases, I might have to.
So, if I need to play files in a certain sequence… and this template has that option, I do:
<span style="display: none">{{Audio_Learn}}</span>
It’s just a hidden field that plays at the beginning, and for the pause, I created separate files and uploaded them to a shared folder so I can use them in the design. So, I have both the standard and my own voiceover… which even plays automatically in ankiweb.net when the map is shown.