473,786 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedding several songs on one page with JS player

I've been trying for a long time to figure this out, to have a page
with several MP3 clips, and each one having a custom start and stop
button next to them to play the track. I finally found a bit of code
that does this, but it's made for only one mp3 file. I don't know
enough about javascript to customize the code myself. I know there
probably needs to be an "array" of some sort, but I need some help
figuring out where and how that works.

Here's the code I found

<script language="JavaS cript">
var state;

//URL of song - Direct path
function playerinit()
{
player.url="YOU RSONG";
player.settings .autoStart = true ;
}

//Play Function
function play()
{
if (player.control s.isavailable(' play'))
{
player.controls .play();
state=setInterv al("updatetime( )",1000);
}
}

//Stop Function
function stop()
{
if (player.control s.isavailable(' stop'))
{
player.controls .stop();
clearInterval(s tate);
}
}
</script>
</head>

<body onload="playeri nit();">

<!-- START PLAYER -->
<!-- Default Player Settings -->
<object id="player"
classid="CLSID: 6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="applicati on/x-oleobject" width="0" height="0">
<param name="autoStart " value="0">
<param name="balance" value="0">
<param name="currentPo sition" value="0">
<param name="currentMa rker" value="0">
<param name="enableCon textMenu" value="0">
<param name="enableErr orDialogs" value="0">
<param name="enabled" value="-1">
<param name="fullScree n" value="0">
<param name="invokeURL s" value="0">
<param name="playCount " value="1">
<param name="rate" value="1">
<param name="uiMode" value="invisibl e">
<param name="volume" value="100">
<param name="URL" value>
<param name="defaultFr ame" value>
<param name="baseURL" value>
<param name="stretchTo Fit" value="0">
<param name="windowles sVideo" value="0">
<param name="SAMIStyle " value>
<param name="SAMILang" value>
<param name="SAMIFilen ame" value>
<param name="captionin gID" value>
<embed id="player" type="applicati on/x-mplayer2" src="" height="0"
width="0">
</object>
<!-- END Default Player Settings -->

<br />

<!-- Player Controls -->
<input TYPE="image" src="PLAYBUTTON HERE.gif" value="Play "name="play "
onclick="play() ;">
<input TYPE="image" src="STOPBUTTON HERE.gif" value="Stop" name="stop"
onclick="stop() ;">
<!-- END Player Controls -->

Dec 30 '06 #1
3 2924

al***@fearofdol ls.com wrote:
I've been trying for a long time to figure this out, to have a page
with several MP3 clips, and each one having a custom start and stop
button next to them to play the track. I finally found a bit of code
that does this, but it's made for only one mp3 file. I don't know
enough about javascript to customize the code myself. I know there
probably needs to be an "array" of some sort, but I need some help
figuring out where and how that works.

Here's the code I found

<script language="JavaS cript">
var state;

//URL of song - Direct path
function playerinit()
{
player.url="YOU RSONG";
player.settings .autoStart = true ;
}

//Play Function
function play()
{
if (player.control s.isavailable(' play'))
{
player.controls .play();
state=setInterv al("updatetime( )",1000);
}
}

//Stop Function
function stop()
{
if (player.control s.isavailable(' stop'))
{
player.controls .stop();
clearInterval(s tate);
}
}
</script>
</head>

<body onload="playeri nit();">

<!-- START PLAYER -->
<!-- Default Player Settings -->
<object id="player"
classid="CLSID: 6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="applicati on/x-oleobject" width="0" height="0">
<param name="autoStart " value="0">
<param name="balance" value="0">
<param name="currentPo sition" value="0">
<param name="currentMa rker" value="0">
<param name="enableCon textMenu" value="0">
<param name="enableErr orDialogs" value="0">
<param name="enabled" value="-1">
<param name="fullScree n" value="0">
<param name="invokeURL s" value="0">
<param name="playCount " value="1">
<param name="rate" value="1">
<param name="uiMode" value="invisibl e">
<param name="volume" value="100">
<param name="URL" value>
<param name="defaultFr ame" value>
<param name="baseURL" value>
<param name="stretchTo Fit" value="0">
<param name="windowles sVideo" value="0">
<param name="SAMIStyle " value>
<param name="SAMILang" value>
<param name="SAMIFilen ame" value>
<param name="captionin gID" value>
<embed id="player" type="applicati on/x-mplayer2" src="" height="0"
width="0">
</object>
<!-- END Default Player Settings -->

<br />

<!-- Player Controls -->
<input TYPE="image" src="PLAYBUTTON HERE.gif" value="Play "name="play "
onclick="play() ;">
<input TYPE="image" src="STOPBUTTON HERE.gif" value="Stop" name="stop"
onclick="stop() ;">
<!-- END Player Controls -->
That script looks as if it is very old. It likely is designed for the
WMP and uses a type of code that gives a lot of validation errors, so I
will not use this approach. In any event, it would require major
surgery to modify it to play several sound files with controls for on
and off.

I have done what you seem to wish, except I am using wma and ra files
rather than mp3. However, that is no problem, since both the WMP and
Real players will play mp3s. Also note that I reference a Microsoft
..wax playlist file for a song that points to the url of the actual .wma
file and a Real .rpm playlist file that points to the url of the actual
..ra file. There are good technical reasons for doing this for my
application, and the playlist files are very short - mainly the url
wanted at just a bit of other code in the case of .wax.

Also, most of the heavy script work is done on the server using php.
Although the pages could be written only using javascript if served as
html, the php is required if served as true xhtml with the correct
mime type.

See http://www.cwdjr.net/souearly/songs2Root.php for the version for
the WMP.

See http://www.cwdjr.net/souearly/songs2Root.txt for some of the php
used which can not be seen by just viewing the page source. You will
see some arrays, and other php script things that look much like
javascript.

Finally see http://www.cwdjr.net/souearly/songs2RootReal.php if you
have a recent Real player.

The controls with start and stop are actually mini embedded WMP and
Real players that are generated by the player objects.

The page could of course be done without all of the elaborate display
that mostly is done in a very large external script.

The two player pages work on IE6 and the most recent versions of Opera,
Firefox, Mozilla, Netscape, and SeaMonkey if you have the required
players and do not have script turned off.

Of course this may be much more complicated than you want, and not all
hosts allow you to use php on the server. It would take quite a bit of
work to write a stripped down version that uses only javascript and no
php, strips the displays, and design the page for html only and not
xhtml. I do not have time to do this at present, since I have several
other projects going.

Dec 31 '06 #2

cwdjrxyz wrote:
al***@fearofdol ls.com wrote:
I've been trying for a long time to figure this out, to have a page
with several MP3 clips, and each one having a custom start and stop
button next to them to play the track. I finally found a bit of code
that does this, but it's made for only one mp3 file. I don't know
enough about javascript to customize the code myself. I know there
probably needs to be an "array" of some sort, but I need some help
figuring out where and how that works.

Here's the code I found

<script language="JavaS cript">
var state;

//URL of song - Direct path
function playerinit()
{
player.url="YOU RSONG";
player.settings .autoStart = true ;
}

//Play Function
function play()
{
if (player.control s.isavailable(' play'))
{
player.controls .play();
state=setInterv al("updatetime( )",1000);
}
}

//Stop Function
function stop()
{
if (player.control s.isavailable(' stop'))
{
player.controls .stop();
clearInterval(s tate);
}
}
</script>
</head>

<body onload="playeri nit();">

<!-- START PLAYER -->
<!-- Default Player Settings -->
<object id="player"
classid="CLSID: 6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="applicati on/x-oleobject" width="0" height="0">
<param name="autoStart " value="0">
<param name="balance" value="0">
<param name="currentPo sition" value="0">
<param name="currentMa rker" value="0">
<param name="enableCon textMenu" value="0">
<param name="enableErr orDialogs" value="0">
<param name="enabled" value="-1">
<param name="fullScree n" value="0">
<param name="invokeURL s" value="0">
<param name="playCount " value="1">
<param name="rate" value="1">
<param name="uiMode" value="invisibl e">
<param name="volume" value="100">
<param name="URL" value>
<param name="defaultFr ame" value>
<param name="baseURL" value>
<param name="stretchTo Fit" value="0">
<param name="windowles sVideo" value="0">
<param name="SAMIStyle " value>
<param name="SAMILang" value>
<param name="SAMIFilen ame" value>
<param name="captionin gID" value>
<embed id="player" type="applicati on/x-mplayer2" src="" height="0"
width="0">
</object>
<!-- END Default Player Settings -->

<br />

<!-- Player Controls -->
<input TYPE="image" src="PLAYBUTTON HERE.gif" value="Play "name="play "
onclick="play() ;">
<input TYPE="image" src="STOPBUTTON HERE.gif" value="Stop" name="stop"
onclick="stop() ;">
<!-- END Player Controls -->

That script looks as if it is very old. It likely is designed for the
WMP and uses a type of code that gives a lot of validation errors, so I
will not use this approach. In any event, it would require major
surgery to modify it to play several sound files with controls for on
and off.

I have done what you seem to wish, except I am using wma and ra files
rather than mp3. However, that is no problem, since both the WMP and
Real players will play mp3s. Also note that I reference a Microsoft
.wax playlist file for a song that points to the url of the actual .wma
file and a Real .rpm playlist file that points to the url of the actual
.ra file. There are good technical reasons for doing this for my
application, and the playlist files are very short - mainly the url
wanted at just a bit of other code in the case of .wax.

Also, most of the heavy script work is done on the server using php.
Although the pages could be written only using javascript if served as
html, the php is required if served as true xhtml with the correct
mime type.

See http://www.cwdjr.net/souearly/songs2Root.php for the version for
the WMP.

See http://www.cwdjr.net/souearly/songs2Root.txt for some of the php
used which can not be seen by just viewing the page source. You will
see some arrays, and other php script things that look much like
javascript.

Finally see http://www.cwdjr.net/souearly/songs2RootReal.php if you
have a recent Real player.

The controls with start and stop are actually mini embedded WMP and
Real players that are generated by the player objects.

The page could of course be done without all of the elaborate display
that mostly is done in a very large external script.

The two player pages work on IE6 and the most recent versions of Opera,
Firefox, Mozilla, Netscape, and SeaMonkey if you have the required
players and do not have script turned off.

Of course this may be much more complicated than you want, and not all
hosts allow you to use php on the server. It would take quite a bit of
work to write a stripped down version that uses only javascript and no
php, strips the displays, and design the page for html only and not
xhtml. I do not have time to do this at present, since I have several
other projects going.
Thanks. What I really want though is on this page
www.fearofdolls.com/music.html, instead of just having (listen) links
next to each song, I want a button to start and stop it, and I want the
track to just play while you're on the page, and not open up a new page
or window or player, and not have a huge player embeded in the page,
just little start and stop buttons.
I'll take a look at your pages more in depth and see if that might be
what I need. I'm just beginning to learn js, php, and am swtiching from
html to xhtml.

Dec 31 '06 #3

al***@fearofdol ls.com wrote:

Thanks. What I really want though is on this page
www.fearofdolls.com/music.html, instead of just having (listen) links
next to each song, I want a button to start and stop it, and I want the
track to just play while you're on the page, and not open up a new page
or window or player, and not have a huge player embeded in the page,
just little start and stop buttons.
I'll take a look at your pages more in depth and see if that might be
what I need. I'm just beginning to learn js, php, and am swtiching from
html to xhtml.
On my page you just get tiny embedded players just to the left of each
song title. They are reduced to about the same size as the text and are
mainly just a start-stop control. You are not directed to another page,
and you do not bring up a large player. The point is that a player can
be reduced to tiny size and be mainly just a start stop button. The
advantage is that all of the controls are built into the player object,
so you do not have to try to script the player itself, which is very
difficult to get to work on most modern browsers. If you are interested
in IE browsers with the WMP only, there is less of a problem. You have
as many mini players as there are songs. I do not care what code you
use. However, I wanted to set the record straight. Your link did not
work for me.

Jan 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

56
6974
by: alan b | last post by:
I copied it and tried to edit the movie.htm below in the <PARAM NAME=*** location of the file where the videoclip is on my hard drive. It is already recorded by Windows Media Player. My version is 9.0 although it is coded 5.0 in this htm file. Let me know if it is able to be fixed. *** denotes where it is edited to locate the path where the videoclip is.
5
4108
by: John | last post by:
I have a number of self-composed songs in mp3 format which are linked to their individual titles with <a href... The problem with this coding is that the songs open in a new window containing the media player transport control. I've tried embedding, but this is not suitable for multiple files. Ideally, I'd like visitors to have control over the playing of the songs with their media player embedded on the same page. I'm brainstorming here,...
6
7708
by: jonathanztaub | last post by:
I have a DVD CD. * Is it possible to embed it within an html page? * Does the user has to have windows media player or any other program associated with it? * How exactly do I use the <embed> tag? * Do I have to convert the original to another format?
4
2413
by: Sumaira Ahmad | last post by:
Hi, Is there any way of playing songs and downloading songs from a server onto a client machine. I want to develop an application such as a music portal which allows clients to play songs that reside on a Web Server. So does the web server need to send the song as an attachment to the ASP.NET Web application or does it do streaming?? And how is it achieved?? Please any ideas or any hints will be highly appreciated.
6
3009
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player = Player() game.loadPlayer(player) player.moveTo(location)
3
13672
by: Ollie Riches | last post by:
How do I embed a *.flv file (Flash Video) into an aspx page similar to embedding windows media player active x control? Cheers Ollie Riches
5
3415
by: Anil Gupte | last post by:
How do I embed Windows Media Player so I can control it with VB code. I am familiar with embedding in a web page like this: *************** <embed src="Test.asx" width=320 height=300 autostart=True type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="MediaPlayer1" showcontrols=1 showstatusbar=1</embed> **************** I have also created a WM Player control in a VB Windows Application. But
1
11633
by: SeanBoyWalton | last post by:
Hi, I'm currently trying to build a website for a DJ friend of mine and I have come stuck with a couple of issues. I've searched everywhere and put some code together but I still have problems. I want to be able to map controls of the media player to images on the page ie - when user clicks play image - song plays. I can currently get it working in IE but I can't get it to work in Firefox. Problems: 1. The buttons (image buttons)...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.