github.com/aitjcize/Overlord@v0.0.0-20240314041920-104a804cf5e8/overlord/app/common/js/CameraWindow.jsx (about) 1 // Copyright 2016 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 // 5 // External dependencies: 6 // - jsmpeg.js: https://github.com/phoboslab/jsmpeg 7 // 8 // View for CameraWindow: 9 // - CameraWindow 10 11 var CameraWindow = React.createClass({ 12 mixins: [BaseWindow], 13 onCloseMouseUp2: function (event) { 14 this.onCloseMouseUp(); 15 this.sock.close(); 16 }, 17 componentDidMount: function () { 18 var url = "ws" + ((window.location.protocol == "https:")? "s": "" ) + 19 "://" + window.location.host + this.props.path; 20 var sock = new WebSocket(url); 21 var canvas = this.refs["cam-" + this.props.mid]; 22 var player = new jsmpeg(sock, {canvas: canvas}); 23 24 this.sock = sock; 25 this.makeDraggable(".terminal"); 26 this.bringToFront(); 27 }, 28 render: function () { 29 return ( 30 <div className="app-window" id={this.props.id} ref="window" 31 onMouseDown={this.onWindowMouseDown}> 32 <div className="app-window-title">{this.props.title}</div> 33 <div className="app-window-control"> 34 <div className="app-window-icon app-window-close" 35 onMouseUp={this.onCloseMouseUp2}></div> 36 </div> 37 <div className="camera-view"> 38 <canvas className="camera-canvas" ref={"cam-" + this.props.mid} 39 width={this.props.width} height={this.props.height}></canvas> 40 </div> 41 </div> 42 ); 43 } 44 });