diff Applications/StoneWebViewer/WebApplication/app.js @ 1710:673c163e1b3e

playing videos if Orthanc is not available
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Nov 2020 16:41:31 +0100
parents 2931f5e15320
children aec45e0b2528
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebApplication/app.js	Mon Nov 30 15:36:40 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/app.js	Mon Nov 30 16:41:31 2020 +0100
@@ -123,7 +123,7 @@
 
 Vue.component('viewport', {
   props: [ 'left', 'top', 'width', 'height', 'canvasId', 'active', 'content', 'viewportIndex',
-           'showInfo' ],
+           'showInfo', 'globalConfiguration' ],
   template: '#viewport-template',
   data: function () {
     return {
@@ -136,7 +136,8 @@
       cineIncrement: 0,
       cineFramesPerSecond: 30,
       cineTimeoutId: null,
-      cineLoadingFrame: false
+      cineLoadingFrame: false,
+      videoUri: ''
     }
   },
   watch: {
@@ -202,7 +203,31 @@
       }
       else if (newVal.series.type == stone.ThumbnailType.VIDEO) {
         this.status = 'video';
-        console.warn('Videos are not supported by the Stone Web viewer yet');
+        this.videoUri = '';
+        if (this.globalConfiguration.OrthancApiRoot) {
+          var that = this;
+          axios.post(that.globalConfiguration.OrthancApiRoot + '/tools/find',
+                     {
+                       Level : 'Instance',
+                       Query : {
+                         StudyInstanceUID: studyInstanceUid
+                       }
+                     })
+            .then(function(response) {
+              if (response.data.length != 1) {
+                throw('');
+              }
+              else {
+                that.videoUri = that.globalConfiguration.OrthancApiRoot + '/instances/' + response.data[0] + '/frames/0/raw';
+              }
+            })
+            .catch(function(error) {
+              alert('Cannot find the video in Orthanc');
+            });
+        }
+        else {
+          console.warn('Videos are not supported by the Stone Web viewer alone yet, the Orthanc REST API is needed');
+        }
       }
     }
   },