@@ -933,7 +933,8 @@ sap.ui.define("z2ui5/CameraPicture", [
933933 value : { type : "string" } ,
934934 press : { type : "string" } ,
935935 autoplay : { type : "boolean" , defaultValue : true } ,
936- facingMode : { type : "string" , defaultValue : "environment" }
936+ facingMode : { type : "string" } ,
937+ deviceId : { type : "string" }
937938 } ,
938939 events : {
939940 "OnPhoto" : {
@@ -1002,12 +1003,23 @@ sap.ui.define("z2ui5/CameraPicture", [
10021003 setTimeout ( function ( ) {
10031004 var video = document . querySelector ( '#zvideo' ) ;
10041005 if ( navigator . mediaDevices . getUserMedia ) {
1005- navigator . mediaDevices . getUserMedia ( { video : { facingMode : { exact : this . getProperty ( "facingMode" ) } } } )
1006+ const facingMode = this . getProperty ( "facingMode" ) ;
1007+ const deviceId = this . getProperty ( "deviceId" ) ;
1008+
1009+ let options = { video : { } } ;
1010+ if ( deviceId ) {
1011+ options . video . deviceId = deviceId ;
1012+ }
1013+ if ( facingMode ) {
1014+ options . video . facingMode = { exact : facingMode } ;
1015+ }
1016+
1017+ navigator . mediaDevices . getUserMedia ( options )
10061018 . then ( function ( stream ) {
10071019 video . srcObject = stream ;
10081020 } )
10091021 . catch ( function ( error ) {
1010- console . log ( "Something went wrong! " + error ) ;
1022+ console . log ( "Something went wrong! " + error ) ;
10111023 } ) ;
10121024 }
10131025 } . bind ( this ) , 300 ) ;
@@ -1027,6 +1039,40 @@ sap.ui.define("z2ui5/CameraPicture", [
10271039 } ) ;
10281040} ) ;
10291041
1042+ sap . ui . define ( "z2ui5/CameraSelector" , [
1043+ "sap/m/ComboBox" ,
1044+ "sap/ui/core/Item"
1045+ ] , function ( ComboBox , Item ) {
1046+ "use strict" ;
1047+ return ComboBox . extend ( "z2ui5.CameraSelector" , {
1048+
1049+ init : function ( ) {
1050+
1051+ ComboBox . prototype . init . apply ( this , arguments ) ;
1052+
1053+ navigator . mediaDevices
1054+ . enumerateDevices ( )
1055+ . then ( ( devices ) => {
1056+ devices . forEach ( ( device ) => {
1057+ if ( device . kind === "videoinput" ) {
1058+ this . addItem ( new Item ( {
1059+ key : device . deviceId ,
1060+ text : device . label
1061+ } ) ) ;
1062+ }
1063+ } ) ;
1064+ } )
1065+ . catch ( ( err ) => {
1066+ console . error ( `${ err . name } : ${ err . message } ` ) ;
1067+ } ) ;
1068+
1069+ } ,
1070+
1071+ renderer : { }
1072+ } ) ;
1073+ } ) ;
1074+
1075+
10301076sap . ui . define ( "z2ui5/UITableExt" , [ "sap/ui/core/Control" ] , ( Control ) => {
10311077 "use strict" ;
10321078
0 commit comments