Welcome Guest, Not a member yet? Register   Sign In
Serving XML file to videoplayer fails
#1

[eluser]mvdg27[/eluser]
Hi,

I'm working on a solution to display video's on a website, using a videoplayer created by Jeroen Weijering (jeroenweijering.com). This player accepts XML files as a playlist. Now I'd like to dynamically create XML files from my database with CodeIgniter.

The XML is correctly created, but fails to load in the player. When I use a single php page with direct DB access everything works fine. Also when I copy the output of my script to an xml file and point to that, no problem occurs. So the script is correct, I imagine. I'm thinking it may be a headers problem? Or the player doesn't understand the url I'm supplying.

Anyway, the code I use to create the XML file:
Code:
// database stuff her ... captures result query in data['videos']

$charset = "utf-8";
$mime = (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) ? "application/xhtml+xml" : "text/html";

$this->output->set_header("content-type:$mime;charset=$charset");
$this->load->view('xml', $data);

And my reference to the playlist file in the javascript
Code:
s1.addVariable('file','<?=site_url()?>/player/play/1/10');

Hope anyone has an idea on how to solve this!

Cheers, Michiel
#2

[eluser]helmutbjorg[/eluser]
Did you end up solving this?
#3

[eluser]mvdg27[/eluser]
Hi,

I ended up solving it, but not in the way I wanted it initially. We decided to simply create actual XML files, whenever the playlist was changed. And in the player we point directly to this XML file.

Maybe this way is even more efficient, since it doesn't need to do the operation each time the xml file is requested, but only when it's actually necessary (i.e. when there is a change in the file).

Cheers, Michiel
#4

[eluser]helmutbjorg[/eluser]
Thanks for the quick response. I have found that when third party flash scripts try to load an external xml file they append some GET vars to the end to restrict caching so if i tell it to load the following file:

Code:
/codeigniter/controller/xml

what it ends up being is

Code:
/codeigniter/controller/xml?c=2546525

And codeigniter therefore displays a 404. It seems to always display a 404 when the url contains a string and a equals sign. I have tried adding a route to bypass it like so

Code:
$routes['controller/xml(:any)'] = 'controller/xml';

but that didn't work...

Could that explain your problem?
#5

[eluser]helmutbjorg[/eluser]
I fixed it!!

Apparently it wont throw a 404 if more than one GET var is appended (who the hell knows why).

So I specified the codeigniter dynamic xml file like so

Code:
/codeigniter/controller/xml?hello=world&

And you don't even need the route. Hope that helps you too.
#6

[eluser]mvdg27[/eluser]
Well, I think my problem was caused by the same thing .. but I didn't figure it out at that point.

Basically I wanted to load an xml file to a flash player. When I was pointing to an existing xml file, everything would work fine, and when I changed it to a dynamicly create file, it wouldn't work. Since we were facing a deadline, I decided to use the work-around explained above.

When I see you analysis, I think it could be solved as easy as allowing get variables in a URL. I think there is a setting for this in the codeigniter config file. I think it was URI protocol.

Hope that helps you.
#7

[eluser]mvdg27[/eluser]
I see you got it working already! Good stuff!

Another thing that crossed my mind is that the GET variable 'c' may be interpreted as a reference to a (non-existent) controller, when you have query string enabled (http://ellislab.com/codeigniter/user-gui.../urls.html)

Michiel
#8

[eluser]helmutbjorg[/eluser]
Anyway, at least we know know for the future that loading xml files in a third party flash component that variables will be added to the url and could cause a 404. One bug at a time hey...
#9

[eluser]mvdg27[/eluser]
Exactly! Definitely good to know for future reference. Kudos for figuring it out!




Theme © iAndrew 2016 - Forum software by © MyBB