Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
I have dynamically created a video list from my database. For that I have done my code in php:
$query = "select post,link from pagination order by id desc
limit $pageLimit," . PAGE_PER_NO;
$res = mysql_query($query);
$count = mysql_num_rows($res);
$HTML = '';
$countli = 1;
if ($count > 0) {
while ($row = mysql_fetch_array($res)) {
        if ($countli == 1) {
            $post = $row['post'];
            $link = $row['link'];
            $HTML.='<li class="active"><div>';
            $HTML.='<video ><source src="' . $link . '" /source>' . '<p>' . $post . '/<p>';
            $HTML.='<a href="#"  önClick="javascript:vidSwap('. $link.'); return false;">Link</a></video>';
            $HTML.='</div><br/>';
            $HTML.='</li>';
            $countli = $countli+1;
        }
 else {
     $post = $row['post'];
            $link = $row['link'];
            $HTML.='<li><div>';
            $HTML.='<video ><source src="' . $link . '" /source>';
            $HTML.='<a href="#"  önClick="javascript:vidSwap('. $link.');">Link</a></video>';
            $HTML.='</div><br/>';
            $HTML.='</li>';
            $countli = $countli+1;
 }
    }
} else {
    $HTML = 'No Data Found';
}
echo '<ul id="playlist">';
echo $HTML;
echo '</ul>';
As, while loading my page it automatically generate a video list. And in my html page there is a video player. Code:
<pre lang="HTML">
<div id="leftcolumn">
                            <video id="myvideo" controls='true' style="width:820px;height:360px"
                                preload="auto">
                            </video>
                        </div>
 
And my javascript code is:
<script type="text/javascrpt">
            function vidSwap(vidURL) {
            var myVideo = document.getElementById()('#myvideo')[0];
            myVideo.src = vidURL;
            myVideo.load();
            myVideo.play();
            }
        </script>
 
But, when I am clicking in a video file from the list its working. Where is the problem I don't understand.
Posted 25-Apr-13 7:26am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 230
1 OriginalGriff 202
2 Richard MacCutchan 185
3 Tomas Takac 146
4 CPallini 125
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 25 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100