Skip to content

Commit

Permalink
Fixes a crash that would occur when trying to open some transcripts a…
Browse files Browse the repository at this point in the history
…nd improves UX for new sessions (Closes #165)
  • Loading branch information
insidegui committed Jun 20, 2016
1 parent a725971 commit 1ef9e6f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions WWDC/VideoWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,19 @@ class VideoWindowController: NSWindowController {
}

func showTranscriptWindow(sender: AnyObject?) {
guard let session = session where session.transcript != nil else { return }
guard let session = session else { return }
guard session.transcript != nil else {
let alert = NSAlert()
alert.messageText = "Transcript not available"
if WWDCEnvironment.yearsToIgnoreTranscript.contains(session.year) {
alert.informativeText = "Transcripts for \(session.year) sessions are not available yet."
} else {
alert.informativeText = "The transcript for this session is not available."
}
alert.addButtonWithTitle("OK")
alert.runModal()
return
}

if transcriptWC != nil {
if let window = transcriptWC.window {
Expand Down Expand Up @@ -239,9 +251,15 @@ class VideoWindowController: NSWindowController {
var boundaryObserver: AnyObject?

func setupTranscriptSync(transcript: Transcript) {
guard !transcript.invalidated else { return }
guard transcript.lines.count > 0 else { return }
guard let player = player where transcriptWC != nil else { return }
guard let playerItem = player.currentItem else { return }

let timecodes = transcript.timecodesWithTimescale(playerItem.duration.timescale)
guard timecodes.count > 0 else { return }

boundaryObserver = player.addBoundaryTimeObserverForTimes(transcript.timecodesWithTimescale(player.currentItem!.duration.timescale), queue: dispatch_get_main_queue()) { [unowned self] in
boundaryObserver = player.addBoundaryTimeObserverForTimes(timecodes, queue: dispatch_get_main_queue()) { [unowned self] in
guard self.transcriptWC != nil else { return }

let ct = CMTimeGetSeconds(self.player!.currentTime())
Expand Down

0 comments on commit 1ef9e6f

Please sign in to comment.