Skip to content

Commit

Permalink
Merge pull request #67 from mikedmor/rc
Browse files Browse the repository at this point in the history
Rc
  • Loading branch information
mikedmor authored Sep 2, 2023
2 parents fd6db8b + 878b4b0 commit 5bb214b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion octoprint_multicam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_classic_webcam_status(self):
return flask.jsonify(enabled=self.isClassicWebcamEnabled())

def isClassicWebcamEnabled(self):
plugin = self._plugin_manager.get_plugin("classicwebcam")
plugin = self._plugin_manager.get_plugin("classicwebcam",True)
return plugin is not None

def get_settings_version(self):
Expand Down
4 changes: 4 additions & 0 deletions octoprint_multicam/static/css/multicam.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
.webcam_video_container .webcam_unrotated {
width: 100%;
position: relative;
}

#control .webcam_img_container,
#control .webcam_video_container .webcam_unrotated{
min-height: 300px;
}

Expand Down
20 changes: 11 additions & 9 deletions octoprint_multicam/static/js/multicam.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ $(function () {
let webcams = ko.toJS(self.settings.multicam_profiles)
self.webcams = []
self.surfaces = []

if ($("#webcam-group").children().length == 0 || !OctoPrint.coreui.viewmodels.settingsViewModel.webcam_webcamEnabled()){
return false;
}
for (const child of document.getElementById("webcam-group").children) {
if (child.id.startsWith("webcam_plugin_multicam")) {
// We can use this surface, take next webcam and bind
Expand Down Expand Up @@ -95,21 +97,21 @@ $(function () {
}

if (parsed.protocol === "webrtc:" || parsed.protocol === "webrtcs:") {
console.log("DEBUGG Webcam stream type: webrtc")
// console.log("DEBUGG Webcam stream type: webrtc")
return "webrtc";
}

var lastDotPosition = parsed.pathname.lastIndexOf(".");
if (lastDotPosition !== -1) {
var extension = parsed.pathname.substring(lastDotPosition + 1);
if (extension.toLowerCase() === "m3u8") {
console.log("DEBUGG Webcam stream type: hls")
// console.log("DEBUGG Webcam stream type: hls")
return "hls";
}
}

// By default, 'mjpg' is the stream type.
console.log("DEBUGG Webcam stream type: mjpg")
// console.log("DEBUGG Webcam stream type: mjpg")
return "mjpg";
};

Expand Down Expand Up @@ -165,10 +167,10 @@ $(function () {
typeof video.canPlayType != undefined &&
video.canPlayType("application/vnd.apple.mpegurl") == "probably"
) {
console.log("DEBUGG Using native HLS playback")
// console.log("DEBUGG Using native HLS playback")
video.src = self.streamUrlEscaped();
} else if (Hls.isSupported()) {
console.log("DEBUGG Using HLS.js playback")
// console.log("DEBUGG Using HLS.js playback")
self.hls = new Hls();
self.hls.loadSource(self.WebCamSettings.streamUrlEscaped());
self.hls.attachMedia(video);
Expand Down Expand Up @@ -293,7 +295,7 @@ $(function () {
}
self.WebCamSettings.webcam_flipH(webcam[1].flipH)
self.WebCamSettings.webcam_flipV(webcam[1].flipV)
console.log("Loading webcam: ", webcam[1].URL)
//console.log("Loading webcam: ", webcam[1].URL)

self.WebCamSettings.streamUrl(webcam[1].URL)

Expand Down Expand Up @@ -336,12 +338,12 @@ $(function () {
};

self.launchWebcamPictureInPicture = function () {
console.log("DEBUGG launchWebcamPictureInPicture",self._getActiveWebcamVideoElement())
// console.log("DEBUGG launchWebcamPictureInPicture",self._getActiveWebcamVideoElement())
self._getActiveWebcamVideoElement().requestPictureInPicture();
};

self.launchWebcamFullscreen = function () {
console.log("DEBUGG launchWebcamPictureInPicture",self._getActiveWebcamVideoElement())
// console.log("DEBUGG launchWebcamPictureInPicture",self._getActiveWebcamVideoElement())
self._getActiveWebcamVideoElement().requestFullscreen();
};

Expand Down
2 changes: 1 addition & 1 deletion octoprint_multicam/static/js/multicam_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $(function () {
url: "/plugin/multicam/classicwebcamstatus",
type: "GET",
success: function (response) {
self.isClassicWebcamEnabled = response.enabled;
self.isClassicWebcamEnabled(response.enabled);
//console.log("DEBUGGG isClassicWebcamEnabled", self.isClassicWebcamEnabled)

//TODO: Inform the user that the classic webcam is enabled and they should consider disabling it
Expand Down
5 changes: 4 additions & 1 deletion octoprint_multicam/templates/multicam_settings.jinja2
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<!-- ko allowBindings: true -->
<form id="settings_plugin_multicam_form" class="form-horizontal">
<h3>{{ _('Multicam Profiles') }}</h3>
<div class="alert alert-warning" role="alert" data-bind="visible: isClassicWebcamEnabled">
<div class="alert alert-warning" role="alert" data-bind="visible: isClassicWebcamEnabled()">
ClassicWebcam is enabled. Consider disabling it to hide its webcam interface.
</div>
<div class="alert alert-danger" role="alert" data-bind="visible: !OctoPrint.coreui.viewmodels.settingsViewModel.webcam_webcamEnabled()">
Webcam is disabled in OctoPrint - <a href="javascript:$('#settings_webcam_link a').trigger('click');">click here to open WebCam setting</a>
</div>
<div class="row-fluid">
<div class="span3 text-center">
<h4>{{ _('Name') }}</h4>
Expand Down

0 comments on commit 5bb214b

Please sign in to comment.