Play audio & video files in user account using Easy Digital Downloads WordPress plugin

135 views Asked by At

I use Easy Digital Downloads plugin to sell downloadable files. Now I want to play audio and video files (that user buy it) in user account, I can print downloads history with this shortcode: [download_history] but this just show download history not play, next I changed history-downloads.php file like this:

<div class="edd_download_file">
    <a href="<?php echo esc_url( $download_url ); ?>" class="edd_download_file_link">
<?php echo edd_get_file_name( $file ); ?>
    </a>
    <br>play online audio
    <audio controls>
       <source src="<?php echo esc_url( $download_url ); ?>" type="audio/ogg">
       your browser dosn't support play file!
    </audio>
</div>

but I want to play Both video and audio, how can I separate video and audio type download files? is there a way to access download category and use it like this?

<?php if($file_category_id==$video_category_id){
    echo '<br>play online video
        <video width="400" controls>
            <source src="'. esc_url( $download_url ) .'" type="video/mp4">
            Your browser does not support video.
        </video>';
}
else if($file_category_id==$audio_category_id){
    echo '<br>play online audio
        <audio controls>
            <source src="'. esc_url( $download_url ) .'" type="audio/ogg">
            your browser does not support audio!
        </audio>';
} ?>
1

There are 1 answers

0
gregman On

You can store content type of downloadable files and use it when used short code [download_history]. For example you can use ACF plugin and set custom type on your product.