Welcome Guest, Not a member yet? Register   Sign In
xml question - pulling data from a database
#1

[eluser]got 2 doodle[/eluser]
Hi all , I'm just looking for a little direction here. I am working on my second CI app and as much as I am understanding how to work with CI and am still not 100% on how CI 'works'

I want to use a mp3 media player that loads a play list from an .xml file. I have proven that I can simply substitute a .php file to output xml with this code.

playlist.php
Quote:<?php
$xmlhead='<?xml version="1.0" encoding="UTF-8"?>';
$xml = <<<EOT
<playlist version="1"
>
<trackList>
<track>
<location>../../assets/mp3/1/ColdWarDemo.mp3</location>
&lt;title&gt;Cold War&lt;/title&gt;
<creator> Henderson</creator>
<image>../../assets/images/artistimage/1/rachael.jpg</image>
</track>
<track>
<location>../../assets/mp3/1/CryMeARiver.mp3</location>
&lt;title&gt;Don't Cry me a River&lt;/title&gt;
<creator>Dave Duval</creator>
<image>../../assets/images/artistimage/1/hector.jpg</image>
</track>
<track>
<location>../../assets/mp3/1/UandI.mp3</location>
&lt;title&gt;U and I&lt;/title&gt;
<creator>Jeff Benetti</creator>
<image>../../assets/images/artistimage/1/jeff.jpg</image>
</track>
</trackList>
</playlist>
EOT;
echo $xmlhead.$xml;
?&gt;
this was down and dirty but it would be easy to pull data from a database and format it accordingly.

code to load playlist into media player
Code:
[removed]
        // &lt;![CDATA[

        var so = new SWFObject("http://localhost/nsbands.com/assets/mediaplayer/ep_player.swf", "ep_player", "269", "226", "9", "#000000");
        so.addVariable("skin", "http://localhost/nsbands.com/assets/mediaplayer/skins/nobius_platinum/skin.xml");
        so.addVariable("playlist", "playlist.php");
        so.addVariable("autoplay", "false");
        so.addVariable("shuffle", "false");
        so.addVariable("repeat", "false");
        so.addVariable("buffertime", "1");
        so.addParam("allowscriptaccess", "always");
        so.write("mediaplayer");

        // ]]>
[removed]

So this works but this was straight (X)HTML and PHP.

In CI I have worked with the models/ controllers and views to build views but how would I access a database using CI, I cannot just put the XML into a variable, it seems that the player requires me to point to a file.

This doesn't work
Code:
so.addVariable("playlist", "$playlist");

I'm just having a little trouble conceptualizing how I am going to do this.

The application will have a list of mp3 files associated with a certain band, each band will have an id - pretty typical stuff I think. It's no problem to get a list of mp3's from a model but this is returned to my controller and then to my view.

How do I get this information when the player wants to point to a file? Do I just step aside from all of CI's power and make playlist.php access the database? Do I use a controller?

I am planning to use the url segment to track the id of the band

http://localhost/nsbands.com/index.php/bands/artist/4 example for band id=4



Hmm....thinking......

doodle

Thanks in advance
#2

[eluser]got 2 doodle[/eluser]
Update to previous post, what I meant was

This doesn't work
Code:
so.addVariable("playlist", "&lt;?php echo $xmlhead.$xml;?&gt;");

Maybe I am making things more difficult than it needs to be, probably just as well to put a separate playlist file in each bands directory.

Hmm....thinking...
doodle
#3

[eluser]Chris Newton[/eluser]
I use CI + Flash frequently. Rather than calling playlist.php, I just call something like playlist_controller/playlist_method

So yeah, a controller calls the database, based on the parameter passed in (in my case, I use controllers+models+views)
#4

[eluser]got 2 doodle[/eluser]
Excellent and thanks,

I'll see what I come up with.

doodle




Theme © iAndrew 2016 - Forum software by © MyBB