object doesn't support property or method 'play'
-
Thursday, July 14, 2011 4:36 AM
I am using Visual C# Express 2010 and the webBrowser object to navigate to the following HTML5 web page:
<!DOCTYPE HTML>
<!-- saved from url=(0016)http://localhost -->
<!-- the above line fixes the comment: -->
<!-- internet explorer restricted this web page from running scripts or ActiveX controls -->
<html>
<head>
<title>Simple Video Example</title>
<script type="text/javascript">function playVideo()
{
var ip = document.getElementById('myVideo'); //text box
var v = document.getElementById('v1'); //video element
v.src = ip.value;
v.play();
}
function pauseVideo()
{
var v = document.getElementById('v1');
v.pause();
}
</script>
</head>
<body>
<video id="v1" style="width:25%" controls="controls" >Video tag is not supported</video>
<input type="text" id="myVideo" size="60" />
<button onclick="playVideo();">Play</button>
<button onclick="pauseVideo();">Pause</button>
</body></html>
The machine runs Windows 7, the browser I use is IE9. The webBrowser object is 9.0.8112.16430.
Although this page runs fine on the IE9 browser (outside of the VC# 2010 Forms app) when I run it using the webBrowser object in VC# 2010 I see the following error:
Object doesn't support property or method 'play' when I click the play button.
Can you please tell me how I can fix this?
All Replies
-
Thursday, July 14, 2011 5:29 AM
Hi,
Thats because the WB control uses IE7Emulation mode (by default) and does not recognise html5 or <video> tag attributes and methods. (document.documentMode)
If you also examine its userAgent string (navigator.userAgent) you will see that it is also using the IE7 userAgent String and version vector.
see http://msdn.microsoft.com/en-us/library/ms537184(v=vs.85).aspx for instructions to add a feature control entry to allow your WB control to use the IE9 DocumentMode and UAS.
Regards.
Rob^_^- Marked As Answer by Yanping WangMicrosoft Contingent Staff, Moderator Thursday, August 04, 2011 2:06 AM


