How to pause current media when another is being played
-
How do I get one media file and player, audio in this instance, to only play one file at a time. So for example; if $audio(one) is playing and $audio(two, three, or etc.) play button is pressed, how to stop/ pause currently played $audio
and only play newly pressed play button on another media file?So far, this is what I got. What is missing for media player to play only one file at a time?
<?php $args = array( 'post_type' => 'attachment', 'post_mime_type' =>'audio', 'post_status' => 'inherit', 'posts_per_page' =>-1, ); // The Query $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // do stuff if ( $post->post_type == 'attachment'){ $attachments = get_posts( array ( 'post_type' => 'attachment', 'post_mime_type' =>'audio', 'post_status' => 'inherit', 'posts_per_page' =>-1, 'post_parent' => $post->ID ) ); } if ( $attachments ) { foreach ( $attachments as $attachment ){ $audio = wp_get_attachment_url( $attachment->ID, 'full', false ); // $attachment_id = attachment_url_to_postid( $audio ); $meta = wp_get_attachment_metadata( $audio ); echo $audio; //here outputs the attachemnts ID's of current post } } ?> <article class="audio element"> <div class="audio element title"><?php echo the_title();?></div> <div class="audio element image"><?php echo the_post_thumbnail();?></div> <div class="audio element content"><?php echo the_content();?></div> </article> <? endwhile; endif; // Reset Post Data wp_reset_postdata(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘How to pause current media when another is being played’ is closed to new replies.