cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the Source of a video widget

SOLVED
Highlighted
Aquamarine

Changing the Source of a video widget

Can someone please share a JS code for changing the source file of a Video widget

 

Avinash

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Changing the Source of a video widget

Hi @agangaiah ,

 

the following script could be used to start 2 sequences on video widget (named  here in my example 'video-1')

Because I have also a 3d model  I started the code first when the model is loaded but you can call it also in  other event (for 2d elements only     you can use also :

 

 

$scope.$on('$ionicView.afterEnter', function()  { ....})

 

The sample code will start the first video sequence which is uploaded to the project upload folder and will play it

 

2019-08-03_09-59-49.jpg

The it will wait 20 secs and will play the second video. Here the call are asynchronous and will possibly interrupt the playing sequence if the timeout is shorter. Here the code:

 

 

// call this event after model was loaded - complette
$rootScope.$on('modelLoaded', function() {  
var url_source= "app/resources/Uploaded/for_PTC.mp4";
var videoName="video-1";
console.warn($scope.view.wdg[ videoName]  )
var wdg = angular.element(document.querySelector('twx-widget[widget-id=\"'+videoName+'\"] video'));

 console.warn(wdg)
  console.log('modelLoaded')
   wdg[0].src=url_source;
   wdg[0].play();
  
   $timeout(function () {
       url_source= "app/resources/Uploaded/20180905_055304_HoloLens.mp4";
     wdg[0].src=url_source;
   wdg[0].play();
   
   }, 20000); // call after 20 secs
})

 

 

 

1 REPLY 1

Re: Changing the Source of a video widget

Hi @agangaiah ,

 

the following script could be used to start 2 sequences on video widget (named  here in my example 'video-1')

Because I have also a 3d model  I started the code first when the model is loaded but you can call it also in  other event (for 2d elements only     you can use also :

 

 

$scope.$on('$ionicView.afterEnter', function()  { ....})

 

The sample code will start the first video sequence which is uploaded to the project upload folder and will play it

 

2019-08-03_09-59-49.jpg

The it will wait 20 secs and will play the second video. Here the call are asynchronous and will possibly interrupt the playing sequence if the timeout is shorter. Here the code:

 

 

// call this event after model was loaded - complette
$rootScope.$on('modelLoaded', function() {  
var url_source= "app/resources/Uploaded/for_PTC.mp4";
var videoName="video-1";
console.warn($scope.view.wdg[ videoName]  )
var wdg = angular.element(document.querySelector('twx-widget[widget-id=\"'+videoName+'\"] video'));

 console.warn(wdg)
  console.log('modelLoaded')
   wdg[0].src=url_source;
   wdg[0].play();
  
   $timeout(function () {
       url_source= "app/resources/Uploaded/20180905_055304_HoloLens.mp4";
     wdg[0].src=url_source;
   wdg[0].play();
   
   }, 20000); // call after 20 secs
})