menu: new "Add Fake Airplay" and "Add Fake Chromecast" items

Fixes #21
This commit is contained in:
Feross Aboukhadijeh
2016-03-05 14:04:33 -08:00
parent ff1d5a6bb0
commit fc68a08de7
2 changed files with 41 additions and 11 deletions

View File

@@ -49,6 +49,10 @@ function getMenuItem (label) {
} }
} }
function addFakeDevice (device) {
windows.main.send('addFakeDevice', device)
}
function getMenuTemplate () { function getMenuTemplate () {
var template = [ var template = [
{ {
@@ -143,17 +147,33 @@ function getMenuTemplate () {
type: 'separator' type: 'separator'
}, },
{ {
label: 'Reload', label: 'Developer',
accelerator: 'CmdOrCtrl+R', submenu: [
click: reloadWindow {
}, label: 'Reload',
{ accelerator: 'CmdOrCtrl+R',
label: 'Developer Tools', click: reloadWindow
accelerator: (function () { },
if (process.platform === 'darwin') return 'Alt+Command+I' {
else return 'Ctrl+Shift+I' label: 'Developer Tools',
})(), accelerator: (function () {
click: toggleDevTools if (process.platform === 'darwin') return 'Alt+Command+I'
else return 'Ctrl+Shift+I'
})(),
click: toggleDevTools
},
{
type: 'separator'
},
{
label: 'Add Fake Airplay',
click: () => addFakeDevice('airplay')
},
{
label: 'Add Fake Chromecast',
click: () => addFakeDevice('chromecast')
}
]
} }
] ]
}, },

View File

@@ -5,6 +5,7 @@ var chromecasts = require('chromecasts')()
var createTorrent = require('create-torrent') var createTorrent = require('create-torrent')
var dragDrop = require('drag-drop') var dragDrop = require('drag-drop')
var electron = require('electron') var electron = require('electron')
var EventEmitter = require('events')
var networkAddress = require('network-address') var networkAddress = require('network-address')
var path = require('path') var path = require('path')
var throttle = require('throttleit') var throttle = require('throttleit')
@@ -191,6 +192,13 @@ electron.ipcRenderer.on('fullscreenChanged', function (e, isFullScreen) {
update() update()
}) })
electron.ipcRenderer.on('addFakeDevice', function (e, device) {
var player = new EventEmitter()
player.play = (networkURL) => console.log(networkURL)
state.view.devices[device] = player
update()
})
function onFiles (files) { function onFiles (files) {
// .torrent file = start downloading the torrent // .torrent file = start downloading the torrent
files.filter(isTorrentFile).forEach(function (torrentFile) { files.filter(isTorrentFile).forEach(function (torrentFile) {
@@ -248,6 +256,8 @@ function torrentReady (torrent) {
} }
function startServer (torrent, cb) { function startServer (torrent, cb) {
if (state.server) return cb()
// use largest file // use largest file
state.view.torrentPlaying = torrent.files.reduce(function (a, b) { state.view.torrentPlaying = torrent.files.reduce(function (a, b) {
return a.length > b.length ? a : b return a.length > b.length ? a : b