Closed smolleyes closed 9 years ago
Read down from here: https://github.com/RSATom/WebChimera/issues/34#issuecomment-65058889
about @gyzerok 's method (not iframe shim), it should help you solve your problem.
yes, it's possible some browsers don't create plugin if it's hidden. It needs some trick to workaround it. I'm already met something similar, just need to remember where exactly.
Found it, look this discussion: https://code.google.com/p/fbvlc/issues/detail?id=61
Also, you can make the plugin window have 1px height and 1px width. It would still be loaded, just practically invisible. :)
hello
ok just set the main div to visibility:hidden and it works not display:none :p
<div id="playerContainer" style="visibility:hidden;">
<object id="Player" type="application/x-chimera-plugin" style="height:100%;width:100%;">
<param name="debug" value="true" />
<param name="qmlsrc" value="player/themes/sleek/main.qml" />
<param name="target" value="" />
</object>
</div>
now another "problem" is that i load some peerflix streams in the player and the total duration change all the time :/ (working with normal vlc) but it s another topic :p (and not all files)
ok so it works, but if i change tab the stream completely stop (no way to stop a media only if stop is called) ?
and attachd events are not working, for exemple
player.addEventListener('MediaPlayerStopped', function() {
do not works, it works if i declare it after player.play('.....')
What browser do you use?
sorry, events are working i had some errors before my declaration of the events...
i use node-webkit 0.9.2 now so chromium: "32.0.1700.107"
Is problem with tab change still exists?
ok forgot my comment on player stooping when i change tab too :p
it works, finally i just have a problem with the total length of the file (but i have the same problem in vlc) ffmpeg can get the real duration of the file, no way to force the duration in the player ? (in seconds)
duration with ffmpeg
C:\Users\smo>ffprobe -i http://192.168.0.36:54566/ -show_format -v quiet
[FORMAT]
filename=http://192.168.0.36:54566/
nb_streams=2
nb_programs=0
format_name=avi
format_long_name=AVI (Audio Video Interleaved)
start_time=0.000000
duration=6505.656000
size=737477910
bit_rate=906875
probe_score=100
TAG:encoder=Lavf55.18.104
[/FORMAT]
don t understand how or if i can acces the wjs object i see in the qml file from js ?
Could you try vlc player nightly build? Maybe it's fixed in recent versions.
ok i try, brb
(it works on linux in vlc with peerflix)
Sorry, don't know what wjs is
i try the msi from here
http://nightlies.videolan.org/build/win32/vlc-3.0.0-20150208-2058/
sorry too lol, i discover qml ... it s vlcPlayer i see it in the qml file, no way to acces it from js ?
humm just start a command line Oo
https://github.com/RSATom/WebChimera/wiki/JavaScript-API All this API related to vlcPlayer instance in qml. I.e. It's no matter on which side you call functions (it has some exceptions but you could think about it as described )
Do you mean, is it possible run ffprobe from qml?
don t know, i call it thru nodejs so it s not a problem but don t know if i can tell vlc or qml to use the duration i give to him
Understand, could you please check if "position" property show correct value(it has 0 to 1 interval)?
player.time 103709 player.time 104549
that s why it change all the time, not way to not refresh it ? (think thru qml if i understand)
is see this in UIsettings.qml
Component.onCompleted: { ui = variables; done = true; } Timer { interval: 0; running: done === true && mutebut.width != ui.settings.toolbar.buttonMuteWidth ? true : false; repeat: false onTriggered: { ui = ui } } Timer { interval: 0; running: done === true && prevBut.width != buttonWidth ? true : false; repeat: false onTriggered: { buttonWidth = buttonWidth } }
??
where can i find the "position" you asked for ? :)
This value I get from libvlc, so i can't change it.
So much happened in the meanwhile..
To use wjs you need to include "player/webchimera.js" in your page, then if the plugin object has id "webchimera" for example, then you call it with wjs("#webchimera")
Where did you download WebChimera Player from? The download page or did you download a demo directly? (need to know in order to help you overwrite the total length of a video element)
i understand, but could we disable it and get it ourself ? (thru ffprobe for me) then sent is a time
"position" = player.position
i downloaded the ratio demo jaruba and use the qml from it (to learn)
player.position 0.014723594300448895
it works
ok, open the file "player\core\Functions.qml"
and look for these lines:
// Start Get Video Length in seconds
function getLength() {
if (vlcPlayer.length > 0) {
return vlcPlayer.length;
} else {
return vlcPlayer.time * (1 / vlcPlayer.position);
}
}
// End Get Video Length in seconds
Change it to:
// Start Get Video Length in seconds
function getLength() {
if (vlcPlayer.length > 0) {
return vlcPlayer.length;
} else if (settings.customLength > 0) {
return settings.customLength;
} else {
return vlcPlayer.time * (1 / vlcPlayer.position);
}
}
// End Get Video Length in seconds
I think @jaruba will help better, I have go to sleep. Will back around 10 hours
ok good night RSATom, thanks :)
ok done jaruba, and now how can i set it from js in the app ?
Now go to "player\core\Settings.qml" and add:
property var customLength: 0;
where you see all the other "property var"..
Now we have a property ready to accept the custom value, all we need to do is send it from on page js to qml. So we go back to "player/core/Functions.qml" and look for:
} else {
if (startsWith(message,"[start-subtitle]")) subMenu.playSubtitles(message.replace("[start-subtitle]","")); // Get Subtitle URL and Play Subtitle
if (startsWith(message,"[clear-subtitle]")) subMenu.clearSubtitles(); // Clear Loaded External Subtitle
if (startsWith(message,"[load-m3u]")) playM3U(message.replace("[load-m3u]","")); // Load M3U Playlist URL
And we add one more line to it:
} else {
if (startsWith(message,"[start-subtitle]")) subMenu.playSubtitles(message.replace("[start-subtitle]","")); // Get Subtitle URL and Play Subtitle
if (startsWith(message,"[clear-subtitle]")) subMenu.clearSubtitles(); // Clear Loaded External Subtitle
if (startsWith(message,"[load-m3u]")) playM3U(message.replace("[load-m3u]","")); // Load M3U Playlist URL
if (startsWith(message,"[set-total-length]")) settings.customLength = message.replace("[set-total-length]",""); // Set custom total length
Now, if you use wjs, you can use:
wjs("#Player").plugin.emitJsMessage("[set-total-length]"+totalLength);
or without wjs:
document.getElementById('Player').emitJsMessage("[set-total-length]"+totalLength);
These examples presume you have a plugin object with id "Player" and that you have the total length in milliseconds saved in a variable by the name of "totalLength".
ok i understand now i call .emitJsMessage( message ) ... that s it
yes i have a player object i ll try now :) THANKS
and it help me understand the qml files... :palm_tree:
Also, you should hook to the event that is triggered when the video ends and use:
wjs("#Player").plugin.emitJsMessage("[set-total-length]0");
or:
document.getElementById('Player').emitJsMessage("[set-total-length]0");
Otherwise, when the video has ended, the next video will probably have the same total length (because it overwrites all other properties except the one from vlcPlayer itself).
player.emitJsMessage("[set-total-length]"+6505);
it gives me 02:15 / 00:06 Oo
strange 06 seconds
yeah, because it's in milliseconds, so 1000 milliseconds = 1 second
oh ok i ll try
Also, I recommend you use the recommended method ( http://wiki.webchimera.org/Player_Embedding ) of embedding WebChimera Player, it gives a lot more options ( http://wiki.webchimera.org/Player_JavaScript_API ) and accepts all the plugin javascript api functions too.
ok it works :+1:
now i ll search to rehresh the progress bar, exemple i have 1:48:25 as total time but seeking in the bar stop at 43:25
The thing is, that the progress bar has nothing to do with .time or .length, it prints the value of "vlcPlayer.progress" which has values ranging from 0.0 (0%) to 1.0 (100%) of the plugin area length.
If you want to overwrite this functionality, first you will need to make sure that you ALWAYS have the correct current time and total length available. Set a new property in "player/core/Settings.qml" (like before), then calculate the new progress by doing (do this in the "onTime()" function in "player/core/Functions.qml"):
settings.newProgress = getLength() / vlcPlayer.time;
settings = settings;
and change all "vlcPlayer.progress" to "settings.newProgress" everywhere.
This might also work without doing "settings = settings;", this is actually a hack I made to force object property notification, and I recommend it in this scenario.
ok thanks, i m adding the webchimera.js now
but have the QML file form local machine warning... fixing it :p
and yes ffprobe always return the good length but on real LIVE streams so don t care about progress bar in this case
Yeah, you should be able to use "visibility:hidden" without problems, because the player container is exposed in html. (not dynamically created like the plugin object)
To fix the local QML file warning, just remove:
// if page on local machine, add warning
var globalurlstring = " ";
var localwarning = '<div id="warning-wrapper"><div id="lwarning" class="btn">QML File cannot be loaded from your Local Machine! Upload the Demo on a Web server to see it working correctly!</div></div>';
var wjsScripts = document.getElementsByTagName("script"),
webchimeraSrc = wjsScripts[wjsScripts.length-1].src,
webchimeraFolder = webchimeraSrc.substring(0, webchimeraSrc.lastIndexOf("/"));
switch(window.location.protocol) {
case 'http:': break;
case 'https:': break
case 'file:':
document.body.innerHTML += localwarning;
break;
default:
document.body.innerHTML += localwarning;
}
// end if page on local machine, add warning
from "player/webchimera.js"
i have webchimeraFolder is not defined if i do that
i try to add case 'app:': break; but not working
I changed my comment above about how to force the new progress. It now includes a hack that ensures that the "settings" property will be notified in qml each time it changes.
Try removing only:
switch(window.location.protocol) {
case 'http:': break;
case 'https:': break
case 'file:':
document.body.innerHTML += localwarning;
break;
default:
document.body.innerHTML += localwarning;
}
See if that helps. I have to run out for an hour or so, leave any questions you may have here and I'll answer them as soon as I get back. :)
ok jaruba thanks a lot !! really cool :)
i try to fix the qml loading for the moment :p
hi
i put the player in a hidden by default in my app like this
and in my js i have a simple
until this div is not visible or focused it seems i can t use the js api on it, how can i do ?
thanks