diff --git a/AUTHORS.md b/AUTHORS.md index 53dbbb65..fe8d32e4 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -22,6 +22,8 @@ - Mathias Rasmussen - Sergey Bargamon - Thomas Watson Steen +- anonymlol - Gediminas Petrikas +- Adam Gotlib #### Generated by bin/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 116244f1..7b323a86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # WebTorrent Desktop Version History +## v0.8.1 - 2016-06-24 + +### Added + +- New URI handler: stream-magnet + +### Fixed + +- DLNA crashing bug + ## v0.8.0 - 2016-06-23 ### Added diff --git a/README.md b/README.md index 1b51ddf9..878eaf45 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,9 @@ brew install wine ### Privacy -WebTorrent Desktop collects some basic usage stats to help us make the app better. For example, we track what OSs are users are on, and how well the play button works (how often does it succeed? time out? show a missing codec error?). The app never sends personally identifying or other private info. +WebTorrent Desktop collects some basic usage stats to help us make the app better. For example, we track how well the play button works. How often does it succeed? Time out? Show a missing codec error? + +The app never sends personally identifying information, nor does it track which swarms you join. ### Code Style diff --git a/bin/package.js b/bin/package.js index 09a2dcea..4708524b 100755 --- a/bin/package.js +++ b/bin/package.js @@ -206,6 +206,12 @@ function buildDarwin (cb) { CFBundleURLIconFile: path.basename(config.APP_FILE_ICON) + '.icns', CFBundleURLName: 'BitTorrent Magnet URL', CFBundleURLSchemes: [ 'magnet' ] + }, + { + CFBundleTypeRole: 'Editor', + CFBundleURLIconFile: path.basename(config.APP_FILE_ICON) + '.icns', + CFBundleURLName: 'BitTorrent Stream-Magnet URL', + CFBundleURLSchemes: [ 'stream-magnet' ] } ] @@ -460,7 +466,7 @@ function buildLinux (cb) { info: { arch: destArch === 'x64' ? 'amd64' : 'i386', targetDir: DIST_PATH, - depends: 'libc6 (>= 2.4)', + depends: 'gconf2, libgtk2.0-0, libnss3, libxss1', scripts: { postinst: path.join(config.STATIC_PATH, 'linux', 'postinst'), prerm: path.join(config.STATIC_PATH, 'linux', 'prerm') diff --git a/main/handlers.js b/main/handlers.js index 33da88fe..454871a2 100644 --- a/main/handlers.js +++ b/main/handlers.js @@ -37,6 +37,7 @@ function installDarwin () { // On OS X, only protocols that are listed in `Info.plist` can be set as the // default handler at runtime. app.setAsDefaultProtocolClient('magnet') + app.setAsDefaultProtocolClient('stream-magnet') // File handlers are defined in `Info.plist`. } @@ -63,6 +64,12 @@ function installWin32 () { iconPath, EXEC_COMMAND ) + registerProtocolHandlerWin32( + 'stream-magnet', + 'URL:BitTorrent Stream-Magnet URL', + iconPath, + EXEC_COMMAND + ) registerFileHandlerWin32( '.torrent', 'io.webtorrent.torrent', @@ -201,6 +208,7 @@ function uninstallWin32 () { var Registry = require('winreg') unregisterProtocolHandlerWin32('magnet', EXEC_COMMAND) + unregisterProtocolHandlerWin32('stream-magnet', EXEC_COMMAND) unregisterFileHandlerWin32('.torrent', 'io.webtorrent.torrent', EXEC_COMMAND) function unregisterProtocolHandlerWin32 (protocol, command) { diff --git a/main/index.js b/main/index.js index dc6f759b..3be191cc 100644 --- a/main/index.js +++ b/main/index.js @@ -90,7 +90,10 @@ function init () { e.preventDefault() windows.main.dispatch('saveState') // try to save state on exit ipcMain.once('savedState', () => app.quit()) - setTimeout(() => app.quit(), 2000) // quit after 2 secs, at most + setTimeout(() => { + console.error('Saving state took too long. Quitting.') + app.quit() + }, 2000) // quit after 2 secs, at most }) app.on('activate', function () { diff --git a/main/ipc.js b/main/ipc.js index 68efb862..99b76a6a 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -15,7 +15,7 @@ var shell = require('./shell') var shortcuts = require('./shortcuts') var vlc = require('./vlc') var windows = require('./windows') -var thumbnail = require('./thumbnail') +var thumbar = require('./thumbar') // Messages from the main process, to be sent once the WebTorrent process starts var messageQueueMainToWebTorrent = [] @@ -61,24 +61,27 @@ function init () { ipc.on('onPlayerOpen', function () { menu.onPlayerOpen() - shortcuts.onPlayerOpen() + powerSaveBlocker.enable() + shortcuts.enable() + thumbar.enable() }) ipc.on('onPlayerClose', function () { menu.onPlayerClose() - shortcuts.onPlayerOpen() + powerSaveBlocker.disable() + shortcuts.disable() + thumbar.disable() }) - ipc.on('updateThumbnailBar', function (e, isPaused) { - thumbnail.updateThumbarButtons(isPaused) + ipc.on('onPlayerPlay', function () { + powerSaveBlocker.enable() + thumbar.onPlayerPlay() }) - /** - * Power Save Blocker - */ - - ipc.on('blockPowerSave', () => powerSaveBlocker.start()) - ipc.on('unblockPowerSave', () => powerSaveBlocker.stop()) + ipc.on('onPlayerPause', function () { + powerSaveBlocker.disable() + thumbar.onPlayerPause() + }) /** * Shell diff --git a/main/menu.js b/main/menu.js index 61f17417..f8fac0c9 100644 --- a/main/menu.js +++ b/main/menu.js @@ -16,7 +16,6 @@ var config = require('../config') var dialog = require('./dialog') var shell = require('./shell') var windows = require('./windows') -var thumbnail = require('./thumbnail') var menu @@ -34,8 +33,6 @@ function onPlayerClose () { getMenuItem('Increase Speed').enabled = false getMenuItem('Decrease Speed').enabled = false getMenuItem('Add Subtitles File...').enabled = false - - thumbnail.showPlayerThumbnailBar() } function onPlayerOpen () { @@ -47,8 +44,6 @@ function onPlayerOpen () { getMenuItem('Increase Speed').enabled = true getMenuItem('Decrease Speed').enabled = true getMenuItem('Add Subtitles File...').enabled = true - - thumbnail.hidePlayerThumbnailBar() } function onToggleAlwaysOnTop (flag) { @@ -225,7 +220,7 @@ function getMenuTemplate () { accelerator: process.platform === 'darwin' ? 'CmdOrCtrl+Alt+Right' : 'Alt+Right', - click: () => windows.main.dispatch('skip', 1), + click: () => windows.main.dispatch('skip', 10), enabled: false }, { @@ -233,7 +228,7 @@ function getMenuTemplate () { accelerator: process.platform === 'darwin' ? 'CmdOrCtrl+Alt+Left' : 'Alt+Left', - click: () => windows.main.dispatch('skip', -1), + click: () => windows.main.dispatch('skip', -10), enabled: false }, { diff --git a/main/power-save-blocker.js b/main/power-save-blocker.js index c7d76e42..97acd41e 100644 --- a/main/power-save-blocker.js +++ b/main/power-save-blocker.js @@ -1,6 +1,6 @@ module.exports = { - start, - stop + enable, + disable } var electron = require('electron') @@ -12,19 +12,19 @@ var blockId = 0 * Block the system from entering low-power (sleep) mode or turning off the * display. */ -function start () { - stop() // Stop the previous power saver block, if one exists. +function enable () { + disable() // Stop the previous power saver block, if one exists. blockId = electron.powerSaveBlocker.start('prevent-display-sleep') - log(`powerSaveBlocker.start: ${blockId}`) + log(`powerSaveBlocker.enable: ${blockId}`) } /** * Stop blocking the system from entering low-power mode. */ -function stop () { +function disable () { if (!electron.powerSaveBlocker.isStarted(blockId)) { return } electron.powerSaveBlocker.stop(blockId) - log(`powerSaveBlocker.stop: ${blockId}`) + log(`powerSaveBlocker.disable: ${blockId}`) } diff --git a/main/shortcuts.js b/main/shortcuts.js index 4254fd37..02bc2320 100644 --- a/main/shortcuts.js +++ b/main/shortcuts.js @@ -1,12 +1,12 @@ module.exports = { - onPlayerClose, - onPlayerOpen + disable, + enable } var electron = require('electron') var windows = require('./windows') -function onPlayerOpen () { +function enable () { // Register play/pause media key, available on some keyboards. electron.globalShortcut.register( 'MediaPlayPause', @@ -14,7 +14,7 @@ function onPlayerOpen () { ) } -function onPlayerClose () { +function disable () { // Return the media key to the OS, so other apps can use it. electron.globalShortcut.unregister('MediaPlayPause') } diff --git a/main/thumbar.js b/main/thumbar.js new file mode 100644 index 00000000..749aa1a3 --- /dev/null +++ b/main/thumbar.js @@ -0,0 +1,54 @@ +module.exports = { + disable, + enable, + onPlayerPause, + onPlayerPlay +} + +/** + * On Windows, add a "thumbnail toolbar" with a play/pause button in the taskbar. + * This provides users a way to access play/pause functionality without restoring + * or activating the window. + */ + +var path = require('path') +var config = require('../config') + +var windows = require('./windows') + +/** + * Show the Windows thumbnail toolbar buttons. + */ +function enable () { + update(false) +} + +/** + * Hide the Windows thumbnail toolbar buttons. + */ +function disable () { + windows.main.win.setThumbarButtons([]) +} + +function onPlayerPause () { + update(true) +} + +function onPlayerPlay () { + update(false) +} + +function update (isPaused) { + var icon = isPaused + ? 'PlayThumbnailBarButton.png' + : 'PauseThumbnailBarButton.png' + + var buttons = [ + { + tooltip: isPaused ? 'Play' : 'Pause', + icon: path.join(config.STATIC_PATH, icon), + click: () => windows.main.dispatch('playPause') + } + ] + windows.main.win.setThumbarButtons(buttons) +} diff --git a/main/thumbnail.js b/main/thumbnail.js deleted file mode 100644 index d3336ed8..00000000 --- a/main/thumbnail.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - showPlayerThumbnailBar, - hidePlayerThumbnailBar, - updateThumbarButtons -} - -var path = require('path') -var config = require('../config') - -var windows = require('./windows') - -// gets called on player open -function showPlayerThumbnailBar () { - updateThumbarButtons(false) -} - -// gets called on player close -function hidePlayerThumbnailBar () { - windows.main.win.setThumbarButtons([]) -} - -function updateThumbarButtons (isPaused) { - var icon = isPaused ? 'PlayThumbnailBarButton.png' : 'PauseThumbnailBarButton.png' - var tooltip = isPaused ? 'Play' : 'Pause' - var buttons = [ - { - tooltip: tooltip, - icon: path.join(config.STATIC_PATH, icon), - click: function () { - windows.main.send('dispatch', 'playPause') - } - } - ] - windows.main.win.setThumbarButtons(buttons) -} diff --git a/package.json b/package.json index 9358f64f..e5797752 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "webtorrent-desktop", "description": "WebTorrent, the streaming torrent client. For OS X, Windows, and Linux.", - "version": "0.8.0", + "version": "0.8.1", "author": { "name": "WebTorrent, LLC", "email": "feross@webtorrent.io", diff --git a/renderer/controllers/media-controller.js b/renderer/controllers/media-controller.js new file mode 100644 index 00000000..785b168b --- /dev/null +++ b/renderer/controllers/media-controller.js @@ -0,0 +1,56 @@ +const electron = require('electron') + +const ipcRenderer = electron.ipcRenderer + +// Controls local play back: the