Kaynağa Gözat

Show live call duration

Vijayakrishnan 5 yıl önce
ebeveyn
işleme
dc7eecdd7f
1 değiştirilmiş dosya ile 18 ekleme ve 1 silme
  1. 18 1
      resources/views/meeting.blade.php

+ 18 - 1
resources/views/meeting.blade.php

@@ -33,7 +33,9 @@
 
         <h5 class="bg-dark font-weight-bold text-white m-0 py-3 px-4 d-flex">
             <span>Meeting</span>
-            <span class="ml-auto"><i class="fa fa-clock mr-1 text-light"></i>02:34</span>
+            <span class="ml-auto" v-if="started"><i class="fa fa-clock mr-1 text-light"></i>
+                @{{ timeDisplay() }}
+            </span>
         </h5>
 
         <div class="d-flex align-items-stretch mt-4 justify-content-center flex-nowrap">
@@ -84,6 +86,9 @@
             el: '#meetingComponent',
             delimiters: ['@{{', '}}'],
             data: {
+                time: 0,
+                startTime: 0,
+                started: false,
                 guest: false,
                 activeType: false,
                 activeParticipant: false,
@@ -112,6 +117,13 @@
                         this.activeType = _type;
                         this.activeParticipant = _participant;
                     }
+                },
+                timeDisplay: function() {
+                    // this.time = new Date().getTime() - this.startTime;
+                    var seconds = this.time / 1000,
+                        minutes = parseInt(seconds / 60, 10);
+                    seconds = seconds % 60;
+                    return minutes + " min, " + seconds + " sec";
                 }
             },
             mounted: function() {
@@ -123,6 +135,11 @@
                 // after 2 seconds, connect recep
                 window.setTimeout(function() {
                     self.pros[0].status = 'active';
+                    self.started = true;
+                    self.startTime = new Date().getTime();
+                    window.setInterval(function() {
+                        self.time = new Date().getTime() - self.startTime;
+                    }, 1000);
 
                     // after 1 second, add 2 docs in connecting state
                     window.setTimeout(function() {