video.tpl 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <div id="chat-video-panel">
  2. <div class="row">
  3. <div class="col-md-4">
  4. <div class="user-video" id="chat-local-video"></div>
  5. <div class="username-local">
  6. {% if user_local.user_is_online_in_chat == 1 %}
  7. <img src="{{ 'online.png' | icon(16) }}" />
  8. {% else %}
  9. <img src="{{ 'offline.png' | icon(16) }}" />
  10. {% endif %}
  11. {{ user_local.complete_name }} ( {{ user_local.username }} )
  12. </div>
  13. <div class="chat-friends">
  14. <div class="panel-group" id="blocklistFriends" role="tablist" aria-multiselectable="true">
  15. <div class="panel panel-default">
  16. <div class="panel-heading" role="tab" id="headingOne">
  17. <h4 class="panel-title">
  18. <a role="button" data-toggle="collapse" data-parent="#blocklistFriends" href="#listFriends" aria-expanded="true" aria-controls="listFriends">
  19. {{ "SocialFriend" | get_lang }}
  20. </a>
  21. </h4>
  22. </div>
  23. <div id="listFriends" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
  24. <div class="panel-body">
  25. {{ block_friends }}
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="col-md-8">
  33. <div class="user-video" id="chat-remote-video"></div>
  34. <div class="chat-user-remote">{{ "ChatWithXUser"|get_lang|format(chat_user.complete_name) }}</div>
  35. </div>
  36. </div>
  37. </div>
  38. <script>
  39. (function() {
  40. var VideoChat = {
  41. init: function() {
  42. var isCompatible = !!Modernizr.prefixed('RTCPeerConnection', window);
  43. var notifyNotSupport = function() {
  44. $.get('{{ _p.web_ajax }}chat.ajax.php', {
  45. action: 'notify_not_support',
  46. to: {{ chat_user.id }}
  47. });
  48. };
  49. var startVideoChat = function() {
  50. var webRTC = new SimpleWebRTC({
  51. localVideoEl: 'chat-local-video',
  52. remoteVideosEl: '',
  53. autoRequestMedia: true
  54. });
  55. webRTC.on('readyToCall', function() {
  56. webRTC.joinRoom('{{ room_name }}');
  57. });
  58. webRTC.on('videoAdded', function (video, peer) {
  59. $(video).addClass('skip');
  60. $('#chat-remote-video').html(video);
  61. });
  62. };
  63. if (!isCompatible) {
  64. notifyNotSupport();
  65. $('#chat-video-panel').remove();
  66. return;
  67. }
  68. $('#messages').remove();
  69. startVideoChat();
  70. }
  71. };
  72. $(document).on('ready', function() {
  73. VideoChat.init();
  74. });
  75. })();
  76. </script>