wnpc
Version:
This README outlines the details of collaborating on this Ember application.
40 lines (36 loc) • 1.54 kB
text/coffeescript
`import Ember from 'ember'`
TorrentController = Ember.Controller.extend(
torrent: (torrent)->
torrent.files.forEach (file)=>
file.encoded_path = encodeURIComponent(file.path)
file.stream_url = "http://localhost:3000/stream/#{@get('content.id').toLowerCase()}/#{file.encoded_path}"
actions:
select: ()->
return if
console.log "Listening on #{@get('content.id').toLowerCase()}", "Emitting #{@get('content.torrent_url')}"
.on(.toLowerCase(), .bind(@))
console.log
.emit('torrent_get', )
play:(link)->
subtitle = null
subtitles =
if subtitles
subtitle = subtitles.sort((a,b)->b.rating-a.rating)[0]
.emit('player_play', {link:link, subtitle:subtitle})
pause: ->
.emit('player_pause', {})
torrent_pause: ->
.emit('torrent_pause', .toLowerCase())
torrent_resume: ->
.emit('torrent_resume', .toLowerCase())
torrent_select: (file_index)->
.emit('torrent_select', .toLowerCase(), file_index)
torrent_deselect: (file_index)->
.emit('torrent_deselect', .toLowerCase(), file_index)
quit: ->
.emit('player_quit', {})
)
`export default TorrentController`