/    Sign up×
Community /Pin to ProfileBookmark

Embedding Selected Audio for Blogs

Hello,

I have done a fair amount of ASP but never any Javascript. I’m not really sure what language I need to start at to learn to embed a drop down selection which will auto-populate the embed string below, so that a drop the correct song loads WITHOUT sending the user to a new url., ie, loading the song without actual form submission.

[COLOR=Blue]<select name=song>
<option value=song1>Johnny Cash – When The Man Comes Around</option>
<option value=song2>Blue Oyster Cult – Godazilla</option>
<option value=[COLOR=Red]song3[/COLOR]>Crosby Stills & Nash – Almost Cut My Hair</option>
</select>[/COLOR]

Now, let’s assume the user selects song3…

Embedded Code below is static with the <%=song%> string being the dynamic variable.:

[COLOR=Blue]<embed allowScriptAccess=”never” src=”Files/[COLOR=Red]<%=song%>[/COLOR]” width=”150″ height=”46″ type=”audio/x-pn-realaudio-plugin” loop=”false” autostart=”true” controls=”all” border=”0″></embed>[/COLOR]

Music starts playing without the page reloading. Sort of like how Image loading alternates on eBay, except I want to do it with music.

Anyway, if anyone has any ideas I’d appreciate them. And sorry to bother you heavy duty fellers with my less than researched question.

Thanks folks,
Bill

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJan 24.2006 — first and most important!: make sure your player has a name.

you can then reference the name and call the correct methods.

here is a simple example:

[CODE]
<html>
<head>
<script type="text/javascript">
function changeSong(song){
var iPlayer = document.embPlayer;
iPlayer.setSource(song);
iPlayer.DoPlay();
}
</script>
</head>
<body>
<select name="song" onchange="changeSong(this[this.selectedIndex].value)">
<option>Select</option>
<option value="C:Documents and SettingsPaul AllsoppMy DocumentsMy MusicMiscEverytime.rm">Britney - Everytime</option>
<option value="C:Documents and SettingsPaul AllsoppMy DocumentsMy MusicPearl Jam5 - Black.mp3">Pearl Jam - Black</option>
<option value="C:Documents and SettingsPaul AllsoppMy DocumentsMy MusicPearl Jam217-yellow_ledbetter.mp3">Pearl Jam - Yellow Ledbetter</option>
</select>

<embed name="embPlayer"
allowScriptAccess="true"
src=""
width="150"
height="46"
type="audio/x-pn-realaudio-plugin"
loop="false"
autostart="false"
controls="all"
border="0">
</embed>

</body>
</html>
[/CODE]


when the select changes, it calls the changeSong() function, which sets the source url to the value passed by the select, then the player is told to play

change the values of the select options to something on your pc, and you'll see what happens.

Have fun.

By the way, you need to go to the Real website and look into embedded scripting. I have a link somewhere.

You can also use callback features, so your scripts can be called when the use does anything to the player, like change volume, right click, press stop etc.

using the proper methods and callbacks, you have absolute control over the player.

here is a similarly simple demo I uploaded:

http://webtop-designs.com/temp/iPlayer.htm (works in IE)

by the way, if you want to set your player controls to 'All', set your player size to 375W and 100H to be able to see the player properly.
×

Success!

Help @billsisemore spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...