<div class="row" style="padding: 10px">
    <?php
    $post_counter = 0;
    $total_public_video = $this->post_model->total_public_video_person_id($profile_person_id);
    $public_video = $this->post_model->all_public_video_person_id($profile_person_id, $post_counter);
    if ($public_video) {
        ?>
        <div class="col-sm-12" style="padding: 0 5px 5px 5px">
            <p class="bg-primary lead" style="text-align: center;background-color: #8CC73F;font-size: 16px;margin-bottom: 0px"> Video</p>
        </div>
        <div id="video_view" class="col-sm-12">
            <?php
            foreach ($public_video as $video_value) {
                ?>
                <div class="col-sm-12 padding-zero">
                    <div class="col-sm-12" >
<!--                        <div class="media-body" style="padding-bottom: 0px;margin-bottom: 0px">-->
                            <div class="col-sm-12">
                                <div class="row" id="right_video_player<?php echo $video_value->post_id; ?>">
                                    <video controls>
                                        <source src="<?php echo base_url() . 'content-library/' . $video_value->url . '/' . $video_value->post_details; ?>" type="video/mp4">                                                              
                                    </video>
                                </div>
                            </div>


<!--                            <div class="embed-responsive embed-responsive-16by9">
                                <div id="right_video_player<?php echo $video_value->post_id; ?>">
                                    <a href="http://www.adobe.com/go/getflash">
                                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                                    </a>
                                    <p>This page requires Flash Player version 10.3.0 or higher.</p>
                                </div>
                            </div>-->

                            <script>
//                                var vURL = "<?php echo base_url() . 'content-library/' . $video_value->url . '/' . $video_value->post_details; ?>";
//                                var subtitlePath = "";
//                                var playerID = 'right_video_player<?php echo $video_value->post_id; ?>';
//                                loadedRight(vURL, subtitlePath, playerID);
                            </script>
<!--                        </div>-->
                        <br>
                        <?php
                        $posted_public_video_link = base_url() . 'view-content/' . $this->utility_model->encode_id($video_value->post_id, '/', 'Tt') . '/2';
                        $this->session->set_flashdata('public_video_link', $posted_public_video_link);
                        ?>
                        <div class="col-sm-12 text-left" style="color: #80c12c; margin-top: 10px">
                            <center>
                                <a class="btn btn-facebook-custom" title="Share in Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($posted_public_video_link); ?>">
                                    <i class="fa fa-facebook" aria-hidden="true"></i>
                                </a>
                                <a class="btn btn-twitter-custom" title="Share in Twitter" target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo $profile_name . ' posted this video on TalhaTraining'; ?>&url=<?php echo $posted_public_video_link; ?>">
                                    <i class="fa fa-twitter" aria-hidden="true"></i>
                                </a>
                                <a class="btn btn-google-custom" title="Share in G+" target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode($posted_public_video_link); ?>">
                                    <i class="fa fa-google-plus"></i>
                                </a>
                                <a class="btn btn-linkedin-custom" title="Share in Linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($posted_public_video_link); ?>&title=<?php echo $profile_name . ' posted video on TalhaTraining'; ?>&summary=<?php echo $video_value->post_file_original_name; ?>">
                                    <i class="fa fa-linkedin"></i>
                                </a>
                            </center>
                        </div>
                        <div class="col-sm-12 form-group"><hr></div>
                    </div>
                </div>
                <?php
            }
            ?>
            <div class="col-sm-12">
                <?php
                if ($total_public_video->total_video > 1) {
                    ?>
                    <div class="col-sm-12">
                        <?php
                        if ($post_counter > 1) {
                            ?>
                            <a href="javascript:void(0)"
                               class="pull-left">
                                Previous
                            </a>
                        <?php } ?>
                        <a href="javascript:void(0)"
                           onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_video->posted_by . '/' . ($post_counter + 1) . '/video' ?>', 'video')"
                           class="pull-right">
                            Next
                        </a>
                    </div>
                <?php } ?>
            </div>
        </div>
    <?php } ?>
</div> 
<script>
    function viewDetails(url, htmlID, ID) {
        serverPage = url;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                //            alert(xmlhttp.responseText);
                document.getElementById(htmlID + ID).innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(null);
    }
    function nextPostValue(url, type) {
        serverPage = url;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                if (type === 'note') {
                    document.getElementById('note').innerHTML = xmlhttp.responseText;
                } else if (type === 'alert') {
                    document.getElementById('alert').innerHTML = xmlhttp.responseText;
                } else if (type === 'assignment') {
                    document.getElementById('assignment').innerHTML = xmlhttp.responseText;
                } else if (type === 'image') {
                    document.getElementById('image_view').innerHTML = xmlhttp.responseText;
                } else if (type === 'video') {
                    document.getElementById('video_view').innerHTML = xmlhttp.responseText;

                    var hiddenID = document.getElementById('hiddin_post_video_id').value;
                    var hiddenURL = document.getElementById('hiddin_post_video_url').value;

                    var videoID = hiddenID.split('##');
                    var videoURL = hiddenURL.split('##');
                    plyr.setup();
                    for (var i = 0; i < videoID.length - 1; i++) {
                        var vURL = videoURL[i];
                        var subtitlePath = "";
                        var playerID = 'right_video_player' + videoID[i];
                        loadedRight(vURL, subtitlePath, playerID);
                    }
                }
                //                        
            }
        };
        xmlhttp.send(null);
    }

    function downloadPublicContentLibrary(url, ID) {
        window.location.href = url + '/' + ID;
    }
    
    $(document).ready(function(){
        plyr.setup();
    });
</script>