Kan variabele niet doorgeven aan Query
Ik heb een simpele versie van Youtube in mijn script staat welke gelinkd
is aan mijn database.
Het speelt alle platen achter elkaar na een eerste klik.
Nu wil ik als een plaat begint te spelen de naam van Artiest en Titel tonen, maar dit lukt niet . Ik weet niet hoe ik dit moet doen.
De mysql query lukt me wel maar die variabele doorgeven aan mijn query als er een nieuwe plaat begint lukt me niet.
Variabele = ytplayer_playitem (javascript)
ytplayer_playitem += 1;
Website:
http://www.simonbuijs.hostoi.com/20091106YoutubeScriptverIII/
Wie heeft een suggestie?
Kan eens wat meer code plaatsen?
Ik heb niet veel kennis van javascript maar ik kan je proberen te helpen
Meestal dan wordt geadviseerd om geen lange scripts neer te zetten
ivm het puzzelen voor degene die intresse heeft, vandaar dat ik het
niet meteen gedaan heb, bovendien kun je de broncode van javascript
zien, muv toelichtingen.
Mijn vraag nog even:
Hoe geef ik door aan < PhP > dat ytplayer_playitem += 1; heeft plaat gevonden, zodat ik met PHP mijn query kan runnen en de juiste titel
bij de af te spelen plaat plaats.
Het lijkt makkelijk maar ik kom er na een week puzzelen nog niet uit.
Graag hulp.
Simon
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Java script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir='ltr' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<script type="text/javascript">(function() { var a=window;function e(b){this.t={};this.tick=function(c,h,d){d=d?d:(new Date).getTime();this.t[c]=[d,h]};this.tick("start",null,b)}var f=new e;a.jstiming={Timer:e,load:f};try{a.jstiming.pt=a.gtbExternal&&a.gtbExternal.pageT()||a.external&&a.external.pageT}catch(g){};a.tickAboveFold=function(b){b=b;var c=0;if(b.offsetParent){do c+=b.offsetTop;while(b=b.offsetParent)}b=c;b<=750&&a.jstiming.load.tick("aft")};var i=false;function j(){if(!i){i=true;a.jstiming.load.tick("firstScrollTime")}}a.addEventListener?a.addEventListener("scroll",j,false):a.attachEvent("onscroll",j); })();</script>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<meta content='true' name='MSSmartTagsPreventParsing'/>
<meta content='blogger' name='generator'/>
<script src='http://www.google.com/jsapi?key=ABQIAAAAuKnU_3Y6OoNPPF63588UERTCQmaY7SjunPdllvuTQyzwJBHwVhTnyQstcdx0PZudnYQGuqmKe40jBQ' type='text/javascript'></script>
<script type='text/javascript'>google.load("jquery", "1.3");</script>
<script type='text/javascript'>var gBlogPageType = "item";</script>
</pre>
<div class="demo-canvas">
<div style="float: left; width: 440px; height: 360px;">
<a name="ytplayer"></a>
<div id="ytplayer_div1">You need Flash player 8+ and JavaScript enabled to view this video.</div>
</div>
<div style="float: left; width: 140px; height: 360px; overflow-y: scroll;">
<div id="ytplayer_div2"></div>
</div>
<br style="clear: both;" />
<br style="clear: both;" />
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js"></script>
<script type="text/javascript">
//
// YouTube JavaScript Player With Playlist
// http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
// Revision 1 [2009-10-12]
//
// Prerequisites
// 1) Create following elements in your HTML:
// -- a) ytplayer: a named anchor
// -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
// -- c) ytplayer_div2: container div for playlist
// 2) Include SWFObject library from http://code.google.com/p/swfobject/
//
// Variables
// -- ytplayer_playlist: an array containing YouTube Video IDs
// -- ytplayer_playitem: index of the video to be played at any given time
//
var ytplayer_playlist = [ ];
var ytplayer_playitem = 0;
swfobject.addLoadEvent( ytplayer_render_player );
swfobject.addLoadEvent( ytplayer_render_playlist );
function ytplayer_render_player( )
{
swfobject.embedSWF
(
'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ] + '&enablejsapi=1&rel=0&fs=1',
'ytplayer_div1',
'425',
'344',
'8',
null,
null,
{
allowScriptAccess: 'always',
allowFullScreen: 'true'
},
{
id: 'ytplayer_object'
}
);
}
function ytplayer_render_playlist( )
{
for ( var i = 0; i < ytplayer_playlist.length; i++ )
{
var img = document.createElement( "img" );
img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[ i ] + "/default.jpg";
var a = document.createElement( "a" );
a.href = "#ytplayer";
//
// Thanks to some nice people who answered this question:
// http://stackoverflow.com/questions/1552941/variables-in-anonymous-functions-can-someone-explain-the-following
//
a.onclick = (
function( j )
{
return function( )
{
ytplayer_playitem = j;
ytplayer_playlazy( 1000 );
};
}
)( i );
a.appendChild( img );
document.getElementById( "ytplayer_div2" ).appendChild( a );
}
}
function ytplayer_playlazy( delay )
{
//
// Thanks to the anonymous person posted this tip:
// http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
//
if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
{
window.clearTimeout( ytplayer_playlazy.timeoutid );
}
ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
}
function ytplayer_play( )
{
var o = document.getElementById( 'ytplayer_object' );
if ( o )
{
o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ] );
}
}
//
// Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
// * Sets up handler for other events
//
function onYouTubePlayerReady( playerid )
{
var o = document.getElementById( 'ytplayer_object' );
if ( o )
{
o.addEventListener( "onStateChange", "ytplayer_statechange" );
o.addEventListener( "onError", "ytplayer_error" );
}
}
//
// State Change Handler
// * Sets up the video index variable
// * Calls the lazy play function
//
// Simon ik heb hier niets veranderd maar hieronder staat iets waar ik wat mee kan doen
function ytplayer_statechange( state )
{
if ( state == 0 )
{
<?php $speelnummer= $speelnummer +1 ; // TOEGEVOEGD DOOR SIMON ?>
ytplayer_playitem += 1;
ytplayer_playitem %= ytplayer_playlist.length;
ytplayer_playlazy( 5000 );
}
}
//
// Error Handler
// * Sets up the video index variable
// * Calls the lazy play function
//
function ytplayer_error( error )
{
if ( error )
{
<?php // $speelnummer= $speelnummer +1 ; // TOEGEVOEGD DOOR SIMON ?>
ytplayer_playitem += 1;
ytplayer_playitem %= ytplayer_playlist.length;
ytplayer_playlazy( 5000 );
}
}
//
// Add items to the playlist one-by-one
//
// ytplayer_playlist.push( '5VCj9sbMKQA' );ytplayer_playlist.push( '8RHrHbcmlmw' );ytplayer_playlist.push( 'mdz08PSqOo8' );ytplayer_playlist.push( 'cznha2YTTh0' );ytplayer_playlist.push( 'fOKMxMjc8Mk' );ytplayer_playlist.push( '0kz3X3NmIuY' );ytplayer_playlist.push( 'JRm3TpxBFik' );
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir='ltr' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<script type="text/javascript">(function() { var a=window;function e(b){this.t={};this.tick=function(c,h,d){d=d?d:(new Date).getTime();this.t[c]=[d,h]};this.tick("start",null,b)}var f=new e;a.jstiming={Timer:e,load:f};try{a.jstiming.pt=a.gtbExternal&&a.gtbExternal.pageT()||a.external&&a.external.pageT}catch(g){};a.tickAboveFold=function(b){b=b;var c=0;if(b.offsetParent){do c+=b.offsetTop;while(b=b.offsetParent)}b=c;b<=750&&a.jstiming.load.tick("aft")};var i=false;function j(){if(!i){i=true;a.jstiming.load.tick("firstScrollTime")}}a.addEventListener?a.addEventListener("scroll",j,false):a.attachEvent("onscroll",j); })();</script>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<meta content='true' name='MSSmartTagsPreventParsing'/>
<meta content='blogger' name='generator'/>
<script src='http://www.google.com/jsapi?key=ABQIAAAAuKnU_3Y6OoNPPF63588UERTCQmaY7SjunPdllvuTQyzwJBHwVhTnyQstcdx0PZudnYQGuqmKe40jBQ' type='text/javascript'></script>
<script type='text/javascript'>google.load("jquery", "1.3");</script>
<script type='text/javascript'>var gBlogPageType = "item";</script>
</pre>
<div class="demo-canvas">
<div style="float: left; width: 440px; height: 360px;">
<a name="ytplayer"></a>
<div id="ytplayer_div1">You need Flash player 8+ and JavaScript enabled to view this video.</div>
</div>
<div style="float: left; width: 140px; height: 360px; overflow-y: scroll;">
<div id="ytplayer_div2"></div>
</div>
<br style="clear: both;" />
<br style="clear: both;" />
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js"></script>
<script type="text/javascript">
//
// YouTube JavaScript Player With Playlist
// http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
// Revision 1 [2009-10-12]
//
// Prerequisites
// 1) Create following elements in your HTML:
// -- a) ytplayer: a named anchor
// -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
// -- c) ytplayer_div2: container div for playlist
// 2) Include SWFObject library from http://code.google.com/p/swfobject/
//
// Variables
// -- ytplayer_playlist: an array containing YouTube Video IDs
// -- ytplayer_playitem: index of the video to be played at any given time
//
var ytplayer_playlist = [ ];
var ytplayer_playitem = 0;
swfobject.addLoadEvent( ytplayer_render_player );
swfobject.addLoadEvent( ytplayer_render_playlist );
function ytplayer_render_player( )
{
swfobject.embedSWF
(
'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ] + '&enablejsapi=1&rel=0&fs=1',
'ytplayer_div1',
'425',
'344',
'8',
null,
null,
{
allowScriptAccess: 'always',
allowFullScreen: 'true'
},
{
id: 'ytplayer_object'
}
);
}
function ytplayer_render_playlist( )
{
for ( var i = 0; i < ytplayer_playlist.length; i++ )
{
var img = document.createElement( "img" );
img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[ i ] + "/default.jpg";
var a = document.createElement( "a" );
a.href = "#ytplayer";
//
// Thanks to some nice people who answered this question:
// http://stackoverflow.com/questions/1552941/variables-in-anonymous-functions-can-someone-explain-the-following
//
a.onclick = (
function( j )
{
return function( )
{
ytplayer_playitem = j;
ytplayer_playlazy( 1000 );
};
}
)( i );
a.appendChild( img );
document.getElementById( "ytplayer_div2" ).appendChild( a );
}
}
function ytplayer_playlazy( delay )
{
//
// Thanks to the anonymous person posted this tip:
// http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
//
if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
{
window.clearTimeout( ytplayer_playlazy.timeoutid );
}
ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
}
function ytplayer_play( )
{
var o = document.getElementById( 'ytplayer_object' );
if ( o )
{
o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ] );
}
}
//
// Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
// * Sets up handler for other events
//
function onYouTubePlayerReady( playerid )
{
var o = document.getElementById( 'ytplayer_object' );
if ( o )
{
o.addEventListener( "onStateChange", "ytplayer_statechange" );
o.addEventListener( "onError", "ytplayer_error" );
}
}
//
// State Change Handler
// * Sets up the video index variable
// * Calls the lazy play function
//
// Simon ik heb hier niets veranderd maar hieronder staat iets waar ik wat mee kan doen
function ytplayer_statechange( state )
{
if ( state == 0 )
{
<?php $speelnummer= $speelnummer +1 ; // TOEGEVOEGD DOOR SIMON ?>
ytplayer_playitem += 1;
ytplayer_playitem %= ytplayer_playlist.length;
ytplayer_playlazy( 5000 );
}
}
//
// Error Handler
// * Sets up the video index variable
// * Calls the lazy play function
//
function ytplayer_error( error )
{
if ( error )
{
<?php // $speelnummer= $speelnummer +1 ; // TOEGEVOEGD DOOR SIMON ?>
ytplayer_playitem += 1;
ytplayer_playitem %= ytplayer_playlist.length;
ytplayer_playlazy( 5000 );
}
}
//
// Add items to the playlist one-by-one
//
// ytplayer_playlist.push( '5VCj9sbMKQA' );ytplayer_playlist.push( '8RHrHbcmlmw' );ytplayer_playlist.push( 'mdz08PSqOo8' );ytplayer_playlist.push( 'cznha2YTTh0' );ytplayer_playlist.push( 'fOKMxMjc8Mk' );ytplayer_playlist.push( '0kz3X3NmIuY' );ytplayer_playlist.push( 'JRm3TpxBFik' );
Gewijzigd op 01/01/1970 01:00:00 door simon
(En er zijn hier wel meer mensen dan Erik Rijk, die wel javascript kunnen.)
Sorry ik wist niet dat het moest (ben een newbee).
Ik snap het nu!!
Simon Buijs
Gewijzigd op 01/01/1970 01:00:00 door simon
Wat moest?
Wat snap je nu?
Ik heb het aangepast
Sorry voor mijn domme vraag.
Simon