Page 1 of 1

ADDON: Play recording right inside the "User Stats" page

PostPosted: Tue Dec 31, 2013 2:19 pm
by nrc
No need to download the file and then play the audio recording

now you can play the file direct from the page, with the ability to move the slider to any position, play, pause, and volume control on screen.

This is all based on HTML5, so you will HAVE to have new browser

Go here to test if your browser has the <AUDIO> function built in: http://html5test.com/ (on the right hand side under AUDIO, make sure the "audio element" shows YES)

here is the code changes:

vicidial/user_stats.php

FIND
Code: Select all
$MAIN.="<td align=right><font size=2> $location &nbsp; </td>\n";


REPLACE WITH
Code: Select all

      $daten = date("Y-m-d H:i:s");
      $currentDate = strtotime($daten);
      $futureDate = $currentDate-(60*6);
      $row4date = strtotime($row[4]);
      if ($row4date < $futureDate){
      ?>
      <script type="text/javascript">
      function init(url, w, h, lid)
      {
             // Fixes dual-screen position                         Most browsers      Firefox
         var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
         var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

         width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
         height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

         var left = ((width / 2) - (w / 2)) + dualScreenLeft;
         var top = ((height / 2) - (h / 2)) + dualScreenTop;
   
         popupWin = window.open('','popupWin','height='+h+',width='+w+',left='+left+',top='+top+',resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no');
         var p1="Leadid: "+lid+"<br><audio controls><source src="+url+" type=audio/ogg>Your browser does not support the audio element.</audio>";
         popupWin.document.writeln(p1);
         popupWin.document.close();
      }
      </script>
      <?php
      $MAIN.="<td><font color=\"blue\"><a onclick=\"init('$row[11]','340','75','$row[12]');\"><small>Listen to [$row[12]]</small></a></font></td>";
      $MAIN.="<td align=center><a href=$row[11]><small>Download File</small></a></td>\n";
      } else {
      $MAIN.="<td>Saving to server </td>";
      $MAIN.="<td>- check back</td>";
      }


My vicidial is setup to transfer the recording from the main server to our offsite server every 5mins, so i placed if statement, that says if the call was started less then 6 mins ago, show "Saving to server, check back", otherwise it will show a link to click, which popsup a window for you to hear the call right away.

Let me know what you think, here are a few screen shots:

Image

Image

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Thu Jan 02, 2014 2:32 am
by Vince-0
Nice work!

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Thu Jan 02, 2014 2:34 pm
by nrc
Thanks Vince

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Sat Jan 04, 2014 12:13 am
by williamconley
You really should post this to the Issue Tracker as a Diff against the latest SVN. Very good work. 8-) (And post a link back here for Matt to peruse without searching.)

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Thu Jan 09, 2014 1:22 pm
by dspaan
Thanks for sharing :-)

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Fri Jan 10, 2014 6:51 am
by Trying
Awesome! Please put it in the issue tracker. Thanks for sharing.

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Sat Jan 18, 2014 9:41 am
by Flashhunter
thanks for sharing! :)

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Mon Jan 20, 2014 1:50 pm
by rrb555
Someone should post this on Vicidial Issue Tracker so the Vicidial team can add this feature soon,

This is quite handy

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Tue Jan 21, 2014 2:43 pm
by nrc
I'll get it added..

thanks guys.

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Tue Jan 21, 2014 2:48 pm
by nrc

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Fri Jan 31, 2014 3:44 am
by Rudolfmdlt
This is EXACTLY what I was looking for. Thank you!

Rudolf

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Mon Feb 03, 2014 10:10 am
by nrc
You bet Rudolf!

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Fri Mar 07, 2014 9:10 am
by dspaan
Hi,

I tried your code but i got this error:

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/vicidial/user_stats.php:1266) in /srv/www/htdocs/vicidial/user_stats.php on line 1478


Any idea how i can fix it?

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Wed Mar 19, 2014 10:56 am
by nrc
Seems like a closing tag is missing somewhere....

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Sat Mar 22, 2014 12:16 pm
by dspaan
I looked again but i can't see anything missing. See here the original file on the left and modified on the right.

Image

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Sat May 03, 2014 3:35 pm
by williamconley
it looks like:

Code: Select all
?>
<script ...

began output. if a header was attempted at this point, it was too late as HTML was already being transmitted, header cannot come after html.

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Mon May 05, 2014 12:34 pm
by dspaan
So how are other people using the same piece of code and it's working for them?

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Wed Jun 11, 2014 10:39 pm
by williamconley
likely they had slightly different code OR the "if" statement above that caused that code to be skipped.

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Thu Jun 12, 2014 7:34 pm
by rrb555
i just tried this, all seems to be working just fine but when I'm about to check to listen - the listen to[12345] is not even clickable. is that normal? i wasn't able to play the recordings not sure why.

Re: ADDON: Play recording right inside the "User Stats" page

PostPosted: Fri Jun 13, 2014 7:13 am
by dspaan
Hey could you paste your entire user_stats.php here so i can compare it with mine? I still haven't got this to work yet.