Skip to content

Commit

Permalink
added screen recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhunt committed Jun 28, 2021
1 parent 21e7f57 commit 4a3b230
Show file tree
Hide file tree
Showing 10 changed files with 711 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Change List
=========
Version 3.1.48 (Build 2021062800)
- added screen recorder

Version 3.1.47 (Build 2021061100)
-updated native video template
-tweaked the file extension parser in uploader.js
Expand Down
7 changes: 6 additions & 1 deletion amd/src/dlg_devicesettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ define(['jquery', 'core/log', 'filter_poodll/dlg_poodll'], function ($, log, dia
this.dlgbox = dlgbox;
this.dlg.set_dialogue_box(dlgbox);

},
set_media_type: function (mediatype) {
//used by screen recorder skin to overide default media type in order to not show video
this.mediatype = mediatype;

},
open: function () {
var self = this;
Expand Down Expand Up @@ -67,7 +72,7 @@ define(['jquery', 'core/log', 'filter_poodll/dlg_poodll'], function ($, log, dia
//register events for the select boxes
self.registerEvents();

if (self.instanceprops.config.mediatype == 'video') {
if (self.mediatype == 'video') {
self.dlg.onclose = function () {
self.resetVideoUserInterface();
};
Expand Down
82 changes: 78 additions & 4 deletions amd/src/poodll_mediarecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ define(['jquery', 'core/log', 'filter_poodll/utils_amd',

this.register_events_video(controlbarid);

//if this is the uploader skin, then we do not bother to get mediaDevices
if (ip.config.media_skin == 'upload' || ip.config.media_skin == 'warning') {
//if this is any of the uploader/warning/screen skins, then we do not bother to get mediaDevices
if (ip.config.media_skin == 'upload' || ip.config.media_skin == 'warning' || ip.config.media_skin == 'screen') {
break;
}

Expand Down Expand Up @@ -279,6 +279,7 @@ define(['jquery', 'core/log', 'filter_poodll/utils_amd',

},


warmup_context: function (ip) {
var ctx = ip.audioctx;
//for chrome oct 2018
Expand Down Expand Up @@ -336,6 +337,49 @@ define(['jquery', 'core/log', 'filter_poodll/utils_amd',
});

},


do_start_screen: function (ip, onMediaSuccess) {

var that = this;
// we warm up the context object
this.warmup_context(ip);

// warmup. the preview object
this.warmup_preview(ip);

//mute the preview
ip.controlbar.preview[0].muted=true;

ip.blobs = [];
//get media constraints
var mediaConstraints = {
audio: {'echoCancellation': true},
video: {cursor: "motion"}
};

//set aspect ratio and I think the "exact" below should be "ideal"
// mediaConstraints.video = {aspectRatio: 1920/1080};


//do all our stream stuff
navigator.mediaDevices.getDisplayMedia(mediaConstraints)
.then(async function(displayStream){
// check for a user audio selected device
if (ip.useraudiodeviceid) {
var audiodeviceid = ip.useraudiodeviceid.valueOf();
mediaConstraints.audio.deviceId = audiodeviceid ? {exact: audiodeviceid} : undefined;
}
var voiceStream = await navigator.mediaDevices.getUserMedia({ audio: mediaConstraints.audio, video: false });
var tracks = [...displayStream.getTracks(), ...voiceStream.getAudioTracks()]
var stream = new MediaStream(tracks);
onMediaSuccess(stream);
})
.catch(function (e) {
that.onMediaError(e, ip);
});
},

do_start_video: function (ip, onMediaSuccess) {

},
Expand Down Expand Up @@ -448,7 +492,10 @@ define(['jquery', 'core/log', 'filter_poodll/utils_amd',
ip.config.hermes.postMessage(messageObject);
},
do_stop_video: function (ip) {

//just use do_stop_audio
},
do_stop_screen: function (ip) {
//just use do_stop_audio
},
do_pause_audio: function (ip) {
//if its paused we need to resume it before pausing again.
Expand All @@ -466,7 +513,7 @@ define(['jquery', 'core/log', 'filter_poodll/utils_amd',

},

/* fetch the audio constraints for passing to mediastream */
/* fetch the video constraints for passing to mediastream */
fetch_video_constraints: function (ip) {
var mediaConstraints = {
audio: !utils.is_opera() && !utils.is_edge(),
Expand All @@ -493,6 +540,33 @@ define(['jquery', 'core/log', 'filter_poodll/utils_amd',
return mediaConstraints;
},

/* fetch the screen constraints for passing to mediastream */
fetch_screen_constraints: function (ip) {
var mediaConstraints = {
audio: !utils.is_opera() && !utils.is_edge(),
video: true
};

//set aspect ratio and I think the "exact" below should be "ideal"
// mediaConstraints.video = {aspectRatio: 1920/1080};
//alert('set');

// check for a user video selected device
if (ip.uservideodeviceid) {
var videodeviceid = ip.uservideodeviceid.valueOf();
var constraints = {deviceId: videodeviceid ? {exact: videodeviceid} : undefined};

mediaConstraints.video = constraints;
}
// check for a user audio selected device
if (ip.useraudiodeviceid) {
var audiodeviceid = ip.useraudiodeviceid.valueOf();
var constraints = {deviceId: audiodeviceid ? {exact: audiodeviceid} : undefined};
mediaConstraints.audio = constraints;
}
return mediaConstraints;
},

/* fetch the audio constraints for passing to mediastream */
fetch_audio_constraints: function (ip) {

Expand Down
8 changes: 7 additions & 1 deletion amd/src/poodll_mediaskins.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ define(['jquery', 'core/log',
'filter_poodll/poodll_oncemediaskin',
'filter_poodll/poodll_freshmediaskin',
'filter_poodll/poodll_uploadmediaskin',
'filter_poodll/poodll_warningmediaskin'], function ($, log, baseskin, onetwothreeskin, goldskin, bmrskin, shadowskin, splitskin, fluencybuilderskin, pushskin, readaloudskin, readseedskin, onceskin, freshskin, uploadskin, warningskin) {
'filter_poodll/poodll_screenmediaskin',
'filter_poodll/poodll_warningmediaskin'],
function ($, log, baseskin, onetwothreeskin, goldskin, bmrskin, shadowskin, splitskin, fluencybuilderskin,
pushskin, readaloudskin, readseedskin, onceskin, freshskin, uploadskin, screenskin, warningskin) {

"use strict"; // jshint ;_;

Expand Down Expand Up @@ -64,6 +67,9 @@ define(['jquery', 'core/log',
case 'upload':
the_skin = uploadskin.clone();
break;
case 'screen':
the_skin = screenskin.clone();
break;
case 'warning':
the_skin = warningskin.clone();
break;
Expand Down
17 changes: 10 additions & 7 deletions amd/src/poodll_onetwothreemediaskin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
define(['jquery', 'jqueryui', 'core/log', 'filter_poodll/utils_amd', 'filter_poodll/anim_progress_bar', 'filter_poodll/speech_poodll', 'filter_poodll/dlg_devicesettings', 'filter_poodll/upskin_bar'], function ($, jqui, log, utils, anim_progress_bar, browserrecognition, settings, upskin_bar) {
define(['jquery', 'jqueryui', 'core/log', 'filter_poodll/utils_amd', 'filter_poodll/anim_progress_bar',
'filter_poodll/speech_poodll', 'filter_poodll/dlg_devicesettings', 'filter_poodll/upskin_bar'],
function ($, jqui, log, utils, anim_progress_bar, browserrecognition, settings, upskin_bar) {
/* jshint ignore:start */

"use strict"; // jshint ;_;
Expand Down Expand Up @@ -278,15 +280,16 @@ define(['jquery', 'jqueryui', 'core/log', 'filter_poodll/utils_amd', 'filter_poo
controls += '<div class="modal-box poodll_mediarecorderbox_onetwothree one-two-three-wrap" id="' + controlbarid + '">';
controls += '<div class="style-holder ' + skin_style + '">';
var status = this.fetch_status_bar('onetwothree');
controls += status,
controls += '<div class="hp_slide" id="slide_' + controlbarid + '">';
controls += status;
controls += '<div class="hp_slide" id="slide_' + controlbarid + '">';
controls += '<div class="hp_timer"></div><canvas class="hp_range"></canvas></div>';
controls += preview,
controls += '<div class="settingsicon" id="settingsicon_' + controlbarid + '"><button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"><i class="fa fa-cogs" aria-hidden="true"></i></button></div>';
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_start-recording_onetwothree"><i class="fa fa-microphone" aria-hidden="true"></i></button> ';
controls += preview;
controls += '<div class="settingsicon" id="settingsicon_' + controlbarid + '"><button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"><i class="fa fa-cogs" aria-hidden="true"></i></button></div>';
if(mediatype == 'video'){var recicon='video-camera';}else{recicon='microphone';}
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_start-recording_onetwothree"><i class="fa fa-'+ recicon +'" aria-hidden="true"></i></button> ';
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_stop-recording_onetwothree pmr_disabled" style="display: none;" disabled><i class="fa fa-stop" aria-hidden="true"></i></button>';
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_pause-recording_onetwothree pmr_disabled" style="display: none;" disabled><i class="fa fa-pause" aria-hidden="true"></i></button>';
controls += ' <button type="button" class="poodll_mediarecorder_button_onetwothree poodll_resume-recording_onetwothree pmr_disabled" style="display: none;" disabled><i class="fa fa-microphone" aria-hidden="true"></i></button>';
controls += ' <button type="button" class="poodll_mediarecorder_button_onetwothree poodll_resume-recording_onetwothree pmr_disabled" style="display: none;" disabled><i class="fa fa-'+ recicon +'" aria-hidden="true"></i></button>';
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_play-recording_onetwothree pmr_disabled" disabled><i class="fa fa-play" aria-hidden="true"></i></button> ';
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_stop-playing_onetwothree pmr_disabled" style="display: none;" disabled><i class="fa fa-stop" aria-hidden="true"></i></button>';
controls += '<button type="button" class="poodll_mediarecorder_button_onetwothree poodll_save-recording_onetwothree pmr_disabled" disabled><i class="fa fa-upload" aria-hidden="true"></i></button>';
Expand Down
Loading

0 comments on commit 4a3b230

Please sign in to comment.