Closed xo1988 closed 8 years ago
Your pages need to at least have <style></style>
in the header, otherwise wcjs-player
can't inject it's styles into the page.
sorry, I add the body of the question late...
it seem that wcjs-player just can get element located at main html, at child html cannot get the element define in it, and if I am not define the in main html, will report TypeError: Cannot read property 'addRule' of undefined, and if I do it, and define
in child html, will report "Uncaught TypeError: Cannot read property 'firstChild' of null". Do you have demo about using wcjs-player with nwjs play video in child html?I think that's a NW.js bug, it's possible that when you call window
in the child window, it actually returns the window of the parent instead of the child window.
I've seen NW.js doing this a few times in other circumstances.
Try setting a timeout on require('wcjs-player')
Also try loading it after the document is ready...
I try like below:
$(document).ready(function () {
setTimeout(function () {
var wjs = require("wcjs-player");
var player = new wjs("#player").addPlayer({ autoplay: true});
var playerUrl = "http://**.mp4";
player.addPlaylist(playerUrl);
},1000);
})
but it still report "Uncaught TypeError: Cannot read property 'firstChild' of null".
and I try with JQuery, test like below in child window. it works.
$("#player").append(
"got you"
);
do you have any route to avoid this circumstances?
try console.log(window.document.getElementById('player'))
define div in child html like below:
<div id="player" class="pp"></div>
then console.log(window.document.getElementById('player').className)
got "pp"
it seem window work well, but when using
var wjs = require("wcjs-player");
var player = new wjs("#player").addPlayer({ autoplay: true});
var playerUrl = "http://**.mp4";
player.addPlaylist(playerUrl);
report
[3941:0121/215101:ERROR:nw_shell.cc(336)] TypeError: Cannot read property 'firstChild' of null
at new wjs (/Users/wangyu/test/video/node_modules/wcjs-player/index.js:75:70)
That makes no sense.. if you look at line 75
:
https://github.com/jaruba/wcjs-player/blob/master/index.js#L75
You will see:
if (window.document.getElementById(this.context.substring(1)).firstChild) {
in your case, this results to:
if (window.document.getElementById('player').firstChild) {
and the error says that:
window.document.getElementById('player')
is null
.
Are you by any chance doing require('wcjs-player')
in the parent window too?
code like below: index.html
<html>
<head><style></style></head>
<body>
<script>
var gui = require("nw.gui");
gui.Window.open('player.html');
</script>
</body>
</html>
player.html
<html>
<head>
<style>
body,html{ width: 100%; height: 100%; padding: 0px; margin:0px }
#player { width: 100%; height: 100% }
</style>
</head>
<body>
<div id="player"></div>
<script>
var wjs = require("wcjs-player");
var player = new wjs("#player").addPlayer({ autoplay: true});
var playerUrl = "http://**.mp4";
player.addPlaylist(playerUrl);
</script>
</body>
</html>
So you have 2 players? One in your parent window and one in a child window?
just have one player in player.html
using electron work well...
Hi, I had the same issues when using version 0.13.0-beta4 of nwjs. So I decided to downgrade to 0.12.3 and everything seems to work now. Hope this helps somebody.
@OancaAndrei, any reason to use beta instead of stable?
No reason at all actually, I simply wanted to have the latest build. I didn't expect it to not work and because the issue wasn't really solved I thought to share my (let's say) solution.
@OancaAndrei did you build wcjs
yourself in the npm install
process? or did you use wcjs-prebuilt
?
It's possible that NW.js 0.13.0 didn't work for you because you built wcjs
by default for NW.js 0.12.3
I used the prebuilt one and I might had forgot to change the version when recompiling... I remember changing it when compiling for electron but not for nwjs. I'll check it now.
I tried recompiling webchimera.js for nwjs v0.13.0-beta4 but unfortunately it doesn't work. The linker complains about some not found links.
Here's the log:
JsVlcPlayer.obj : error LNK2019: unresolved external symbol "void __cdecl node::AtExit(void (__cdecl*)(void *),void *)" (?AtExit@node@@YAXP6AXPAX@Z0@Z) referenced in function "public: static void __cdecl JsVlcPlayer::initJsApi(class v8::Local<class v8::Object> const &)" (?initJsApi@JsVlcPlayer@@SAXABV?$Local@VObject@v8@@@v8@@@Z) [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_default_loop referenced in function "private: __thiscall JsVlcPlayer::JsVlcPlayer(class v8::Local<class v8::Object> &,class v8::Local<class v8::Array> const &)" (??0JsVlcPlayer@@AAE@AAV?$Local@VObject@v8@@@v8@@ABV?$Local@VArray@v8@@@2@@Z) [path\webchimera.js\build\WebChimera.js.vcxproj]
VlcVideoOutput.obj : error LNK2001: external symbol _uv_default_loop unresolved [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_close referenced in function "public: void __thiscall JsVlcPlayer::close(void)" (?close@JsVlcPlayer@@QAEXXZ) [path\webchimera.js\build\WebChimera.js.vcxproj]
VlcVideoOutput.obj : error LNK2001: external symbol _uv_close unresolved [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_async_init referenced in function "private: __thiscall JsVlcPlayer::JsVlcPlayer(class v8::Local<class v8::Object> &,class v8::Local<class v8::Array> const &)" (??0JsVlcPlayer@@AAE@AAV?$Local@VObject@v8@@@v8@@ABV?$Local@VArray@v8@@@2@@Z) [path\webchimera.js\build\WebChimera.js.vcxproj]
VlcVideoOutput.obj : error LNK2001: external symbol _uv_async_init unresolved [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_async_send referenced in function "private: virtual void __thiscall JsVlcPlayer::media_player_event(struct libvlc_event_t const *)" (?media_player_event@JsVlcPlayer@@EAEXPBUlibvlc_event_t@@@Z) [path\webchimera.js\build\WebChimera.js.vcxproj]
VlcVideoOutput.obj : error LNK2001: external symbol _uv_async_send unresolved [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_timer_init referenced in function "private: __thiscall JsVlcPlayer::JsVlcPlayer(class v8::Local<class v8::Object> &,class v8::Local<class v8::Array> const &)" (??0JsVlcPlayer@@AAE@AAV?$Local@VObject@v8@@@v8@@ABV?$Local@VArray@v8@@@2@@Z) [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_timer_start referenced in function "private: void __thiscall JsVlcPlayer::handleLibvlcEvent(struct libvlc_event_t const &)" (?handleLibvlcEvent@JsVlcPlayer@@AAEXABUlibvlc_event_t@@@Z) [path\webchimera.js\build\WebChimera.js.vcxproj]
JsVlcPlayer.obj : error LNK2019: unresolved external symbol _uv_timer_stop referenced in function "public: void __thiscall JsVlcPlayer::close(void)" (?close@JsVlcPlayer@@QAEXXZ) [path\webchimera.js\build\WebChimera.js.vcxproj]
WebChimera.obj : error LNK2019: unresolved external symbol _node_module_register referenced in function __register_WebChimera [path\webchimera.js\build\WebChimera.js.vcxproj]
Am I missing something?
Earlier with prebuilt I meant that I was using the prebuilt distribution of NW.js. So yes, I was compiling nwjs
myself.
@RSATom do you think these errors from nw.js 0.13 are also related to the vmem issue?
No. I think it's cmake-js issue.
@OancaAndrei, are you really need NW.js beta? tbh, I'm a little bit limited in free time, so don't know when will be able look at it. If you really need it, please create issue at https://github.com/RSATom/WebChimera.js/issues
Oh, don't worry about it. I won't use the 0.13 version until it gets out from beta stage. Because facing the same problems, I thought that also @xo1988 might have downloaded the beta version of NW.js so I just wanted to point that out (the issue wasn't really closed in my opinion :) ).
BTW, thanks for your great work, both of you, @RSATom and @jaruba.
@OancaAndrei, good, thank you.
Using macx64, nwjs, wcjs-player, and I want to open child windows using var gui = require("nw.gui"); and gui.Window.open('player.html'); when child window onload i will init the wcjs-player to play video