Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
This will register the onLoad, onCuepoint and onSeek events. Would be great to get support for all events though.... Anyone know of a way to pass a JavaScript function through Drupal.settings or something?
// ...
var config = Drupal.settings.flowplayer[selector];
// Convert any JavaScript events to function calls.
if (typeof(config['onLoad']) == 'string') {
config['onLoad'] = eval(config['onLoad']);
}
if (config['clip'] && config['clip']['onCuepoint'] && typeof(config['clip']['onCuepoint'][1]) == 'string') {
config['clip']['onCuepoint'][1] = eval(config['clip']['onCuepoint'][1]);
}
if (config['clip'] && typeof(config['clip']['onSeek']) == 'string') {
config['clip']['onSeek'] = eval(config['clip']['onSeek']);
}
// Create the flowplayer element on the non-processed elements.
// ...
Yeah, since Drupal.settings only supports arrays, integers and strings, we're limited to what we can do with it. Using eval seems like the best way to go. #374042: Default Configuration Options required onLoad, so that's in already, just need the rest of the events....
This issue has a 'fixed' status but it's still not clear to me how to add a callback to the flowplayer configuration in a module. The link to the commit that fixed it is broken (points to old cvs repo) so I can't take a look at the code.
Comments
Comment #1
robloachThis will register the onLoad, onCuepoint and onSeek events. Would be great to get support for all events though.... Anyone know of a way to pass a JavaScript function through Drupal.settings or something?
Comment #2
Anonymous (not verified) commentedRob, I'm encountering the same problem too. Neither drupal_to_js nor json_encode (php5) are checking for strings that look like functions.
I found some guidance, but it definitely involves side-stepping drupal_to_js or json_encode.
http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/
I think your method of evaluating the string is a good start. I've also seen some tips that suggest using JS Function objects.
http://www.permadi.com/tutorial/jsFunc/index.html
All of Flowplayer's events are known. Perhaps your method here should be expanded to work on all the known events on clip and player?
Comment #3
Anonymous (not verified) commentedRob, I'm encountering the same problem too. Neither drupal_to_js nor json_encode (php5) are checking for strings that look like functions.
I found some guidance, but it definitely involves side-stepping drupal_to_js or json_encode.
http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/
I think your method of evaluating the string is a good start. I've also seen some tips that suggest using JS Function objects.
http://www.permadi.com/tutorial/jsFunc/index.html
All of Flowplayer's events are known. Perhaps your method here should be expanded to work on all the known events on clip and player?
Comment #4
robloachYeah, since Drupal.settings only supports arrays, integers and strings, we're limited to what we can do with it. Using eval seems like the best way to go. #374042: Default Configuration Options required onLoad, so that's in already, just need the rest of the events....
Comment #5
robloachhttp://drupal.org/cvs?commit=175314
Comment #7
markj commentedThis issue has a 'fixed' status but it's still not clear to me how to add a callback to the flowplayer configuration in a module. The link to the commit that fixed it is broken (points to old cvs repo) so I can't take a look at the code.
Specifically, I'd like to implement the function illustrated on http://flowplayer.org/plugins/streaming/audio.html at "optional: when playback starts close the first audio playback".