Page 1 of 1

Flash to PHP to Flash service

Posted: Tue Oct 03, 2006 9:16 pm
by Artist 3D
I need to have a small PHP file that sits on the main folder of a site and retrieves my flash site a desired MP3's duration. I understand that PHP creates XML or HTML and that flash calls PHP by the getURL command.

I know nothing about PHP programing (aware that the rules asks for it, so excuse me), but I guess that extracting only the duration code from a requested /some_directories/MP3 file isn't that complicated.

So, can anyone help me here please?

Posted: Tue Oct 03, 2006 11:47 pm
by Allan Hansen
Yes it is rather simple matter.

Check demo.basic.php in the demos directory.

Posted: Wed Oct 04, 2006 8:55 am
by Artist 3D
Nice, this file does look much more simple then the others. So if I understand it write, the code should be like this:

Code: Select all

<?php
require_once('../getid3/getid3.php');
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
getid3_lib::CopyTagsToComments($ThisFileInfo);
echo @$ThisFileInfo['duration'];    
?>
Am I right? is it duration that I need to put there instead of their examples?

Now, let say the file name is mp3_duration.PHP

How do I call the PHP?
It's my 1st time calling a PHP, but this is my guess: getURL ("mp3_duration.php /tracks/rock/song.mp3");

And final question, so this code will create an mp3_duration.xml file that contains only the duration?

Posted: Wed Oct 04, 2006 9:26 am
by Allan Hansen
Although you have read the rules, I will quote some of them anyway:

1. This is a getID3() support forum. We (the developers, who each have spent 1000+ unpaid man hours on this project) would like to hear from our users and fix possible bugs.

2. This is not a general PHP forum. There are other places on the net that provides services.

3. Some programming and PHP skills required. Programming is a way of earning the daily bread, just like carpentering, only slightly different.

You either need to learn PHP or to find a PHP programmer to help you solve this problem. Alternatively you could befriend the developers by putting, say $100, in the donation box.

Posted: Thu Oct 05, 2006 9:02 am
by Artist 3D
Ah, it doesn't matter anymore, I've found out my host doesn't support id3 tags (it's a free host, and it's a small site as a student, with all the good will, i can't afford paying 100$, which is a full day work for me, and all that for a small feature in my whole site, that I already waste alot of hours to build it). - I'll pass to a non-dynamic XML... it's not that I have so many files...

But thanks anyway, specially for your patience.

Posted: Sat Oct 07, 2006 9:36 am
by MsTiFtS
Just to prevent confusion:
Your host doesn't need to support ID3, it just needs to support PHP.
If it doesn't, you need to get some. There is enough php-capable webspace around, most of the providers don't allow storing mp3s, though.
If you want do do further stuff with php, I strongly recommend you reading a tutorial.
Your code above wasn't that bad, though, just a few small mistakes.

Code: Select all

<?php
require_once('../getid3/getid3.php');
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($_GET["filename"]);
echo "<xml-whatever-you-want>".$ThisFileInfo['playtime_string']."</xml>";
?>
This will return you <xml-whatever-you-want>3:57</xml> or similar, you can just replace that xml stuff with whatever you need, escape " as \"
If you want the playtime as a count of seconds, replace playtime_string with playtime_seconds and you will get something like 236.752375
To call it, use something like this:
getURL("mp3_duration.php?filename=%2Ftracks%2Frock%2Fsong.mp3");
To escape the slashes use the flash equivalent of http://php.net/urlencode
I'm pretty sure there is one.
For further information, please refer to http://php.net as a reference and some tutorials and PHP forums. Allan is right, this isn't the right place for questions like that. I hope I have helped you anyway.

If you are further interested in php, have read a tutorial or two and still don't understand something, feel free to contact me at mstifts@gmx.de, I will then decide whether I have time to answer it or not, but please leave this poor forum alone ;)

Posted: Sat Oct 07, 2006 5:00 pm
by Artist 3D
Wow! I'm speechless, you are an angel in an area that not a many willed to help me. I didn't try your help, though it's exactly what I need. Unfortunately, a friend of a friend tried to help me, and we got to the conclusion that though they support PHP (my host), they don't somehow reject id3 code. I asked them by e-mail and got the following reasons for that:

1. being afraid to illegal music casting (I'm a designer, yet I do music for fun, so this is what I want to put in my site).

2. they want to avoid people to make their 300MB as a file host service

3. they want to keep the bandwidth usage low, and as you know, streaming services need a lot of that, and if a site uses PHP, it means it gives a wide service (or his owner is a wako like me :P )

Anyway, I will try your PHP, even though I'm skeptic. And yes, I got this fact that I'm in the wrong forum, sorry for the mess from all those who suffer from it ;)

Posted: Sat Oct 07, 2006 5:18 pm
by MsTiFtS
I don't think that there is ANY possibility to block getID3, but there php has it's own integrated ID3 functions, I bet they blocked these. So try it, it should work even though they think they blocked it. If it doesn't work, it will at least spit out some sort of an error message, which will help hunting down the issue.
PLEASE answer only by email (see above) as this really is the wrong place for this discussion!

Posted: Sat Oct 07, 2006 9:17 pm
by James Heinrich
However, if a host has somehow blocked getID3() for whatever reason, I would like to hear about it here.

Posted: Sat Oct 07, 2006 9:35 pm
by Artist 3D
No, it was my mistake. the error included 2 parts:

Code: Select all

Array
(
    [warning] => Array
        (
            [0] => WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.
        )

    [error] => Array
        (
            [0] => getid3.lib.php is missing or corrupt
        )

)
Don't know how, I missed the 2nd part :P

Posted: Sun Oct 08, 2006 7:50 am
by MsTiFtS
James Heinrich wrote:However, if a host has somehow blocked getID3() for whatever reason, I would like to hear about it here.
I bet they blocked the PHP integrated ID3 functions by some php.ini setting ;)
I can't imagine any way to block this library without hacking php source to reject files with a certain name or hash ;) Which wouldn't work very long, too...
I'll stay in touch with artist3d and will tell you if they really blocked something. From the messages the scripts produced I guess that he just didn't upload all files.

Posted: Sun Oct 08, 2006 8:17 am
by Allan Hansen
MsTiFtS wrote: I bet they blocked the PHP integrated ID3 functions by some php.ini setting ;)
That is impossible. The integrated ID3 thing is not integrated at all. It comes as PHP source.

Posted: Sun Oct 08, 2006 8:21 am
by MsTiFtS
Right, it's a PEAR package. Then I think they just wanted to scare artist3d ;)
Until now nothing happened there that would point to some restriction beside safe mode of course.

Posted: Tue Oct 10, 2006 7:41 pm
by MsTiFtS
We've got it to work now, and none of the problems point to the provider blocking something. There were just some small mistakes like missing or not found files, a leading slash in paths which should have been relative and so on...
So I think the provider really thought that artist3d would give up if it doesn't work and they say they blocked it.

Posted: Wed Oct 11, 2006 12:49 pm
by Artist 3D
Now everything works just fine thanks to MsTiFtS, so I'm back to struggle with action script to make the whole system work. I must admit that that small PHP part was the biggest problem I had in this project, and of course it's all because of my lack of knowledge in PHP. (mostly it would take a day for such thing).