jneilliii / OctoPrint-ConsolidatedTabs

22 stars 1 forks source link

[FR] Work with OctoPrint_MultiCam #20

Closed danielfmo closed 4 years ago

danielfmo commented 4 years ago

Hello,

Any change to make this work with OctoPrint_MultiCam? When I try to switch webcam streams nothing happens. (I would be happy with a reasonable alternative or some hints to try to debug this.)

jneilliii commented 4 years ago

My guess is that this is not working because of the way that plugin changes the background-image url of the div. Since this plugin moves that container, his selector might not be right anymore, but that's just a guess right now. I'll have to look into that plugin's code to be sure.

jneilliii commented 4 years ago

Do you get any errors in the developer console of your browser (F12) when you change the selection?

danielfmo commented 4 years ago

No errors on console, So far I was able to determine the following using chromes debugger:

if (OctoPrint.coreui.selectedTab != "#control" || !OctoPrint.coreui.browserTabVisible) {
    return;
}
danielfmo commented 4 years ago

So this makes me question if the following function (from OctoPrint-ConsolidatedTabs)is properly setting the selectedtab.

                self.controlViewModel.onBrowserTabVisibilityChange = function (status) {
                    if (status && self.hasWebcam()) {
                        let selected = OctoPrint.coreui.selectedTab;
                        if (self.webcamtab) {
                            OctoPrint.coreui.selectedTab = "#tab_plugin_webcamtab";
                        } else {
                            OctoPrint.coreui.selectedTab = "#control";
                        }
                        self.controlViewModel._enableWebcam();
                        OctoPrint.coreui.selectedTab = selected;
                    } else {
                        self.controlViewModel._disableWebcam();
                    }
                };

In fact, when I add a breakpoint it is never triggered, not even when I change tabs

danielfmo commented 4 years ago

I believe the issue must be fixed on the OctoPrint_MultiCam

For reference, I made it work by forcing the selectedTab value as bellow:

OctoPrint.coreui.selectedTab = "#control";
self.control._enableWebcam();
jneilliii commented 4 years ago

Maybe not. I do those overrides to get the default webcam to work, but seems to also effect the webcamtab from functioning properly too. I'm adding the plugin to my test pi to see what it's doing.

jneilliii commented 4 years ago

I can confirm this issue. I will try to figure this out for the next release one way or another.

jneilliii commented 4 years ago

So I just figured something out. My override to the onBrowserTabVisibilityChange function in the control view model actually resolves the multicam issue. If you click one of the other webcams to enable and then switch tabs in chrome (not octoprint) or minimize and restore chrome the correct cam loads.

jneilliii commented 4 years ago

This can be fixed with the PR above to the OctoPrint_MultiCam plugin repo. Feel free to install by using the URL below in Plugin Manager > Get More > ...fromURL and click Install.

https://github.com/jneilliii/OctoPrint_MultiCam/archive/ConsolidatedTabsFix.zip