Video = require '../video'

class DetailsVideo extends Video
	className: 'control control-url control-video-details'
	template:  'core/views/video-details'

	elements: '.video-title': 'title', '.video-prew': 'prew'
	silent: true

	# file is missing
	onInvalidURL: =>
		@$removeClass 'invalid'
		@title.text 'File missing.'
		@disposePlayer()
		@$unbind 'click', '.video-title, .video-prew', @toggle

	onValidURL: =>
		super
		@prew.append @player.el()
		@$bind 'click', '.video-title, .video-prew', @toggle

	update: ->
		super
		(title = @item.path.split('/').pop().split '.').pop()
		@title.text (unescape title.join '.').trim() or 'No Title'

	reposition: => @_el = $ @player.el()

	status: =>
		@el.toggleClass 'playing', !@player.ended() and !@player.paused()

module.exports = DetailsVideo