File tree Expand file tree Collapse file tree 7 files changed +81
-0
lines changed
Expand file tree Collapse file tree 7 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ Looking at the examples in the `/src/stories` folder should give you some ideas
8383- <a href =" #isBuilt " >` videomailClient.isBuilt() ` </a >
8484- <a href =" #submit " >` videomailClient.submit() ` </a >
8585- <a href =" #getLogLines " >` videomailClient.getLogLines() ` </a >
86+ - <a href =" #setLimitSeconds " >` videomailClient.setLimitSeconds() ` </a >
8687
8788<a name =" constructor " ></a >
8889
@@ -201,6 +202,12 @@ Calling this function will manually trigger a submission of the recorded videoma
201202
202203For advanced use only: returns you a collection of log lines that show what code has been covered recently. Useful if you want to debug something tricky.
203204
205+ <a name =" setLimitSeconds " ></a >
206+
207+ ### videomailClient.setLimitSeconds()
208+
209+ For advanced use only: sets the recording time limit in seconds. Useful if you want to dynamically change the recording duration.
210+
204211<a name =" whatisstored " ></a >
205212
206213## What gets stored on the videomail server?
Original file line number Diff line number Diff line change @@ -77,6 +77,24 @@ class VideomailClient extends Despot {
7777 this . container . startOver ( params ) ;
7878 }
7979
80+ // Useful for altering limit when user has changed options in real-time like
81+ // enabling/disabling audio etc
82+ public setLimitSeconds ( limitSeconds : number ) {
83+ if ( this . options . video . limitSeconds === limitSeconds ) {
84+ this . options . logger . debug (
85+ `Client: setLimitSeconds called but limitSeconds is already ${ limitSeconds } , doing nothing.` ,
86+ ) ;
87+
88+ return ;
89+ }
90+
91+ this . options . video . limitSeconds = limitSeconds ;
92+
93+ this . options . logger . debug ( `Client: setLimitSeconds (limitSeconds = ${ limitSeconds } )` ) ;
94+
95+ this . container . setLimitSeconds ( limitSeconds ) ;
96+ }
97+
8098 public unload ( startingOver = false ) {
8199 this . container . unload ( { startingOver } ) ;
82100 }
Original file line number Diff line number Diff line change @@ -79,6 +79,43 @@ export const Audio: Story = {
7979 } ,
8080} ;
8181
82+ export const ChangingLimit : Story = {
83+ name : "Changing limit on the fly" ,
84+ args : {
85+ enableAutoPause : false ,
86+ audio : {
87+ enabled : false ,
88+ switch : true ,
89+ } ,
90+ image : {
91+ quality : 0.4 ,
92+ } ,
93+ video : {
94+ limitSeconds : 30 ,
95+ countdown : false ,
96+ width : 320 ,
97+ } ,
98+ text : {
99+ buttons : {
100+ preview : "Stop" ,
101+ } ,
102+ } ,
103+ } ,
104+ render : ( args ) => {
105+ const videomailClient = new VideomailClient ( args ) ;
106+
107+ videomailClient . on ( "ENABLING_AUDIO" , function ( ) {
108+ videomailClient . setLimitSeconds ( 15 ) ;
109+ } ) ;
110+
111+ videomailClient . on ( "DISABLING_AUDIO" , function ( ) {
112+ videomailClient . setLimitSeconds ( 30 ) ;
113+ } ) ;
114+
115+ return videomailClient . show ( ) ;
116+ } ,
117+ } ;
118+
82119// High quality: High FPS, near HD quality, short duration and without auto-pause
83120//
84121// This example shows that your browser cannot meet the FPS requirements due to
Original file line number Diff line number Diff line change @@ -899,6 +899,11 @@ class Container extends Despot {
899899 public recordAgain ( ) {
900900 this . visuals . recordAgain ( ) ;
901901 }
902+
903+ public setLimitSeconds ( limitSeconds : number ) {
904+ this . options . video . limitSeconds = limitSeconds ;
905+ this . visuals . setLimitSeconds ( limitSeconds ) ;
906+ }
902907}
903908
904909export default Container ;
Original file line number Diff line number Diff line change @@ -480,6 +480,11 @@ class Visuals extends Despot {
480480 }
481481 }
482482
483+ public setLimitSeconds ( limitSeconds : number ) {
484+ this . options . video . limitSeconds = limitSeconds ;
485+ this . recorderInsides . setLimitSeconds ( limitSeconds ) ;
486+ }
487+
483488 public getElement ( ) {
484489 return this . visualsElement ;
485490 }
Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ class RecordTimer {
121121 return this . options . video . limitSeconds ;
122122 }
123123
124+ public setLimitSeconds ( limitSeconds : number ) {
125+ this . options . video . limitSeconds = limitSeconds ;
126+ }
127+
124128 public start ( ) {
125129 this . countdown = this . getStartSeconds ( ) ;
126130 this . nearComputed = this . endNighComputed = false ;
Original file line number Diff line number Diff line change @@ -153,6 +153,11 @@ class RecorderInsides extends Despot {
153153 public checkTimer ( elapsedTime : number ) {
154154 this . recordTimer . check ( elapsedTime ) ;
155155 }
156+
157+ public setLimitSeconds ( limitSeconds : number ) {
158+ this . options . video . limitSeconds = limitSeconds ;
159+ this . recordTimer . setLimitSeconds ( limitSeconds ) ;
160+ }
156161}
157162
158163export default RecorderInsides ;
You can’t perform that action at this time.
0 commit comments