<?php
wp_enqueue_script('videojs',get_template_directory_uri().'/static/js/video.js');
wp_enqueue_script('audiojs',get_template_directory_uri().'/static/js/audio.js');


$audio_url = get_post_meta(get_the_ID(), 'audio_url', 1);

global $wpdb;
$attach_id = get_attach_id_by_url($audio_url);
$row_mp3=[];
if($attach_id){
    $row_mp3[] = get_post($attach_id);
}

?>
<?php  if(!empty($audio_url) && _ceo('cao_audio') == true): ?>
<div class="ceo-video">
    <div class="ceo-video-logo">
        <img src="<?php echo _ceo('head_logo');?>">
    </div>
</div>
<?php endif; ?>

<?php
foreach ($row_mp3 as $music) {
    ?>
<div class="audio-wrapper">
        <audio id="player-<?php echo $music->ID;?>" class="audio-play" preload="none" src="<?php
        echo $audio_url;

        ?>"></audio>
    <div class="audio-info">
        <div class="audio-left">
            <img id="audioPlayer" class="play-icon" src="<?php echo get_template_directory_uri();?>/static/images/play.png">
            <div class="cover-bg"></div>
        </div>
        <div class="audio-right">
                <h1><?php
                    echo $music->post_title;
                    ?></h1>
            <div class="poster-footer">
                    <a><time datetime="<?php echo get_the_time('Y-m-d', $post->ID); ?>"><i class="fa fa-clock-o"></i> <?php echo get_the_time('Y-m-d', $post->ID); ?></time></a>
                    <a><span><i class="fa fa-eye"></i> <?php echo _get_post_views() ;?></span></a>
            </div>
            <div class="progress-bar-bg" id="progressBarBg">
                <div class="progress-yinfu"></div>
                <span id="progressDot"></span>
                <div class="progress-bar" id="progressBar"></div>
            </div>
            <div class="audio-time">
                <span class="audio-length-current" id="audioCurTime">00:00</span>
                    <span class="audio-length-total"><?php
                        $mp3_duration=get_transient('duration_'.md5($music->guid));
                        if($mp3_duration){
                            echo $mp3_duration;
                        }else{echo '00:00';}?></span>
            </div>
        </div>
    </div>
</div>
    <?php
}
?>
