I would add an id to the element to make is easier to access via code, like:
<audio id="song" autoplay loop>
...
Then you can grab the track with jQuery like this:
$('#song')[0]
To check if it's playing:
(set: _notPlaying to $('#song')[0].paused)
An audio track will always be "paused" if it isn't playing.
To set up an event for when a track finishes:
<script>
$("#song").on('ended', function () {
// JavaScript code
});
</script>
I also suggest taking a look at one of my audio libraries. HTML audio works fine, but Twine's structure often causes problems for audio that's played from within passages.
https://twinelab.net/harlowe-audio/#/
https://github.com/ChapelR/howler-for-harlowe
The former library is still in beta, but the latter has bugs that won't be fixed. So for right now, you've just got to pick your poison if you want better functionality and control than you can easily get via HTML. Using the former and finding and reporting bugs and issues will help me inprove it though and move it to fill release, but if Howler for Harlowe does everything you need, there's little reason not to use it.