added open in vlc feature.
This commit is contained in:
@@ -75,7 +75,8 @@ module.exports = {
|
|||||||
WINDOW_WEBTORRENT: 'file://' + path.join(__dirname, 'renderer', 'webtorrent.html'),
|
WINDOW_WEBTORRENT: 'file://' + path.join(__dirname, 'renderer', 'webtorrent.html'),
|
||||||
|
|
||||||
WINDOW_MIN_HEIGHT: 38 + (120 * 2), // header height + 2 torrents
|
WINDOW_MIN_HEIGHT: 38 + (120 * 2), // header height + 2 torrents
|
||||||
WINDOW_MIN_WIDTH: 425
|
WINDOW_MIN_WIDTH: 425,
|
||||||
|
OPEN_IN_VLC: false
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigPath () {
|
function getConfigPath () {
|
||||||
|
|||||||
10
main/menu.js
10
main/menu.js
@@ -59,6 +59,10 @@ function onToggleFullScreen (flag) {
|
|||||||
getMenuItem('Full Screen').checked = flag
|
getMenuItem('Full Screen').checked = flag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onToggleOpenInVlc (flag) {
|
||||||
|
getMenuItem('Open in VLC').checked = flag
|
||||||
|
}
|
||||||
|
|
||||||
function onWindowBlur () {
|
function onWindowBlur () {
|
||||||
getMenuItem('Full Screen').enabled = false
|
getMenuItem('Full Screen').enabled = false
|
||||||
getMenuItem('Float on Top').enabled = false
|
getMenuItem('Float on Top').enabled = false
|
||||||
@@ -258,6 +262,12 @@ function getMenuTemplate () {
|
|||||||
label: 'Add Subtitles File...',
|
label: 'Add Subtitles File...',
|
||||||
click: () => windows.main.dispatch('openSubtitles'),
|
click: () => windows.main.dispatch('openSubtitles'),
|
||||||
enabled: false
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Open in VLC',
|
||||||
|
type: 'checkbox',
|
||||||
|
click: () => windows.main.dispatch('toggleOpenInVlc', getMenuItem('Open in VLC')),
|
||||||
|
enabled: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -151,6 +151,16 @@ function updateElectron () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleOpenInVlc(menuItem) {
|
||||||
|
var flag = menuItem.checked;
|
||||||
|
console.log(`toggleOpenInVlc ${flag}`);
|
||||||
|
config.OPEN_IN_VLC = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOpenInVlc() {
|
||||||
|
return config.OPEN_IN_VLC;
|
||||||
|
}
|
||||||
|
|
||||||
// Events from the UI never modify state directly. Instead they call dispatch()
|
// Events from the UI never modify state directly. Instead they call dispatch()
|
||||||
function dispatch (action, ...args) {
|
function dispatch (action, ...args) {
|
||||||
// Log dispatch calls, for debugging
|
// Log dispatch calls, for debugging
|
||||||
@@ -158,6 +168,9 @@ function dispatch (action, ...args) {
|
|||||||
console.log('dispatch: %s %o', action, args)
|
console.log('dispatch: %s %o', action, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action === 'toggleOpenInVlc') {
|
||||||
|
toggleOpenInVlc(args[0]);
|
||||||
|
}
|
||||||
if (action === 'onOpen') {
|
if (action === 'onOpen') {
|
||||||
onOpen(args[0] /* files */)
|
onOpen(args[0] /* files */)
|
||||||
}
|
}
|
||||||
@@ -1061,6 +1074,17 @@ function openPlayerFromActiveTorrent (torrentSummary, index, timeout, cb) {
|
|||||||
return update()
|
return update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------
|
||||||
|
// play in VLC if set as default player (Menu: Playback / Open in VLC)
|
||||||
|
if (getOpenInVlc()) {
|
||||||
|
console.log('-- OPEN IN VLC', torrentSummary);
|
||||||
|
dispatch('vlcPlay');
|
||||||
|
update()
|
||||||
|
cb()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------
|
||||||
|
|
||||||
// otherwise, play the video
|
// otherwise, play the video
|
||||||
state.window.title = torrentSummary.files[state.playing.fileIndex].name
|
state.window.title = torrentSummary.files[state.playing.fileIndex].name
|
||||||
update()
|
update()
|
||||||
|
|||||||
Reference in New Issue
Block a user