Hi,
while I search the net for hints I leave this here, probably you will be
faster than me finding an answer.
The next:
I have a static site where I embed a player using an external js
The html:
The JS:
if(navigator.userAgent.indexOf(“Opera”)!=-1){
document.write(’
’);
document.write(’’);
document.write(’’);
document.write(’’);
document.write(’’);
document.write(’
’);
}
else if(navigator.userAgent.indexOf(“Firefox”)!=-1){
document.write(’
’);
document.write(’’);
document.write(’’);
document.write(’’);
document.write(’<embed src=“file.mid” type=“application/x-mplayer2”
width=“184” "height=“45” autostart=“0”>’);
document.write(’’);
document.write(’
’);
}
else {
document.write(’
’);
document.write(’’);
document.write(’’);
document.write(’’);
document.write(’’);
document.write(’
’);
}
So when the page loads it uses that js to embed the player.
My question:
-
I want to have a template js (or rjs?) where I can modify the file to
be played dynamically. What do you think is the best approach with Ruby
on Rails/AJAX?
-
As you can see I take care of browsing checking, maybe there is some
ready made functions in AJAX for this, or even for player embedding (?)
Thanks in advance!
you should wrap that code in a function that you can pass the filename
and call the function the layout/view, maybe in the header:
<%= javascript_tag
“my_player_function(‘#{@my_ruby_variable_with_filename_for_player}’)”
%>
then you just have to set @my_ruby_variable_with_filename_for_player
somwhere in you controller, like the current action or a before_filter
(don’t know what you need, depends on your goal here)
On 29 Nov., 19:44, comopasta Gr [email protected]
Thanks Thorsten! I will try that very soon.
Uuff, I didn’t even have time to open my browser to continue searching
the net. That was indeed quick!
Cheers!
Excellent!! It worked just beautifully.
Btw the embedding I made works fine on Windows with Opera, Explorer,
Netscape and Firefox. I also add a direct link to download the audio
file for the Linux users since I can’t test on Linux.
Is there a quick hint to get the same script working on Linux? Not a
critical thing though.
Thanks again!
you could test on linux by:
A) booting into a live cd (heaps available on the net).
B) running linux in a VM (just download a prebuilt one for your VM
software
of choice).
C) use the live CD in an existing VM if you have one (save building
one).
If you don’t have an VM software installed I can recommend VirtualBox,
it’s
free and available for Windows, Mac & Linux hosts.
If the “MediaPlayer” referred to in your script is the Windows Media
Player
then it will only work in Windows however and not on Linux or Mac. You
would
want to investigate using a Flash based player for the most
compatibility.
Cheers,
Anthony
Anthony R. wrote:
You would want to investigate using a Flash based player for the most
compatibility.
Yeah flash as always been an option. And a new topic to learn 
I found this site http://kennybellew.com/tutorial/ with very good
information. Probably when I finish the current basic tasks I can jump
into that. It is a very basic player I need, but I’m not sure yet if
flash can play midi…
Thanks