In a page that opens various items in modal-type popups on users clicking titles or images, some of the items include video, others audio.
I found a piece of code that successfully stops a Youtube video within an iframe playing on clicking the close button. Without it, the video continues to play after the popup is closed. I'm struggling to successfully modify the code to stop other players in a similar way. How could I achieve this for a Soundcloud iframe for example?
This is the bare bones of the code I am currently using successfully for youtube iframes:
<div class="wm_container slug_videos all">
<div class="videos_content_wrap">
<div id="popmake-videos_all_post-30230" class="popmake theme-27529 responsive size-large" data-popmake="{"id":"videos_all_post-30230","theme":"27529","meta":{"display":{"size":"large","overlay_disabled":0,"custom_width":"600","custom_width_unit":"px","custom_height":"","custom_height_unit":"px","custom_height_auto":0,"location":"center top","position_top":100,"position_left":0,"position_bottom":0,"position_right":0,"position_fixed":0,"animation_type":"slide","animation_speed":350,"animation_origin":"top"},"close":{"overlay_click":0,"esc_press":1}}}" style="visibility: visible; display: none;">
<div class="popmake-title">title</div>
<div class="popmake-content">
<iframe id="iF_xxUHxxxPexx" width="1280" height="480" src="http://www.youtube.com/embed/xxUHxxxPexx?autoplay=1&controls=1&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd=1&vq=hd720" frameborder="0" style="" allowfullscreen="" kwframeid="11"></iframe>
</div>
<a class="popmake-close">×</a>
</div>
</div>
<script type="text/javascript">
jQuery('videos_all_post-30230')
.on('popmakeBeforeClose', function () {
var $iframe = jQuery('iframe', jQuery(this)),
src = $iframe.prop('src');
$iframe.prop('src', '').prop('src', src.replace('?autoplay=1', ''));
});
</script>
</div>
And here is an example of a soundcloud iframe:
<iframe class="soundCloudiframe-30235" width="" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=https%3A%2F%2Fsoundcloud.com%2F . . . &color=333333&sharing=false&show_artwork=true&player_width=300" kwframeid="1"></iframe>
UPDATE:
This is a Plunker that demonstrates how the youtube video stops playing on closure of modal popup. Some magic code is needed for the same to happen with Soundcloud audio.
Any pointers on this will be much appreciated.