mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Make presenting files a chat command.
This commit is contained in:
parent
5ecb3a1f93
commit
cbcfbb3f74
2 changed files with 38 additions and 27 deletions
|
@ -233,11 +233,6 @@
|
|||
</form>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<form id="fileform">
|
||||
<label for="fileinput" class=".sidenav-label-first">Play local file:</label>
|
||||
<input type="file" id="fileinput" accept="audio/*,video/*" multiple/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -405,11 +405,6 @@ function setButtonsVisibility() {
|
|||
let present = permissions.indexOf('present') >= 0;
|
||||
let local = !!findUpMedia('camera');
|
||||
let canWebrtc = !(typeof RTCPeerConnection === 'undefined');
|
||||
let canFile =
|
||||
/** @ts-ignore */
|
||||
!!HTMLVideoElement.prototype.captureStream ||
|
||||
/** @ts-ignore */
|
||||
!!HTMLVideoElement.prototype.mozCaptureStream;
|
||||
let mediacount = document.getElementById('peers').childElementCount;
|
||||
let mobilelayout = isMobileLayout();
|
||||
|
||||
|
@ -426,7 +421,6 @@ function setButtonsVisibility() {
|
|||
setVisibility('mediaoptions', present);
|
||||
setVisibility('sendform', present);
|
||||
setVisibility('simulcastform', present);
|
||||
setVisibility('fileform', canFile && present);
|
||||
|
||||
setVisibility('collapse-video', mediacount && mobilelayout);
|
||||
}
|
||||
|
@ -617,21 +611,6 @@ getInputElement('activitybox').onchange = function(e) {
|
|||
}
|
||||
};
|
||||
|
||||
getInputElement('fileinput').onchange = function(e) {
|
||||
if(!(this instanceof HTMLInputElement))
|
||||
throw new Error('Unexpected type for this');
|
||||
let input = this;
|
||||
let files = input.files;
|
||||
for(let i = 0; i < files.length; i++) {
|
||||
addFileMedia(files[i]).catch(e => {
|
||||
console.error(e);
|
||||
displayError(e);
|
||||
});
|
||||
}
|
||||
input.value = '';
|
||||
closeNav();
|
||||
};
|
||||
|
||||
/**
|
||||
* @this {Stream}
|
||||
* @param {Object<string,any>} stats
|
||||
|
@ -3375,6 +3354,43 @@ commands.unraise = {
|
|||
}
|
||||
}
|
||||
|
||||
function presentFile() {
|
||||
let input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept="audio/*,video/*";
|
||||
input.onchange = function(e) {
|
||||
if(!(this instanceof HTMLInputElement))
|
||||
throw new Error('Unexpected type for this');
|
||||
let files = this.files;
|
||||
for(let i = 0; i < files.length; i++) {
|
||||
addFileMedia(files[i]).catch(e => {
|
||||
console.error(e);
|
||||
displayError(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
|
||||
commands.presentfile = {
|
||||
description: 'broadcast a video or audio file',
|
||||
f: (c, r) => {
|
||||
presentFile();
|
||||
},
|
||||
predicate: () => {
|
||||
if(!serverConnection || !serverConnection.permissions ||
|
||||
serverConnection.permissions.indexOf('present') < 0)
|
||||
return 'You are not authorised to present';
|
||||
/** @ts-ignore */
|
||||
if(!HTMLVideoElement.prototype.captureStream &&
|
||||
/** @ts-ignore */
|
||||
!HTMLVideoElement.prototype.mozCaptureStream)
|
||||
return 'Your browser does not support presenting arbitrary files';
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
*/
|
||||
|
@ -3384,7 +3400,7 @@ function sendFile(id) {
|
|||
input.onchange = function(e) {
|
||||
if(!(this instanceof HTMLInputElement))
|
||||
throw new Error('Unexpected type for this');
|
||||
let files = input.files;
|
||||
let files = this.files;
|
||||
for(let i = 0; i < files.length; i++) {
|
||||
try {
|
||||
offerFile(id, files[i]);
|
||||
|
|
Loading…
Reference in a new issue