Skip to content

Commit

Permalink
youtubelink: check start <= end & pulled into own function
Browse files Browse the repository at this point in the history
  • Loading branch information
anshukla committed Aug 8, 2013
1 parent 73f7ff2 commit f131a87
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
6 changes: 6 additions & 0 deletions coffee/src/shells/videolink.shell.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ class VideoLinkShell.RemixView extends LinkShell.RemixView
_setTimeInputMax: =>
@timeRangeView.setMax @model.timeTotal()

_setClipRange: =>
@timeRangeView.values {
start: @model.timeStart()
end: @model.timeEnd()
}


onChangeTimes: (changed) =>
changes = {}
Expand Down
28 changes: 15 additions & 13 deletions coffee/src/shells/youtube.shell.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,10 @@ class YouTubeShell.RemixView extends VideoLinkShell.RemixView
super
@metaData().sync success: @onMetaDataSync


onMetaDataSync: (data) =>
@model._fetchedDefaults ?= {}
@model._fetchedDefaults = title: data.data.title
@model.timeTotal data.data.duration

@model._updateAttributesWithDefaults()
start = acorn.util.fetchParameters this.model.link(), ["t", "start"]
# take the first possible valid parameter

# Default start/end can only be set once player metadata
# is avaiilable and initialized. Otherwise, default values
# will override the start/end times.
initializeDefaultClip: =>
start = @model.timeStart()
unless _.isNumber start
start = acorn.util.fetchParameters this.model.link(), ["t", "start"]
Expand All @@ -131,12 +125,20 @@ class YouTubeShell.RemixView extends VideoLinkShell.RemixView
unless _.isNumber end
end = @model.timeTotal()

end = if end >= start then end else @model.timeTotal()
# Clip range must be set before progress bar is initialized
@model.timeStart(start)
@model.timeEnd(end)

@_setTimeInputMin()
@_setTimeInputMax()
@_setClipRange()

onMetaDataSync: (data) =>
@model._fetchedDefaults ?= {}
@model._fetchedDefaults = title: data.data.title
@model._updateAttributesWithDefaults()
@model.timeTotal data.data.duration

@initializeDefaultClip()
@_setTimeInputMax()

metaData: =>
if @model.metaDataUrl() and not @_metaData
Expand Down

1 comment on commit f131a87

@jbenet
Copy link
Member

@jbenet jbenet commented on f131a87 Aug 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Please sign in to comment.