have you changed the dialog's notification sound from standard to none? this might prevent youtube from pausing.yes this works with any MD window is in foreground.
also working with combination of following actions -
display dialog (which i configured to show volume level) & then running script - shows dialog and then volum slider pops up.
just need to press ok after changing volume.
but this pauses youtube but acceptable