Skip to content

Commit

Permalink
Record from browser (#1068)
Browse files Browse the repository at this point in the history
* add link to new lecture

* target blank

* :)

* prepared everthing for inpage recording

* nice record button

* video design

* responsive

* added select screen

* add start stop methods

* recording should work

* added play buttonc

* simplify colors

* controls working

* add data as a file

* make it work

* mute video preview

* added notices

* fix bug

* fix OnLastSlide :)
  • Loading branch information
mono424 authored Aug 16, 2023
1 parent e770c8d commit 502d63b
Show file tree
Hide file tree
Showing 5 changed files with 388 additions and 13 deletions.
1 change: 0 additions & 1 deletion .idea/runConfigurations/run_production.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{define "lecture-record-slide"}}
<div
x-data="{
recorder: initRecorder($el)
}"
>
<div class="dark:bg-gray-800 dark:text-orange-300 border-l-4 border-orange-500 rounded text-orange-500 p-4 bg-orange-100 mt-2">
<p class="font-bold">Notice</p>
<p>Please keep in mind, this feature hasn't been fully tested yet. So, we recommend using it only for short recordings where you can easily redo them if anything goes wrong.</p>
</div>
<div class="flex flex-col justify-center mt-7 xl:flex-row">
<div
class="aspect-video xl:w-[47%] xl:mx-[1.5%] my-2 rounded relative max-xl:min-w-full cursor-pointer text-white overflow-hidden"
:class="recorder.screencastAvailable ? 'bg-black' : 'bg-black/30 dark:bg-black/20'"
>
<div
x-show="!recorder.screencastAvailable"
@click="() => recorder.selectScreencast($refs.screenDisplay)"
class="flex justify-center flex-col items-center h-full"
>
<i class="fa fa-desktop text-2xl mb-2"></i>
<span class="block">
Click to enable Screencast
</span>
</div>

<video class="h-full w-full" x-ref="screenDisplay"></video>
</div>
<div
class="aspect-video xl:w-[47%] xl:mx-[1.5%] my-2 rounded relative max-xl:min-w-full cursor-pointer text-white overflow-hidden"
:class="recorder.cameraAvailable ? 'bg-black' : 'bg-black/30 dark:bg-black/20'"
>
<div
x-show="!recorder.cameraAvailable"
@click="() => recorder.selectCamera($refs.camDisplay)"
class="flex justify-center flex-col items-center h-full"
>
<i class="fa fa-camera text-2xl mb-2"></i>
<span class="block">
Click to enable Camera
</span>
</div>

<video class="h-full w-full" x-ref="camDisplay"></video>
</div>
</div>

<div class="dark:text-gray-300 p-4 text-center">
<p>We kindly draw your attention to the fact that <b>voice recording functionality is dependent on the activation of your camera feed</b>.</p>
</div>

<div x-show="!recorder.recordingsReady" class="flex justify-center mt-7">
<button
@click.prevent="recorder.toggleRecording()"
class="rounded-full w-20 h-20 hover:scale-105 transition ease-in-out active:scale-90 active:bg-gray-600 flex justify-center items-center duration-100 disabled:opacity-20 disabled:scale-100 disabled:bg-gray-400"
:class="recorder.isRecording ? 'bg-gray-500' : 'bg-red-400'"
:disabled="recorder.retrieveRecording"
>
<div
class="bg-white transition-all ease-in-out duration-100"
:class="recorder.isRecording ? 'rounded w-7 h-7' : 'rounded-full w-5 h-5'"
></div>
</button>
</div>

<div x-show="recorder.recordingsReady" class="flex justify-center mt-7">
<button
@click.prevent="recorder.deleteRecordings()"
class="rounded-full w-20 h-20 hover:scale-110 transition ease-in-out active:scale-90 flex justify-center items-center text-red-400 duration-100 disabled:opacity-20 disabled:scale-100"
>
<i class="fa fa-trash text-2xl"></i>
</button>
<button
@click.prevent="recorder.togglePlay()"
class="rounded-full w-20 h-20 hover:scale-105 transition ease-in-out bg-blue-400 active:scale-90 active:bg-gray-600 flex justify-center items-center duration-100 text-white disabled:opacity-20 disabled:scale-100 disabled:bg-gray-400"
>
<i x-show="!recorder.isPlaying" class="fa fa-play text-2xl"></i>
<i x-show="recorder.isPlaying" class="fa fa-pause text-2xl"></i>
</button>
<button
@click.prevent="recorder.resetPlay()"
class="rounded-full w-20 h-20 hover:scale-110 transition ease-in-out active:scale-90 flex justify-center items-center text-blue-400 duration-100 disabled:opacity-20 disabled:scale-100"
>
<i class="fa fa-stop text-2xl"></i>
</button>
</div>
</div>
{{end}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@
<ul class="w-full">
<li class="mb-2">
<button
@click.prevent="() => updateType(false)"
x-data="{ itemCreateType: admin.LectureCreateType.livestream }"
@click.prevent="() => updateCreateType(itemCreateType)"
class="inline-flex items-center justify-between w-full p-5 text-gray-500 bg-white border border-gray-200 rounded-lg cursor-pointer dark:hover:text-gray-300 dark:border-gray-700 hover:text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-600 dark:hover:bg-gray-500"
:class="formData.vodup === true ? '' : 'dark:text-white dark:border-white border-blue-600 text-blue-600'"
:class="createType === itemCreateType ? 'dark:text-white dark:border-white border-blue-600 text-blue-600' : ''"
>
<div class="block text-left">
<div class="w-full text-lg font-semibold">Livestream</div>
<div class="w-full">From Lecture-Hall or Self-Stream</div>
</div>
</button>
</li>
<li class="mb-2">
<button
x-data="{ itemCreateType: admin.LectureCreateType.vodRecord }"
@click.prevent="() => updateCreateType(itemCreateType)"
class="inline-flex items-center justify-between w-full p-5 text-gray-500 bg-white border border-gray-200 rounded-lg cursor-pointer dark:hover:text-gray-300 dark:border-gray-700 hover:text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-600 dark:hover:bg-gray-500"
:class="createType === itemCreateType ? 'dark:text-white dark:border-white border-blue-600 text-blue-600' : ''"
>
<div class="block text-left">
<div class="w-full text-lg font-semibold">Record Lecture</div>
<div class="w-full">Record a Lecture in your Browser</div>
</div>
</button>
</li>
<li>
<button
@click.prevent="() => updateType(true)"
x-data="{ itemCreateType: admin.LectureCreateType.vodUpload }"
@click.prevent="() => updateCreateType(itemCreateType)"
class="inline-flex items-center justify-between w-full p-5 text-gray-500 bg-white border border-gray-200 rounded-lg cursor-pointer dark:hover:text-gray-300 dark:border-gray-700 hover:text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:bg-gray-600 dark:hover:bg-gray-500"
:class="formData.vodup !== true ? '' : 'dark:text-white dark:border-white border-blue-600 text-blue-600'"
:class="createType === itemCreateType ? 'dark:text-white dark:border-white border-blue-600 text-blue-600' : ''"
>
<div class="block text-left">
<div class="w-full text-lg font-semibold">Video Upload</div>
Expand Down
26 changes: 18 additions & 8 deletions web/template/partial/course/manage/create-lecture-form.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@
2
</span>
<span class="hidden sm:inline-flex sm:ml-2">Details</span>
<svg aria-hidden="true" class="w-4 h-4 ml-2 sm:ml-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 5l7 7-7 7M5 5l7 7-7 7"></path></svg>
<svg x-show="createType === admin.LectureCreateType.vodUpload || createType === admin.LectureCreateType.vodRecord" aria-hidden="true" class="w-4 h-4 ml-2 sm:ml-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 5l7 7-7 7M5 5l7 7-7 7"></path></svg>
</li>
<li x-show="createType === admin.LectureCreateType.vodUpload" class="flex items-center " :class="currentTab === 2 ? `text-blue-500 dark:text-white` : `text-gray-400 dark:text-gray-500`">
<span class="flex items-center justify-center w-5 h-5 mr-2 text-xs border rounded-full shrink-0" :class="currentTab === 2 ? `border-blue-500 dark:border-white` : `border-gray-400 dark:border-gray-500`">
3
</span>
Upload Media
</li>
<li class="flex items-center " :class="currentTab === 2 ? `text-blue-500 dark:text-white` : `text-gray-400 dark:text-gray-500`">
<li x-show="createType === admin.LectureCreateType.vodRecord" class="flex items-center " :class="currentTab === 2 ? `text-blue-500 dark:text-white` : `text-gray-400 dark:text-gray-500`">
<span class="flex items-center justify-center w-5 h-5 mr-2 text-xs border rounded-full shrink-0" :class="currentTab === 2 ? `border-blue-500 dark:border-white` : `border-gray-400 dark:border-gray-500`">
3
</span>
Record Media
</li>
</ol>

<div class="form-container-body">
{{- /* Loading Tab */ -}}
<div x-show="currentTab === -1" x-data="{ progress: { COMB: 0, PRES: null, CAM: null } }" @voduploadprogress.window="(e) => (progress = e.detail)">
<h3>Your lecture is being created ...</h3>
<ul x-show="formData.vodup" class="mt-2">
Expand All @@ -37,21 +45,23 @@
</ul>
</div>

{{- /* Tab 1 */ -}}
<div x-show="currentTab === 0" class="flex py-4">
{{template "lecture-type-slide"}}
</div>

<div x-show="currentTab === 1 && !formData.vodup">
{{template "livestream-type-slide"}}
</div>

<div x-show="(currentTab === 1 && formData.vodup) || (currentTab === 2 && !formData.vodup) " class="grid grid-cols-2 space-x-2">
{{- /* Tab 2 */ -}}
<div x-show="currentTab === 1" class="grid grid-cols-2 space-x-2">
{{template "lecture-details-slide"}}
</div>

<div x-show="currentTab === 2 && formData.vodup">
{{- /* Tab 3 */ -}}
<div x-show="createType === admin.LectureCreateType.vodUpload && currentTab === 2" class="">
{{template "lecture-media-slide"}}
</div>
<div x-show="createType === admin.LectureCreateType.vodRecord && currentTab === 2" class="">
{{template "lecture-record-slide"}}
</div>
</div>

<div x-show="error" class="flex justify-end px-6 py-2">
Expand Down
Loading

0 comments on commit 502d63b

Please sign in to comment.