       
       @connection = new Connection code
       @connection.set('bc', bc)
-      @remote = new Remote code.url
-      @connection.set 'author', @remote.getAuthor()
-      @connection.set 'currentSlideUrl', @remote.driver.getCurrentSlideScreenshot() 
-      @connection.set 'currentSlideNumber', @remote.driver.getCurrentSlideNumber() 
-      @connection.set 'quantity', @remote.driver.quantity
-      @connection.set 'title',    @remote.driver.getTitle()
+      try 
+        @remote = new Remote code.url
+        @connection.set 'author', @remote.getAuthor()
+        @connection.set 'currentSlideUrl', @remote.driver.getCurrentSlideScreenshot() 
+        @connection.set 'currentSlideNumber', @remote.driver.getCurrentSlideNumber() 
+        @connection.set 'quantity', @remote.driver.quantity
+        @connection.set 'title',    @remote.driver.getTitle()
+
+      catch error
+        alert(error)
+        return false
 
       baseFirebaseUrl = @baseFirebaseUrl = "#{BACKEND_DATA_HOST}#{@connection.get('token')}/"
       @queue.url = "#{baseFirebaseUrl}qc/"
       console? && console.log @queue
       
-
       # Push slide info
       slideInfo = new Firebase "#{baseFirebaseUrl}info/"
       slideInfo.set @connection.toJSON(), (e) ->

    getCurrentSlideScreenshot: () ->
    getAuthor: () ->
    getTitle: () ->
      $(document).prop('title')

  class SpeakerdeskRemote extends RemoteControlDriver 
    constructor: () ->
      super
      # The player is put inside a iframe so, let get its contents
      @container = $('.speakerdeck-iframe ').contents()
      @quantity = this.getSlideQuantity()
      console? && console.log @container

    getAuthor: () ->
      $('#talk-details h2 a').html()
          #when window.location.host.indexOf('slideshare.net')  then   $('#talk-details h2 a').html()
    getTitle: () ->
        $(document).prop('title').replace("// Speaker Deck", '').trim()

    getSlideQuantity: () ->
      $('.previews > img', @container).length

    getCurrentSlideNumber: () ->
      current_url = $('#player-content-wrapper > #slide_image', @container).prop('src')
      r = /\/slide_([0-9]+)\./gi
      if m = r.exec(current_url)
        return 1 + parseInt(m[1])
      return false 

    getCurrentSlideScreenshot: () ->
      $('#player-content-wrapper > #slide_image', @container).prop('src')
    
    jump: (num) ->
      $('.speakerdeck-iframe ')[0].contentWindow.player.goToSlide num
    next: () ->
      $('.overnav > .next', @container)[0].click()
    previous: () ->
      $('.overnav > .prev', @container)[0].click()

  class SlideshareRemote extends RemoteControlDriver
    constructor: () ->
      super
      @container = $('#svPlayerId') 
      @quantity = this.getSlideQuantity()
      console? && console.log @container
    
    getAuthor: () ->
      $('.title .h-author-name').html()

    getSlideQuantity: () ->
      if $('.slide_container').length > 0
        return $('.slide_container .slide', @container).length 
      if $('.slidesContainer').length > 0 
        return $('.slidesContainer .jsplBgColorBigfoot').length

    getCurrentSlideNumber: () ->
      n = parseInt($('.goToSlideLabel > input', @container).val())
      if n<=1
        return 1
      return n

    getCurrentSlideScreenshot: () ->
      n = this.getCurrentSlideNumber()
      if $('.slide_container > .slide').eq(n-1).find('img').length > 0 
        url = $('.slide_container > .slide').eq(n-1).find('img').prop('src')
        if url.indexOf('image')>=1
          return url
      return "http://placehold.it/320&text=#{n}"

      this.setupRemote()
    # Based on url, load corresponding remote driver  
    setupRemote: () -> 
      try 
        @driver = switch
          when @url.indexOf('speakerdeck.com/') > 1 then new SpeakerdeskRemote
          when @url.indexOf('slideshare.net/') > 1  then new SlideshareRemote
          when @url.indexOf('scribd.com/') > 1  then new ScribdRemote
          when @url.indexOf('drive.google.com/') > 1  then new GoogleRemote
          else throw new Error("Not supported yet")
        return this    
      catch error
        throw error

    control: () ->
      @driver
