manipulating playlist using php

Ask Questions or make comments about Mp3 Toolbox
Post Reply
radiocor
Posts: 17
Joined: Wed Feb 23, 2005 1:12 am
Contact:

manipulating playlist using php

Post by radiocor » Fri Mar 25, 2005 5:49 am

I have got mp3 toolbox working a treat after changing hosting companies. It is fantastic and I\'m trying to add some nifty php functionality to the playlist configuration.

There are a few problems and I hope you can help.

First I thought it would be great to make the playlist time sensitive. Using

Code: Select all

php Date ()
worked - got an

Code: Select all

else if
sequence and I can get a different start point according to the server time. It adds a whole new realm to the radio stream.

Then I though about getting the users local day and time using some simple javascript and setting the values in cookies. Hey we\'re now talking timezone free here - it would make a really neat feature. I can see all sorts of possiblities with it.

That part was easy. The cookie values I\'m able to get into php using

Code: Select all

$hour =($_COOKIE[\'playlisthour\']); 
and have done all sorts of things to check it works fine.

However when trying using it in the mp3 toolbox script, or calling it in from anywhere else and doing all the things you are meant to be able do with php, it refuse to work.

Tried alternatives too

Code: Select all

S_GET
and

Code: Select all

S_REQUEST
or

Code: Select all

import_request_variables("c", "a_");
etc. etc. etc. and they works everywhere else. Basically I can do anything except what I want to do.

Is there anything you can suggest that I can do, hack, add or change, that will get those cookie values in there. I\'m so excited with the local time idea and I\'m so close..........

Globals are set to off by the way.

I\'m only testing at the moment on my live server and don\'t have the

Code: Select all

$hour =($_COOKIE[\'playlisthour\']); 
in the script there. But you can see that the cookies work fine. Clicking on the start player button sets them.

http://www.amsterdamonair.net/

Any help would be gratefully appreciated - since finding out it won\'t work I\'ve been sitting with it for over 24 hours non-stop Googling and trying fixes! It\'s a small but I think powerful addition to the mp3 toolbox radio function - when I make it work.

User avatar
Jay
Will work for food (Administrator)
Posts: 2867
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Post by Jay » Fri Mar 25, 2005 10:26 am

without any reference to any errors I am not sure why it wouldn't work, as long as the cookies are being set properly and in the scope of mp3 toolbox's directory then all of php's attempts to access cookie information should work. You could try pulling the stream up in your browser and turning off the user-agent protection and see if any php errors are displayed.
- Jay

radiocor
Posts: 17
Joined: Wed Feb 23, 2005 1:12 am
Contact:

Post by radiocor » Fri Mar 25, 2005 10:40 am

Certainly I\'ll do it right now. The only thing is can you just explain how to do that exactly?

I\'ll get on to it straight away and post the results. Sorry to sound so eager and bother you like this, but I\'ve got so excited at the prospect at getting this to work and you have given me exactly the right encouragement -
as long as the cookies are being set properly and in the scope of mp3 toolbox\'s directory then all of php\'s attempts to access cookie information should work.
Gotta get it going now - when I do I\'ll send it over to you - it might prove useful to others. I certainly have ideas with it.

Jay you do know your stuff. [/quote]

User avatar
Jay
Will work for food (Administrator)
Posts: 2867
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Post by Jay » Fri Mar 25, 2005 10:49 am

remove 'Mozilla' from the agent block in the config file then go to the stream address in your browser rather then in your player. To see the stream.
- Jay

radiocor
Posts: 17
Joined: Wed Feb 23, 2005 1:12 am
Contact:

Post by radiocor » Fri Mar 25, 2005 11:12 am

The mp3toolbox_conf.php? I just went there and it was set as nothing so I set it as this, based on what you had written above.

Code: Select all

$agent_block = \\\"Mozilla\\\";
Having said that the link pasted in the browser afterwards just spat out a pls for me to open or download. I think I may have down the wrong thing somwhere. Sorry to sound so thick, but can you point me a bit more.

If you ever come to Amsterdam I promise I\\\'ll make it up to you with lots of thick Dutch beer.

radiocor
Posts: 17
Joined: Wed Feb 23, 2005 1:12 am
Contact:

Post by radiocor » Fri Mar 25, 2005 11:43 am

Ah, just before resetting the agent block I put this into the browser

Code: Select all

http://terry/toolbox/index.php?cmd=radio
(it\'s on my local server at present) and it took me straight to the mp3 toolbox index.php page and not as a .pls

The page was fine and showed no errors.

Here\'s the code I\'m using for the cookie.

Code: Select all

$hour=($_COOKIE[\'playlisthour\']);

if ($a_hour <= \"15\"){
$playlist_scr[0] = $source_dir[0].\"/dump_1\";
$playlist_scr[1] = $source_dir[0].\"/promos\";
$playlist_scr[2] = $source_dir[0].\"/dump_1\";
$playlist_scr[3] = $source_dir[0].\"/promos\";
$playlist_scr[4] = $source_dir[0].\"/dump_1\";}
else if ($a_hour <= \"16\"){
$playlist_scr[0] = $source_dir[0].\"/dump_2\";
$playlist_scr[1] = $source_dir[0].\"/promos\";
$playlist_scr[2] = $source_dir[0].\"/dump_2\";
$playlist_scr[3] = $source_dir[0].\"/promos\";
$playlist_scr[4] = $source_dir[0].\"/dump_2\";}
else{
$playlist_scr[0] = $source_dir[0].\"/dump_3\";
$playlist_scr[1] = $source_dir[0].\"/promos\";
$playlist_scr[2] = $source_dir[0].\"/dump_3\";
$playlist_scr[3] = $source_dir[0].\"/promos\";
$playlist_scr[4] = $source_dir[0].\"/dump_3\";}
I haven\'t gone the whole hog yet with the day etc., although I might put the hour in the index.php for the appropriate mp3toolbox_conf.php - assuming it eventually goes okay.

Just done a few more checks and it shows no errors without the cookies being set. I\'ve tested it on text files, same code structure and it does work. Checking the text test without cookies being set show errors, but are fine once I set them.

The cookie paths are set to /

It doesn\'t sound promising does it? But as you rightly say there is no reason why it shouldn\'t work. Hand manipulating the values and it works, it did it with the server date too, so it ought to do it. I have no streaming issues with the way php is set up on either local or live sites.

And I\'m running at home on the new Easyphp1.8

Hope you might have an idea - I\'ve done every tutorial on the internet - all say this should work.

User avatar
Jay
Will work for food (Administrator)
Posts: 2867
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Post by Jay » Fri Mar 25, 2005 12:32 pm

If I were you I would take a step back and just make a single php script for reading and writing cookies and make sure it works there before getting too much into digging around mp3 toolbox.

Be sure that the reading and writing scripts exist in the same directory as you would like it to work in you mp3toolbox setup.
- Jay

radiocor
Posts: 17
Joined: Wed Feb 23, 2005 1:12 am
Contact:

Post by radiocor » Fri Mar 25, 2005 1:10 pm

Oh I've done that, I have working examples,

http://www.amsterdamonair.net/

The Select Player button sets the cookie, takes you to a popup page, where at the moment I''ve placed confirmation script to check the cookies work.

In addition I've replicated the exact same paths I would use for the playlist configuration using a text file output - which only work once the cookie is set.

http://www.amsterdamonair.net/globecast/index.php

Separately I tested mp3 toolbox manually and using php Date(). Putting the one into the other has only come about after being sure what I was doing worked individually - and the idea is exactly not to dig around in the toolbox script. As you say in the conf.php
Place your script here, this is just a simple array of directory paths
Most of what happens is, or can be outside and not inside the actual toolbox script. I hear what your saying, but believe I've learnt the hard way to take it one stage at a time.

Please try the links and have a look at the cookies, it all works logically. Honestly I've done so much work developing what I think is a really sound feature, I just need to get over this last and unexpected hurdle of a long road.

radiocor
Posts: 17
Joined: Wed Feb 23, 2005 1:12 am
Contact:

Post by radiocor » Sat Mar 26, 2005 5:20 am

I think I'm on to a solution. Time and maths.

Thanks for the pointers.

adamwolstenholme
Posts: 1
Joined: Thu Mar 30, 2006 1:53 pm

Post by adamwolstenholme » Thu Mar 30, 2006 2:03 pm

Wow I've been listening to the output of your station. It sounds great!!! I love the fact that everyone can hear the same output. The time features are great too. Well Done! Any chance of helping out some of us that don't know php as you have made a brilliant tool even better!
Adam Wolstenholme

Post Reply