Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error when media format is unsupported #409

Merged
merged 4 commits into from
Apr 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ function dispatch (action, ...args) {
if (action === 'mediaStalled') {
state.playing.isStalled = true
}
if (action === 'mediaError') {
state.location.back(function () {
onError(new Error('Unsupported file format'))
})
}
if (action === 'mediaTimeUpdate') {
state.playing.lastTimeUpdate = new Date().getTime()
state.playing.isStalled = false
Expand Down
2 changes: 1 addition & 1 deletion renderer/lib/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function dispatcher (...args) {
var json = JSON.stringify(args)
var handler = _dispatchers[json]
if (!handler) {
_dispatchers[json] = (e) => {
handler = _dispatchers[json] = (e) => {
// Don't click on whatever is below the button
e.stopPropagation()
// Don't regisiter clicks on disabled buttons
Expand Down
18 changes: 11 additions & 7 deletions renderer/lib/location-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@ function LocationHistory () {
this._pending = null
}

LocationHistory.prototype.go = function (page) {
LocationHistory.prototype.go = function (page, cb) {
console.log('go', page)
this.clearForward()
this._go(page)
this._go(page, cb)
}

LocationHistory.prototype._go = function (page) {
LocationHistory.prototype._go = function (page, cb) {
if (this._pending) return
if (page.onbeforeload) {
this._pending = page
page.onbeforeload((err) => {
if (this._pending !== page) return /* navigation was cancelled */
this._pending = null
if (err) return
if (err) return cb(err)
this._history.push(page)
if (cb) cb()
})
} else {
this._history.push(page)
if (cb) cb()
}
}

LocationHistory.prototype.back = function () {
LocationHistory.prototype.back = function (cb) {
if (this._history.length <= 1) return

var page = this._history.pop()
Expand All @@ -39,17 +41,19 @@ LocationHistory.prototype.back = function () {
// call finishes first.
page.onbeforeunload(() => {
this._forward.push(page)
if (cb) cb()
})
} else {
this._forward.push(page)
if (cb) cb()
}
}

LocationHistory.prototype.forward = function () {
LocationHistory.prototype.forward = function (cb) {
if (this._forward.length === 0) return

var page = this._forward.pop()
this._go(page)
this._go(page, cb)
}

LocationHistory.prototype.clearForward = function () {
Expand Down
4 changes: 0 additions & 4 deletions renderer/lib/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ var sounds = {
url: 'file://' + path.join(config.STATIC_PATH, 'sound', 'error.wav'),
volume: 0.2
},
POP: {
url: 'file://' + path.join(config.STATIC_PATH, 'sound', 'pop.wav'),
volume: 0.2
},
PLAY: {
url: 'file://' + path.join(config.STATIC_PATH, 'sound', 'play.wav'),
volume: 0.2
Expand Down
1 change: 1 addition & 0 deletions renderer/views/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function renderMedia (state) {
onplay=${dispatcher('mediaPlaying')}
onpause=${dispatcher('mediaPaused')}
onstalling=${dispatcher('mediaStalled')}
onerror=${dispatcher('mediaError')}
ontimeupdate=${dispatcher('mediaTimeUpdate')}
autoplay>
${trackTags}
Expand Down