...

View Full Version : Embeded player help



porscheman170
11-04-2006, 06:01 PM
Hi everybody,

I'm brand new to this forum and actually coding as well. I have a game server and I'm trying to play music through the built in game browser. The problem is though the music plays perfectly but any drop down menu for song selection is not clickable. I'm pretty sure this is just the ingame browser causing problems so I'm not worried about it but I was trying to figure a way to have songs listed as links to click on then they will start playing. This is the player I have now which is using a .m3u playlist and it works awesome but it doesn't shuffle through songs and the user has to listen to whatever song instead of selecting the one he wants to listen to. Thanks for your help sorry I wrote a book, lol.



<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img src="http://mysite.com/main-logo.jpg"
width="300" height="135" style="padding-left:4px;"/></p>
<h2>In game player </h2>
<p><br />
You're listening to radio, the way!.<br />
<br />
<span style="font-size:14px; font-family:arial; text-align:center;">
<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
type="application/x-oleobject" width="275" height="45" standby="Loading Windows
Media Player components..." id="MediaPlayer">
<param name="FileName" value="http://mysite.com/music/music.m3u"
valuetype="ref" ref="" />
<param name="AudioStream" value="1" />
<param name="AutoSize" value="0" />
<param name="AutoStart" value="1" />
<param name="AnimationAtStart" value="0" />
<param name="AllowScan" value="-1" />
<param name="AllowChangeDisplaySize" value="-1" />
<param name="AutoRewind" value="0" />
<param name="Balance" value="0" />
<param name="BaseURL" value="" />
<param name="BufferingTime" value="5" />
<param name="CaptioningID" value="" />
<param name="ClickToPlay" value="-1" />
<param name="CursorType" value="0" />
<param name="CurrentPosition" value="-1" />
<param name="CurrentMarker" value="0" />
<param name="DefaultFrame" value="" />
<param name="DisplayBackColor" value="0" />
<param name="DisplayForeColor" value="16777215" />
<param name="DisplayMode" value="1" />
<param name="DisplaySize" value="1" />
<param name="Enabled" value="-1" />
<param name="EnableContextMenu" value="-1" />
<param name="EnablePositionControls" value="-1" />
<param name="EnableFullScreenControls" value="-1" />
<param name="EnableTracker" value="-1" />
<param name="InvokeURLs" value="-1" />
<param name="Language" value="-1" />
<param name="Mute" value="0" />
<param name="PlayCount" value="0" />
<param name="PreviewMode" value="0" />
<param name="Rate" value="1" />
<param name="SAMILang" value="" />
<param name="SAMIStyle" value="" />
<param name="SAMIFileName" value="" />
<param name="SelectionStart" value="-1" />
<param name="SelectionEnd" value="-1" />
<param name="SendOpenStateChangeEvents" value="-1" />
<param name="SendWarningEvents" value="-1" />
<param name="SendErrorEvents" value="-1" />
<param name="SendKeyboardEvents" value="0" />
<param name="SendMouseClickEvents" value="0" />
<param name="SendMouseMoveEvents" value="0" />
<param name="SendPlayStateChangeEvents" value="-1" />
<param name="ShowCaptioning" value="0" />
<param name="ShowControls" value="-1" />
<param name="ShowAudioControls" value="-1" />
<param name="ShowDisplay" value="0" />
<param name="ShowGotoBar" value="0" />
<param name="ShowPositionControls" value="0" />
<param name="ShowStatusBar" value="-1" />
<param name="ShowTracker" value="-1" />
<param name="TransparentAtStart" value="0" />
<param name="VideoBorderWidth" value="0" />
<param name="VideoBorderColor" value="333333" />
<param name="VideoBorder3D" value="-1" />
<param name="Volume" value="50" />
<param name="WindowlessVideo" value="-1" />
<embed src="http://mysite.com/music/music.m3u" width="275" height="51"
type="application/x-mplayer2"> </embed>
</object>
</span></p>

porscheman170
11-08-2006, 05:30 AM
Ok I read the whole sticky about embedding Windows media player. I learned some interesting things but I still can't get it to work right. This is what I have so far:




<body>
<p><img src="http://tnbsourceclan.net/main-logo.jpg"
width="300" height="135" style="padding-left:4px;"/></p>
<h2>In game player </h2>
You're listening to radio, the Titties -N- Beer way!.<br />
<br />
<span style="font-size:14px; font-family:arial; text-align:center;">
<OBJECT id=music height=70 width=300 classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95>
<param name="AudioStream" value="1" />
<param name="AutoSize" value="0" />
<param name="AutoStart" value="1" />
<param name="AnimationAtStart" value="0" />
<param name="AllowScan" value="-1" />
<param name="AllowChangeDisplaySize" value="-1" />
<param name="AutoRewind" value="0" />
<param name="Balance" value="0" />
<param name="BaseURL" value="" />
<param name="BufferingTime" value="5" />
<param name="CaptioningID" value="" />
<param name="ClickToPlay" value="-1" />
<param name="CursorType" value="0" />
<param name="CurrentPosition" value="-1" />
<param name="CurrentMarker" value="0" />
<param name="DefaultFrame" value="" />
<param name="DisplayBackColor" value="0" />
<param name="DisplayForeColor" value="16777215" />
<param name="DisplayMode" value="1" />
<param name="DisplaySize" value="1" />
<param name="Enabled" value="-1" />
<param name="EnableContextMenu" value="-1" />
<param name="EnablePositionControls" value="-1" />
<param name="EnableFullScreenControls" value="-1" />
<param name="EnableTracker" value="-1" />
<param name="InvokeURLs" value="-1" />
<param name="Language" value="-1" />
<param name="Mute" value="0" />
<param name="PlayCount" value="0" />
<param name="PreviewMode" value="0" />
<param name="Rate" value="1" />
<param name="SAMILang" value="" />
<param name="SAMIStyle" value="" />
<param name="SAMIFileName" value="" />
<param name="SelectionStart" value="-1" />
<param name="SelectionEnd" value="-1" />
<param name="SendOpenStateChangeEvents" value="-1" />
<param name="SendWarningEvents" value="-1" />
<param name="SendErrorEvents" value="-1" />
<param name="SendKeyboardEvents" value="0" />
<param name="SendMouseClickEvents" value="0" />
<param name="SendMouseMoveEvents" value="0" />
<param name="SendPlayStateChangeEvents" value="-1" />
<param name="ShowCaptioning" value="0" />
<param name="ShowControls" value="1" />
<param name="ShowAudioControls" value="-1" />
<param name="ShowDisplay" value="0" />
<param name="ShowGotoBar" value="0" />
<param name="ShowPositionControls" value="1" />
<param name="ShowStatusBar" value="-1" />
<param name="ShowTracker" value="-1" />
<param name="TransparentAtStart" value="0" />
<param name="VideoBorderWidth" value="0" />
<param name="VideoBorderColor" value="333333" />
<param name="VideoBorder3D" value="-1" />
<param name="Volume" value="50" />
<param name="WindowlessVideo" value="-1" />
</OBJECT>
</div>

<a href="http://www.tnbsourceclan.net/music/music.m3u" onclick="PlayIt(this.href);return false">Rock Mix</a><br>

<p><INPUT id=song1 onclick=document.all.music.filename=document.all.song1.value; TYPE="RADIO" NAME="Music" VALUE="http://www.tnbsourceclan.net/music/music.m3u">Super Mix
</p>
<p><INPUT id=song2 onclick=document.all.music.filename=document.all.song2.value; TYPE="RADIO" NAME="Music" VALUE="http://www.tnbsourceclan.net/music/rock.m3u">Rock Mix
</p>
<p><INPUT id=song3 onclick=document.all.music.filename=document.all.song3.value; TYPE="RADIO" NAME="Music" VALUE="http://www.tnbsourceclan.net/music/zombie.m3u">Zombie Mix
</p>
<p><INPUT id=song4 onclick=document.all.music.filename=document.all.song4.value; TYPE="RADIO" NAME="Music" VALUE="http://www.tnbsourceclan.net/music/hiphop.m3u">Hip Hop Mix
</p>
<p><INPUT id=song5 onclick=document.all.music.filename=document.all.song5.value; TYPE="RADIO" NAME="Music" VALUE="http://www.tnbsourceclan.net/music/club.m3u">Club Mix


The onclick buttons work fine in IE however with the ingame browser I click them and it just lights up the button but nothing happens. When I click the link it opens a new media player window. I want it to play in the embeded player but its being a lil bugger. Can anybody help me please? I will be your best friend:)

Thanks in advance

_Aerospace_Eng_
11-08-2006, 05:59 PM
Here you go

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Playlist Media Player</title>
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background:#000;
color:#FF0;
}
h3 {
text-align:center;
padding:10px;
}
#playercontain {
width:300px;
margin:auto;
text-align:center;
}
#music {
width:300px;
margin:auto;
}
#playlists {
padding:10px 0;
}
#playlists ul {
list-style:none;
}
#playlists ul li {
display:inline;
}
#playlists ul li a {
font-weight:normal;
color:#FFF;
text-decoration:underline;
background:#F00;
}
#playlists ul li a:hover {
text-decoration:none;
}
.clear {
clear:both;
font-size:0;
line-height:0px;
}
</style>
<script type="text/javascript">
function PlayIt(what)
{
document.getElementById('music').innerHTML='<object width="300" height="45" '
+'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
+'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '
+'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
+'<param name="url" value="'+what+'">'
+'<param name="uiMode" value="full">'
+'<param name="autoStart" value="true">'
+'<param name="playCount" value="9999">'
+'<embed type="application/x-mplayer2" '
+'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
+'showcontrols="1" uimode="full" width="300" height="45" '
+'src="'+what+'" autostart="1" playcount="9999">'
+'</object>';
return false;
}
window.onload = function()
{
PlayIt('null.m3u');
}
</script>
</head>

<body>
<div id="playercontain">
<img src="http://tnbsourceclan.net/main-logo.jpg" width="300" height="135" id="mainlogo" />
<h2>In game player</h2>
<p>You're listening to radio, the way!</p>
<div id="playlists">Choose a Playlist
<ul>
<li><a href="http://www.tnbsourceclan.net/music/music.m3u" onclick="return PlayIt(this.href);">Rock Mix</a></li>
<li><a href="http://www.tnbsourceclan.net/music/zombie.m3u" onclick="return PlayIt(this.href);">Zombie Mix</a></li>
<li><a href="http://www.tnbsourceclan.net/music/hiphop.m3u" onclick="return PlayIt(this.href);">Hip Hop Mix</a></li>
<li><a href="http://www.tnbsourceclan.net/music/club.m3u" onclick="return PlayIt(this.href);">Club Mix</a></li>
</ul>
<div class="clear">&nbsp;</div>
</div>
<div id="music">&nbsp;</div>
</div>
</body>
</html>

porscheman170
11-08-2006, 09:39 PM
Wow that is an excellent code! Thank you so much, it's more than I could ask for and I love the layout it's exactly what I wanted. There is one problem though , when I try the code in IE I have to click the box to allow activeX which is normal. I accept activeX on the page and the player pops up and I click the link and the song plays perfectly. If I don't accept activeX and I click the link for the song it opens windows media player in a new window. The problem is when I'm in-game and I open the page the player is not there which is unusual because on the other codes that I posted the player shows up. Unfortunately the in-game browser does not let you accept activeX so when I click the link for the song it minimizes the game and opens windows media player externally. Is there anything in the new code that you gave me that is making this happen compared to the first two I posted that show the player as soon as I open the in-game browser?

Thank you again for your help I really appreciate your time.

_Aerospace_Eng_
11-08-2006, 11:01 PM
Try the attached files. Also testing locally will make the activex prompt come up. On the server the warning should go away.

porscheman170
11-09-2006, 07:04 AM
It works great thank you so much! Is there a way to randomize the songs in the playlist? I noticed that it randomized it whenit played in the external player but not in the embedded one. If this isn't possible or too involved don't sweat it you already helped me out 10X what I was expecting. :thumbsup:

Thanks again,

Chris

_Aerospace_Eng_
11-09-2006, 06:05 PM
No its not possible.

porscheman170
11-18-2006, 01:10 AM
Is it possible by using a .php file to randomize the playlists. It's hard to believe that its not possible. I am willing to paypal some money to anybody that can make a script that will randomize my playlist. I'm serious too I am getting desperate here.

Thanks for your time.

_Aerospace_Eng_
11-18-2006, 01:35 AM
What type of playlist? Also how much are you willing to pay? You asked if it was possible to randomize the playlist using the embedded player, you never said that you were willing to use a server side language in which case my answer would have been yes its possible.

chaser7016
11-18-2006, 03:07 AM
Here is a php randomized script that is supposed to work ... brings up a media player but doesnt play anything :( wonder where I went wrong. Been trying to get it work for a few days now... the files it links to are on my server in the root directory.

<?php

ob_start();
$asx = getASXString();
header("Content-type: video/x-ms-asf");
header("Content-length: ".strlen($asx));
ob_end_clean();
exit;

function get_random_url() {
$files = array('IMoK.mp3', 'ByTheWay.wma', 'DoUWantMe.mp3');
$index = rand(0, count($files)-1);
$random_url = "http://ryanismy.name/" . $files[$index];
return $random_url;

}

function getASXString() {
$output = '<ASX version="3.0">';
for ($i = 0; $i < 10; ++$i) {
$random_url = get_random_url();
$output.="\r\n" . '<ENTRY><REF HREF="' . $random_url .
'"/></ENTRY>';
}
$output.="\r\n</ASX>";
return $output;

}

?>

Maybe we all can get it working?

Chaser

porscheman170
11-18-2006, 06:24 AM
Well Aerospace, I love the player you made me however everytime you click a playlist (from the 4 selections you made for me rock,zombie,hiphop,club) it starts at the same song, which is the first song on the that particular playlist. All I want to do is randomize the song so it is not the same one everytime from each playlist. Example I click Rock Mix AC/DC Hells bells plays, now I close the player and come back to it and click Rock Mix now Nickelback plays. I still want to use the player you made me or something similar if need be because the layout is perfect. I found this random song .php file but I couldn't get it to work with the player you made me.

<?php
$playlist = "/music/playlist.m3u";
if ($_SERVER['PATH_INFO'] == "/playlist.m3u") {
# This a request for the actual playlist.
playlist();
} else {
# Fall through to end of script and display
# the player HTML.
}
function playlist() {
header("Content-type: audio/mpeg");

# Needed for PHP versions OLDER than 4.2.0 only.
# If your host still has PHP older than 4.2.0, shame on them.
# Find a better web host.
srand(make_seed());

# Fetch our list of songs from a file.
$songs = file($playlist);
shuffle($songs);
# Now output the URLs in random order.
foreach ($songs as $song) {
# Remove newline and any other leading and trailing
# whitespace from URL of song.
$song = trim($song);
echo "$song\n";
}
# Now exit before any HTML is produced.
exit(0);
}
# Needed only for very old versions of PHP,
# see srand call earlier.
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
?>

<html>
<head>
<title>MP3s Playing in Random Order</title>
</head>
<body>
<h1 align="center">MP3s Playing in Random Order</h1>
<embed src="http://www.tnbsourceclan.net/music/randomsongs.php/playlist.m3u"
width="0"
height="0"
autostart="true"
type="audio/mpeg"
loop="true"/>
</body>
</html>


The problem is I rent the webhost its not my own box so I can't install programs on it. But I could upload anything into it and change permissions and such if needed. So there you have it that is the type of playlist I want. The price I'm willing to pay, well give me a price within reason and you got it.

Thanks for your time and hopefully talk to you soon.

_Aerospace_Eng_
11-18-2006, 09:02 AM
Hmm I actually think a flash player might be better for this. It may save you money as well. http://www.*******************/?item=Flash+Mp3+Player has an mp3 player that is able to shuffle playlists. You can set it up to use xml files or you can have it read a directory on your server using php and create a playlist from that.

porscheman170
11-18-2006, 05:14 PM
The problem with the flash player is the ingame browser does not support flash right. It doesn't let you click anything to select a playlist, that's why you made links for me to select different playlists. Drop down menus don't even work. At this point I don't care about saving money I am really frustrated with this thing, lol.

_Aerospace_Eng_
11-18-2006, 05:20 PM
What type of game is it? Is it a flash game?

chaser7016
11-18-2006, 06:57 PM
Yeah, porscheman I tried that same php script u posted above but everytime I tried it, it would always load the 1st song in my playlist. Im using GoDaddy and I wonder if the problem has to do with my host?

Im very eager to get this accomplished too ... looking 2 pay as well but I want it to random an asx playlist.

Chaser

porscheman170
11-18-2006, 10:11 PM
The game is counterstrike its not a flash game. It has a built in browser but it's not very good. The ingamemediaplayer.zip file that you made me works perfect though but it doesn't randomize.

porscheman170
11-20-2006, 10:29 PM
Areospace are you there buddy?

_Aerospace_Eng_
11-20-2006, 10:51 PM
Yeah I sent you a pm, did you not read it?

porscheman170
11-21-2006, 02:46 AM
I wrote you back Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum