Foliovision › Forums › FV Player › How to … › wp_ajax_ do_shortcode
-
-
Hello David,
I’m not sure what could be causing your issue as we use the standard WordPress shortcode API. Are you sure it works with shortcode like [gallery]? Are you sure your working shortcode is not getting some special treatment? You need to use the_content() or apply_filters(), as the shortcodes are not processed otherwise. Then you need to load Flowplayer on the resulting DIV element, similar to what is at the end of the document here: http://foliovision.com/player/api-programming
Thanks,
MartinHi Martin,
thank you for your response. I’ve tried with my custom shortcode, with [gallery ids="2377,2376,2374"] shortcode, and all it’s ok. I don’t understand why with fvplayer shortcode doesn’t work.
My test: when click on link, I call ajax function that return do_shortcode(‘[gallery ids="2377,2376,2374"]‘) and replace div with html response and I see gallery image
When I use do_shortcode(‘[fvplayer src="http://amazonaws.com/test.mp4" width=500 splash="http://site.com/wp-content/uploads/2013/02/videoAnteprima-thumb.png" splashend=show]‘) and replace html, I see shortcode as string and doesn’t convert as video.
I’ve checked that calling floplayer_content_handle() function (/controller/shortcode.php) I get this:
Fatal error: Call to undefined function flowplayer_content_handle() in ajax-functions/init.php on line 57I think that flowplayer doesn’t load in ajax envirovment.
Can you help me? Thank you
Hi Martin,
I did some debig and seems that not all file are loaded in ajax envirovment.
In my ajax call I had to include controller/shortcodes.php but I get
Fatal error: Call to undefined method flowplayer_backend::build_min_player() in /fv-wordpress-flowplayer/controller/shortcodes.php on line 182Then I re-initialized again $fv_fp = new flowplayer_frontend(); in controller/shortcodes.php for testing pourpose and I get splash screen correctly but with error
Admin warning:
I’m sorry, your JavaScript appears to be broken. Please use “Check template” in plugin settings or order our pro support and we will get it fixed for you.Hello David,
you can remove that notice using JavaScript. You need to use JavaScript anyway to initialize Flowplayer on the DIV element which contains the player.
It sounds like an interesting project and I see we could improve this (the backend/frontend stuff could be improved). However currently we are under a heavy load of more end-user features to add.
If you need this resolved quickly or it’s important for your work, we are happy to help you with the coding if you make a donation, or we can incorporate your changes if you are able to do this properly. Are you also sure you absolutely need AJAX here?
Thanks,
MartinHi Martin,
thank you for your response. Soon I’ll buy license for our project.
I need to use ajax to load content but I currently use a loophole like this
$(‘.content’).load($(this).attr(‘href’)+’ .flowplayer’,function(){
jQuery(‘.flowplayer’).flowplayer();
});
And this loophole does work.
But I don’t understand why if I call jQuery(‘.flowplayer’).flowplayer().play(); I get an error: Uncaught TypeError: undefined is not a function
If I use this after jQuery(‘.flowplayer’).flowplayer()
var api = flowplayer();
api.bind(‘ready’, function() {
alert( ‘Video just started!’ );
});
I doesn’t see alertThank you
Hi Martin,
Ok I’ve understand that with this method I can play video
jQuery(‘.flowplayer’).flowplayer();
var api = flowplayer();//with this we get first instance of player
api.load(); //play videoapi.play() //not load video
jQuery(‘.flowplayer’).flowplayer().load() //return error undefinedif I’ve more info I share here
Hello David,
working with load() and play() is not always so obvious, as it works a bit differently for iPad etc.
Following should play any video you insert in JavaScript:
jQuery('#your-player-element').flowplayer();
var api = jQuery('#your-player-element').data('flowplayer');
api.load();Thanks,
Martin