Windows Thumbnail Bar
* While in the player view, show a play/pause toggle in the thumbnail
This commit is contained in:
@@ -15,6 +15,7 @@ var shell = require('./shell')
|
|||||||
var shortcuts = require('./shortcuts')
|
var shortcuts = require('./shortcuts')
|
||||||
var vlc = require('./vlc')
|
var vlc = require('./vlc')
|
||||||
var windows = require('./windows')
|
var windows = require('./windows')
|
||||||
|
var thumbnail = require('./thumbnail')
|
||||||
|
|
||||||
// Messages from the main process, to be sent once the WebTorrent process starts
|
// Messages from the main process, to be sent once the WebTorrent process starts
|
||||||
var messageQueueMainToWebTorrent = []
|
var messageQueueMainToWebTorrent = []
|
||||||
@@ -68,6 +69,10 @@ function init () {
|
|||||||
shortcuts.onPlayerOpen()
|
shortcuts.onPlayerOpen()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipc.on('updateThumbnailBar', function (e, isPaused) {
|
||||||
|
thumbnail.updateThumbarButtons(isPaused)
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Power Save Blocker
|
* Power Save Blocker
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ var config = require('../config')
|
|||||||
var dialog = require('./dialog')
|
var dialog = require('./dialog')
|
||||||
var shell = require('./shell')
|
var shell = require('./shell')
|
||||||
var windows = require('./windows')
|
var windows = require('./windows')
|
||||||
|
var thumbnail = require('./thumbnail')
|
||||||
|
|
||||||
var menu
|
var menu
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ function onPlayerClose () {
|
|||||||
getMenuItem('Increase Speed').enabled = false
|
getMenuItem('Increase Speed').enabled = false
|
||||||
getMenuItem('Decrease Speed').enabled = false
|
getMenuItem('Decrease Speed').enabled = false
|
||||||
getMenuItem('Add Subtitles File...').enabled = false
|
getMenuItem('Add Subtitles File...').enabled = false
|
||||||
|
|
||||||
|
thumbnail.showPlayerThumbnailBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPlayerOpen () {
|
function onPlayerOpen () {
|
||||||
@@ -44,6 +47,8 @@ function onPlayerOpen () {
|
|||||||
getMenuItem('Increase Speed').enabled = true
|
getMenuItem('Increase Speed').enabled = true
|
||||||
getMenuItem('Decrease Speed').enabled = true
|
getMenuItem('Decrease Speed').enabled = true
|
||||||
getMenuItem('Add Subtitles File...').enabled = true
|
getMenuItem('Add Subtitles File...').enabled = true
|
||||||
|
|
||||||
|
thumbnail.hidePlayerThumbnailBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onToggleAlwaysOnTop (flag) {
|
function onToggleAlwaysOnTop (flag) {
|
||||||
|
|||||||
35
main/thumbnail.js
Normal file
35
main/thumbnail.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
@@ -372,14 +372,18 @@ function pause () {
|
|||||||
|
|
||||||
function playPause () {
|
function playPause () {
|
||||||
if (state.location.url() !== 'player') return
|
if (state.location.url() !== 'player') return
|
||||||
|
|
||||||
if (state.playing.isPaused) {
|
if (state.playing.isPaused) {
|
||||||
play()
|
play()
|
||||||
} else {
|
} else {
|
||||||
pause()
|
pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
// force rerendering if window is hidden,
|
// force rerendering if window is hidden,
|
||||||
// in order to bypass `raf` and play/pause media immediately
|
// in order to bypass `raf` and play/pause media immediately
|
||||||
if (!state.window.isVisible) render(state)
|
if (!state.window.isVisible) render(state)
|
||||||
|
|
||||||
|
ipcRenderer.send('updateThumbnailBar', state.playing.isPaused)
|
||||||
}
|
}
|
||||||
|
|
||||||
function jumpToTime (time) {
|
function jumpToTime (time) {
|
||||||
|
|||||||
BIN
static/PauseThumbnailBarButton.png
Normal file
BIN
static/PauseThumbnailBarButton.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 101 B |
BIN
static/PlayThumbnailBarButton.png
Normal file
BIN
static/PlayThumbnailBarButton.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 208 B |
Reference in New Issue
Block a user