Skip to content

Commit

Permalink
Prompt users to install extentions to enable screen sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Dec 11, 2015
1 parent df165b7 commit 8fa87c2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
3 changes: 3 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@
"Username_Change_Disabled" : "Your Rocket.Chat administrator has disabled the changing of usernames",
"Username_description" : "The username is used to allow others to mention you in messages.",
"Username_invalid" : "<strong>%s</strong> is not a valid username,<br/> use only letters, numbers, dots and dashes",
"Screen_Share" : "Screen Share",
"You_need_install_an_extension_to_allow_screen_sharing" : "You need install an extension to allow screen sharing",
"Install_Extension" : "Install Extension",
"Username_title" : "Register username",
"Username_unavaliable" : "<strong>%s</strong> is already in use :(",
"Users" : "Users",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui-master/master/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<meta name="msapplication-config" content="/images/logo/browserconfig.xml?v=3">
<meta name="theme-color" content="#04436a">
<link rel="manifest" href="/images/logo/manifest.json?v=3">
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/nocfbnnmjnndkbipkabodnheejiegccf">
<link rel="icon" sizes="any" type="image/svg+xml" href="/assets/favicon.svg?v=3">
<link rel="icon" sizes="256x256" type="image/png" href="/assets/favicon_256.png?v=3">
<link rel="icon" sizes="192x192" type="image/png" href="/assets/favicon_192.png?v=3">
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui/views/app/videoCall/videoCall.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Template.videoCall.helpers
audioAndVideoEnabled: ->
return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).audioEnabled.get() and WebRTC.getInstanceByRoomId(Session.get('openedRoom')).videoEnabled.get()

screenShareAvaliable: ->
return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).screenShareAvaliable
screenShareAvailable: ->
return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).screenShareAvailable

screenShareEnabled: ->
return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).screenShareEnabled.get()
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui/views/app/videoCall/videoCall.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{{else}}
<button class="enable-video button"><i class="icon-eye"></i></button>
{{/if}}
{{#if screenShareAvaliable}}
{{#if screenShareAvailable}}
{{#if screenShareEnabled}}
<button class="disable-screen-share button red"><i class="icon-desktop"></i></button>
{{else}}
Expand Down
32 changes: 29 additions & 3 deletions packages/rocketchat-webrtc/WebRTCClass.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,15 @@ class WebRTCClass
@monitor = false
@autoAccept = false

@navigator = if navigator.mozGetUserMedia? then 'firefox' else 'chrome'
@screenShareAvaliable = document.cookie.includes('rocketchatscreenshare=chrome') is true or window.rocketchatscreenshare is 'firefox'
@navigator = undefined
if navigator.userAgent.toLocaleLowerCase().indexOf('chrome') > -1
@navigator = 'chrome'
else if navigator.userAgent.toLocaleLowerCase().indexOf('firefox') > -1
@navigator = 'firefox'
else if navigator.userAgent.toLocaleLowerCase().indexOf('safari') > -1
@navigator = 'safari'

@screenShareAvailable = @navigator in ['chrome', 'firefox']

@media =
video: true
Expand Down Expand Up @@ -308,11 +315,30 @@ class WebRTCClass
navigator.getUserMedia media, onSuccess, onError
return

if @screenShareAvaliable isnt true
if @screenShareAvailable isnt true
console.log 'Screen share is not avaliable'
return

getScreen = (audioStream) =>
if document.cookie.indexOf("rocketchatscreenshare=chrome") is -1 and not window.rocketchatscreenshare?
swal
type: "warning"
title: TAPi18n.__ "Screen_Share"
text: TAPi18n.__ "You_need_install_an_extension_to_allow_screen_sharing"
html: true
showCancelButton: true
confirmButtonText: TAPi18n.__ "Install_Extension"
cancelButtonText: TAPi18n.__ "Cancel"
, (isConfirm) =>
if isConfirm
if @navigator is 'chrome'
chrome.webstore.install undefined, undefined, ->
window.open('https://chrome.google.com/webstore/detail/rocketchat-screen-share/nocfbnnmjnndkbipkabodnheejiegccf')
else if @navigator is 'firefox'
window.open('https://addons.mozilla.org/en-GB/firefox/addon/rocketchat-screen-share/')

return

getScreenSuccess = (stream) =>
if audioStream?
stream.addTrack(audioStream.getAudioTracks()[0])
Expand Down

0 comments on commit 8fa87c2

Please sign in to comment.