Help with PHP + JSON Playlist (Projekktor Core)
Hey,
I've been attempting to implement loading a playlist via JSON from a PHP script., and am having trouble getting it to work.
When I use this snippet, everything is peachy:
projekktor('#featured-video-preview', {
playlist: [{0:{src: [{0:{src:"http://www.myurl.com/wp-content/uploads/2012/07/test-video.mp4", type:"video/mp4"}}], type:"text/json"}}],
playerFlashMP4: 'http://www.myurl.com/wp-content/plugins/my-plugin/js/projekktor/jarisplayer.swf',
playerFlashMP3: 'http://www.myurl.com/wp-content/plugins/my-plugin/js/projekktor/jarisplayer.swf',
controls: true,
debug: true,
width: 260,
height: 250
});But when I try this, it doesn't work:
projekktor('#featured-video-preview', {
playlist: [{0:{src: [{0:{src: ajaxurl +"?action=show_playlist", type:"video/mp4"}}], type:"text/json"}}],
playerFlashMP4: 'http://www.myurl.com/wp-content/plugins/my-plugin/js/projekktor/jarisplayer.swf',
playerFlashMP3: 'http://www.myurl.com/wp-content/plugins/my-plugin/js/projekktor/jarisplayer.swf',
controls: true,
debug: true,
width: 260,
height: 250
});The following is what's being received from the php script:
{"1":{"title":"Test Video","file":[{"src":"http:\/\/www.myurl.com\/wp-content\/uploads\/2012\/07\/test-video.mp4","type":"video\/mp4"}]}}In the debug, it looks like everything is coming through okay:
["Update: 'modelReady", [Object { src="Test Video", type="none/none", quality="default"}, [Object { src="http://www.myurl.com...07/test-video.mp4", type="video/mp4"}]], "NA", undefined]
But when I attempt to play the video, this is what pops up in debug (note the error at the end):
[ "Update: 'state" , [Object { src= "Test Video" , type= "none/none" , quality= "default" }, [Object { src= "http://www.myurl.com...07/test-video.mp4" , type= "video/mp4" }] ] , "NA" , "ERROR" ]
Along with a message in the player that says:
"Sorry, Your browser does not support the media format of the requested file."
The thing is, I know that it DOES work, because it does in the first example, and it's a simple MP4 video.
I've even tried echoing [{0:{src:"http://www.myurl.com/wp-content/uploads/2012/07/test-video.mp4", type:"video/mp4"}}] from my php script to achieve identical results to what I CAN get working and it throws an error from the json parsing.
Any insights or solutions would be greatly appreciated. Am I missing something obvious or should it be working with the current json_encode?
Thank you for your help!
PS. It would be amazing if the documentation on remote json requests was more robust including working json_encode examples.
Complete thread:
- Help with PHP + JSON Playlist - jwondrusch, 2012-07-31, 20:27
![Open whole thread [*]](templates/default/images/complete_thread.png)
- [solved] Help with PHP + JSON Playlist - jwondrusch, 2012-07-31, 22:44
![Show preview […]](templates/default/images/ajax_preview.png)
- [solved] Help with PHP + JSON Playlist - jwondrusch, 2012-07-31, 22:44
