By jesusrocksmyfaceoff on
Hi there - I'm doing something like this:
file_create_url($node->field_audio[0]['filepath'])
which creates a url like this:
http://www.newcreationwoc.org/sites/default/files/audio/2009-08-12.mp3
What I want to do is pull the filename out...
so 2009-08-12.mp3
and then remove the extension
so 2009-08-12
and then add the .flv extension
so 2009-08-12.flv
and then insert that at the end of a completely different url, something like
I know its simple php coding (likely), but I can't figure it out. Can someone please help me out?
Thanks!
Josh Mans
New Creation World Outreach Church
Comments
perhaps something like
perhaps something like this:
Standard warnings apply: I'm typing off the top of my head, so I didn't test the code. It should work, though.
-Corey
file_create_url + print swf() - SWFTools
I'm wondering why the following code does not work. The first part works just fine (the filename changes from .mp3 to .flv). It just doesn't display anything on the page I'm trying to display it on. (I'm embedding it into a theme tpl.php page, so it automatically inserts it on every node of a particular type. Any further advice would be greatly appreciated. THANKS!
Check the documentation
Your use of the swf() function isn't right, and the streaming documentation only refers to using the [swf] syntax so it isn't immediately clear how to do it.
First, the filename is in the wrong place. Take a look at the swf() syntax documentation. The filename doesn't go in the array, but all other settings do.
stream goes in the othervars array, action goes in the methods array, type is a flashvar.
So, without actually testing it I think it should be
Hmmm.. Getting Closer I think...
Thank you SO much, we're getting closer --
This is now my code:
$filename = basename(file_create_url($node->field_audio[0]['filepath']));
$filename = substr($filename, 0, strrpos($filename, '.'));
$filename .= '.flv';
print swf($filename,
array(
'othervars' => array('stream' => 'rtmp://newcreationwoc.flashsvr.com/newcreationwoc/'),
'flashvars' => array('type' => 'rtmp'),
'othervars' => array('methods' => array('action' => 'swftools_flv_display')),
)
);
however, it returns an error - the error that displays when flash cannot display for whatever reason in drupal. I'll keep playing with it and checking the syntax documentation, but, any other ideas?
THANKS SO MUCH!
Josh
My mistake
I didn'g get the code quite right, both methods and stream live in othervars, so I think
is what you need. I'll try and simulate properly later.
Works :-)
Thanks so much!
It works! Now, I would like to tweak this so that if the variable $filename does not exist, it doesn't even display the video at all. Is there an easy way to do that?
THANK YOU SO MUCH AGAIN!
The Drupal Community ROCKS!
Josh
Just use a bit of PHP
Seeing as you are adding your code at a template level you can just wrap the print swf() statement inside an if block. Test to see that a filename is present, if it is then print. If filename is empty you don't to do anything.
Seems simple, but...
Okay, so a simple if (file_exists($filename)) {..... piece of code would ordinarily work. However - the file resides on an external server that does NOT have http access (only rtmp). That's where I'm lost on this one...
Is there a way to check if playing the stream would return a null or not found error, and if it does, not display the player, and if it finds it, then go ahead and display?
thanks again...