Click to See Complete Forum and Search --> : How To write this HTML code?


Jin Liying
May 1st, 2002, 10:47 AM
Hi,
In my program( I make my code in VC++), I must use HTML to generate a web page, and the HTML file . I want to embed windows media player into web page, and generate link to play media file using that player, how to write the HTML code?
thanks!

susad
May 3rd, 2002, 05:41 AM
The HTML-Code could look like this:

<OBJECT ID="MyMediaPlayer"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
CODEBASE= "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
width="210"
height="23"
standby="Loading Microsoft Windows Media Player components..."
type="application/x-oleobject">
<PARAM NAME="FileName" VALUE="Your File">
<PARAM NAME="TransparentAtStart" Value="true">
<PARAM NAME="AutoStart" Value="true">
<PARAM NAME="AnimationatStart" Value="true">
<PARAM NAME="ShowStatusBar" Value="true">
<PARAM NAME="ShowControls" Value="false">
<PARAM NAME="autoSize" Value="true">
<PARAM NAME="displaySize" Value="false">
<PARAM NAME="ShowAudioControls" Value="true">
<PARAM NAME="ShowPositionControls" Value="true">
</OBJECT>



Hope that helps
susad

Jin Liying
May 3rd, 2002, 08:24 AM
Thanks!
Now my new question is how can I create different links in one frame to play media file in the other frame?In your code, file name is fixed, I want to send the file name to that frame and play it,how can I chage the code?Thanks!

susad
May 3rd, 2002, 09:05 AM
You can access the MediaPlayer-Object via JavaScript like this:


parent.FrameName.document.MyMediaPlayer.FileName = "Something.avi"
parent.FrameName.document.MyMediaPlayer.play();




You have to replace "FrameName" with the name of the frame with the MediaPlayer-Object.

susad

Jin Liying
May 3rd, 2002, 09:33 AM
I do as you tell me, but when I run it, an error display: deny access. what's the matter?

susad
May 3rd, 2002, 09:56 AM
A reason could be, that the two html-pages are not from the same host. IE does not allow, that you access the document-object of a page that is from another host.

susad

Jin Liying
May 3rd, 2002, 11:24 AM
I just write the following code in one page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body topmargin="0" leftmargin="0">
<object ID="MyPlayer"
classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95
codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=7.0
height=353 type=application/x-oleobject         
width=530 VIEWASTEXT standby="Loading Microsoft Windows Media Playercomponents..." border="-1">
<param name="AudioStream" value="-1">
<param name="AutoSize" value="0">
<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="10">
<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="65280">
<param name="DisplayMode" value="0">
<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="1">
<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="-1">
<param name="ShowPositionControls" value="-1">
<param name="ShowStatusBar" value="-1">
<param name="ShowTracker" value="-1">
<param name="TransparentAtStart" value="-1">
<param name="VideoBorderWidth" value="-1">
<param name="VideoBorderColor" value="0">
<param name="VideoBorder3D" value="-1">
<param name="Volume" value="-1">
<param name="WindowlessVideo" value="0">
<param name="AutoStart" value="0">
<param name="Filename" value="test\Love Day After Tomorrow- 2.asf">
</object>
<script language="JavaScript">
<!--
function play()
{
document.MyPlayer.play();
}
play();
</script>
</html>

//but it seem doesn't work, an error throw: Unknow error.

what's the matter?

susad
May 3rd, 2002, 12:18 PM
You have to wait, until the mplayer has loaded the complete file. Extend the Play-Function like this:


function play()
{
if (document.MyPlayer.object.ReadyState != 4)
window.setTimeout("play()", 500);
else
document.MyPlayer.Play();
}



ReadyState == 4 means the MPlayer is ready and a value of 1 means the is loading.

Hope that helps
susad

Jin Liying
May 3rd, 2002, 10:07 PM
Thanks!
Another question: Why the following code can NOT work?
document.MyPlayer.FileName = "test\Love Day After Tomorrow- 2.asf";
//Unknow error throw
in HTML,I write this:
<param name="FileName" value>

Is there any thing wrong?
Thanks!

susad
May 5th, 2002, 06:47 AM
Ensure that the file exists. If it's not so, the MPlayer throws an "Unknown error" instead of "File not found". And you should change the backslash against a slash in your filename.

susad