"is not object" error when accessing player in javascript

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
t_odell
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2008 07:27

"is not object" error when accessing player in javascript

Postby t_odell » 03 Jan 2008 08:57

Hi, I'm a newbie to the Videolan forum.

I'm trying to set up a simple Ruby on Rails application to display video in the user's mozilla browser.

The page my Ruby application generates is this:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title>Product X Lesson</title> <link href="/stylesheets/style.css?1195723379" media="screen" rel="Stylesheet" type="text/css" /> </head> <body> <div id="content"> <p style="color: green"></p> <embed pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" progid="VideoLAN.VLCPlugin.2" name="video1" autoplay="no" loop="yes" height="240" width="352" target="/images/PSA-Web-320.ogg?1193009495" </embed> <br /> <input type="button" value="Play" onclick="document.video1.play();" /> <input type="button" value="Pause" onclick="document.video1.pause();" /> <input type="button" value="Stop" onclick="document.video1.stop();" /> </div> </body> </html>
When I press the button, the console displays:
(event handler):Value undefined (result of expression document.video1.play) is not object.

Browser is Safari Version 3.0.4 (523.12.2).
Plug-in is latest downloadable plugin for OSX PowerPC.
Browser demo pages from videolan work fine.

Full console dump is as follows:------------------------------
argn=pluginspage, argv=http://www.videolan.org
argn=type, argv=application/x-vlc-plugin
argn=progid, argv=VideoLAN.VLCPlugin.2
argn=name, argv=video1
argn=autoplay, argv=no
argn=loop, argv=yes
argn=height, argv=240
argn=width, argv=352
argn=target, argv=/images/PSA-Web-320.ogg?1193009495
[[32;1m00000001[0m] main private debug: [0mopening config file /Users/B800354/Library/Preferences/VLC/vlcrc[0m
[[32;1m00000001[0m] main private warning: [33;1mconfig file /Users/B800354/Library/Preferences/VLC/vlcrc does not exist yet[0m
[[32;1m00000001[0m] main private debug: [0mchecking builtin modules[0m
[[32;1m00000001[0m] main private debug: [0mchecking plugin modules[0m
[[32;1m00000001[0m] main private debug: [0mloading plugins cache file /Users/B800354/Library/Preferences/VLC/cache/plugins-0404be.dat[0m
[[32;1m00000001[0m] main private debug: [0mrecursively browsing `vlc/modules'[0m
[[32;1m00000001[0m] main private debug: [0mrecursively browsing `/usr/local/lib/vlc'[0m
[[32;1m00000001[0m] main private debug: [0mrecursively browsing `vlc/plugins'[0m
[[32;1m00000001[0m] main private debug: [0mrecursively browsing `/Library/Internet Plug-Ins/VLC Plugin.plugin/Contents/MacOS/modules'[0m
[[32;1m00000001[0m] main private debug: [0mmodule bank initialized, found 206 modules[0m
[[32;1m00000001[0m] main private debug: [0mopening config file /Users/B800354/Library/Preferences/VLC/vlcrc[0m
[[32;1m00000001[0m] main private warning: [33;1mconfig file /Users/B800354/Library/Preferences/VLC/vlcrc does not exist yet[0m
[00000001] main private debug: CPU has capabilities AltiVec FPU
[00000001] main private debug: looking for memcpy module: 2 candidates
[00000001] main private debug: using memcpy module "memcpyaltivec"
[00000269] main playlist debug: waiting for thread completion
[00000269] main playlist debug: thread 26293760 (playlist) created at priority -47 (playlist/playlist.c:184)
[00000270] main private debug: waiting for thread completion
[00000270] main private debug: thread 27389952 (preparser) created at priority -47 (playlist/playlist.c:210)
[00000271] main interface debug: looking for interface module: 1 candidate
[00000271] main interface debug: using interface module "hotkeys"
[00000271] main interface debug: thread 26292224 (interface) created at priority -47 (interface/interface.c:198)
[00000269] main playlist debug: adding playlist item `http://localhost:3000/images/PSA-Web-320.ogg?1193009495' ( http://localhost:3000/images/PSA-Web-320.ogg?1193009495 )
(event handler):Value undefined (result of expression document.video1.play) is not object.

PhatBob
New Cone
New Cone
Posts: 9
Joined: 03 Jan 2008 12:22

Re: "is not object" error when accessing player in javascript

Postby PhatBob » 03 Jan 2008 16:40

Would you not be better to set the id property (so something like id="vlcID") on the VLC object and use (in the first instance):

Code: Select all

var vlc = document.getElementById("vlcID"); if (vlc != null) { vlc.playlist.play(); }
Then once you are happy that the id resolves correctly:

Code: Select all

document.getElementById("vlcID").playlist.play();
Last edited by PhatBob on 04 Jan 2008 08:53, edited 1 time in total.

t_odell
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2008 07:27

Re: "is not object" error when accessing player in javascript

Postby t_odell » 04 Jan 2008 05:26

Thanks for your quick reply.

Your javascript code won't load, by the way. The browser doesn't understand "Nothing". Please fix it for future forum readers. (I don't know enough about javascript to know what the correction should be.)

From your example, I replaced "document.video1.play()" with "document.video1.playlist.play()" and it works.

"document.video1.playlist.stop()" also works. However, I can't find a combination that works for pause.

Which all leads to the question: why does the demo page work?

Here is the mozilla code produced by the demo page http://people.videolan.org/~dionoea/vlc ... height=180:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-15" /> <meta http-equiv="content-language" content="en" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>VLC Plugin Demo</title> </head> <div id="content"> <h1>VLC Plugins Demo Page</h1> <p><a href="index.php">back to main page</a></p> <p>Direct link : <a href='http://people.videolan.org/~dionoea/vlc-plugin-demo/streams/sw_3M.mov'>http://people.videolan.org/~dionoea/vlc-plugin-demo/streams/sw_3M.mov</a></p> <p>Browser autodetection selected the mozilla plugin.</p><p>You are trying to use the mozilla and firefox plugin. <br/><a href="plugin.php?url=http://people.videolan.org/~dionoea/vlc-plugin-demo/streams/sw_3M.mov&width=320&height=180&plugin=activex">Click here to try the activex plugin.</a></p> <!-- mozilla --> <!-- mozilla --> <!-- mozilla --> <!-- mozilla --> <script language="javascript"> function volume_up() { var previous = document.video1.get_volume(); var newvolume = previous + 10; if( newvolume > 200 ) newvolume = 200; document.video1.set_volume( newvolume ); var volume = document.getElementById("volume_status"); volume.innerHTML = document.video1.get_volume() + " %"; } function volume_down() { var previous = document.video1.get_volume(); var newvolume = previous - 10; if( newvolume < 0 ) newvolume = 0; document.video1.set_volume( newvolume ); var volume = document.getElementById("volume_status"); volume.innerHTML = document.video1.get_volume() + " %"; } function status() { var play_status = document.getElementById("play_status"); var time = document.getElementById("time"); var length = document.getElementById("length"); play_status.innerHTML = document.video1.isplaying() ? "Playing" : "Not playing"; if( document.video1.isplaying() == true ) { got_time = document.video1.get_time(); hours = Math.floor(got_time/ 3600); minutes = Math.floor((got_time/60) % 60); seconds = got_time % 60; if ( hours < 10 ) hours = "0" + hours; if ( minutes < 10 ) minutes = "0" + minutes; if ( seconds < 10 ) seconds = "0" + seconds; time.innerHTML = hours+":"+minutes+":"+seconds; got_length = document.video1.get_length(); hours = Math.floor(got_length/ 3600); minutes = Math.floor((got_length/60) % 60); seconds = got_length % 60; if ( hours < 10 ) hours = "0" + hours; if ( minutes < 10 ) minutes = "0" + minutes; if ( seconds < 10 ) seconds = "0" + seconds; length.innerHTML = hours+":"+minutes+":"+seconds; } else { time.innerHTML = "--:--:--"; length.innerHTML = "--:--:--"; } setTimeout("status()", 1000 ); } function play_selected() { select = document.getElementById("item"); set_item( select.value ); document.video1.play(); } function set_item( name) { document.video1.stop(); document.video1.clear_playlist(); document.video1.add_item( name ); } </script> <p> <embed type="application/x-vlc-plugin" name="video1" autoplay="no" loop="yes" height="180" width="320" target="http://people.videolan.org/~dionoea/vlc-plugin-demo/streams/sw_3M.mov" /> </p> <p> <input type="button" value="Play" onclick="document.video1.play();" /> <input type="button" value="Pause" onclick="document.video1.pause();" /> <input type="button" value="Stop" onclick="document.video1.stop();" /> <input type="button" name="chewa" value="Seek -10s" onclick="document.video1.seek(-10,true);" /> <input type="button" name="chewa" value="Seek +10s" onclick="document.video1.seek(10,true);" /> <input type="button" value="Fullscreen" onclick="document.video1.fullscreen()" /> <input type="button" name="chewa" value="Increase volume" onclick="volume_up()" /> <input type="button" name="chewa" value="Decrease volume" onclick="volume_down()" /> <input type="button" name="chewa" value="Mute" onclick="document.video1.mute()" /> </p> <div class="content"> <table> <tr><td>Status</td><td><span id="play_status">Unknown</span></td></tr> <tr><td>Time</td><td><span id="time">--:--:--</span></td></tr> <tr><td>Total Length</td><td><span id="length">--:--:--</span></td></tr> <tr><td>Volume</td><td><span id="volume_status"></span></td></tr> </table> </div> <script language="javascript"> set_item( "http://people.videolan.org/~dionoea/vlc-plugin-demo/streams/sw_3M.mov" ); var volume = document.getElementById("volume_status"); volume.innerHTML = document.video1.get_volume()+ " %"; setTimeout("status()", 1 ); </script> <p><a href="http://www.videolan.org/vlc" title="Get VLC media player - It plays, it streams, it kills WiMPs!!"> <img src="http://download.videolan.org/images/buttons/GetVLC_110.png" alt="Get VLC media player" style="border: 0px none black;"/></a></p> <p>Please send your comments to <a href="dionoea (AT) videolan [dot] org">dionoea (AT) videolan [dot] org</a>.</p> <p><a href="plugin.phps">View this page's source code</a></p> </div> </body> </html>
It clearly calls document.video1.play().

Further help in this would be greatly appreciated.

PhatBob
New Cone
New Cone
Posts: 9
Joined: 03 Jan 2008 12:22

Re: "is not object" error when accessing player in javascript

Postby PhatBob » 04 Jan 2008 08:54

Code fixed.

Does document.video1.playlist.togglePause() not work then?

divx118
Blank Cone
Blank Cone
Posts: 95
Joined: 22 Jun 2006 18:19

Re: "is not object" error when accessing player in javascript

Postby divx118 » 07 Jan 2008 13:02

You are mixing the version 1 and 2 of the activeX. This is the properlink to the latest testpage, if you want to use the latest version. http://people.videolan.org/~damienf/plugin-0.8.6.html
Look at the embed progid the first version is VideoLAN.VLCPlugin.1 and the latest is VideoLAN.VLCPlugin.2
The javascript commands have changed in the latest version see the documentation http://www.videolan.org/doc/play-howto/ ... l#id293992

Scroll down to Build HTML pages that use the plugin (version > 0.8.5.1)

Maurice 8)

t_odell
New Cone
New Cone
Posts: 5
Joined: 02 Jan 2008 07:27

Re: "is not object" error when accessing player in javascript

Postby t_odell » 10 Jan 2008 09:50

Thanks very much for all your help.

I now understand that the sample page I was using was for the old interface and the interface points have changed.

playlist.togglePause() works.

Thanks once again!


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 3 guests