Windows Thumbnail Bar

* While in the player view, show a play/pause toggle in the thumbnail
This commit is contained in:
Gediminas Petrikas
2016-04-23 21:34:49 +03:00
committed by DC
parent 7526b18507
commit 15f733f11c
6 changed files with 49 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ var shell = require('./shell')
var shortcuts = require('./shortcuts')
var vlc = require('./vlc')
var windows = require('./windows')
var thumbnail = require('./thumbnail')
// Messages from the main process, to be sent once the WebTorrent process starts
var messageQueueMainToWebTorrent = []
@@ -68,6 +69,10 @@ function init () {
shortcuts.onPlayerOpen()
})
ipc.on('updateThumbnailBar', function (e, isPaused) {
thumbnail.updateThumbarButtons(isPaused)
})
/**
* Power Save Blocker
*/

View File

@@ -16,6 +16,7 @@ var config = require('../config')
var dialog = require('./dialog')
var shell = require('./shell')
var windows = require('./windows')
var thumbnail = require('./thumbnail')
var menu
@@ -33,6 +34,8 @@ function onPlayerClose () {
getMenuItem('Increase Speed').enabled = false
getMenuItem('Decrease Speed').enabled = false
getMenuItem('Add Subtitles File...').enabled = false
thumbnail.showPlayerThumbnailBar()
}
function onPlayerOpen () {
@@ -44,6 +47,8 @@ function onPlayerOpen () {
getMenuItem('Increase Speed').enabled = true
getMenuItem('Decrease Speed').enabled = true
getMenuItem('Add Subtitles File...').enabled = true
thumbnail.hidePlayerThumbnailBar()
}
function onToggleAlwaysOnTop (flag) {

35
main/thumbnail.js Normal file
View 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)
}

View File

@@ -372,14 +372,18 @@ function pause () {
function playPause () {
if (state.location.url() !== 'player') return
if (state.playing.isPaused) {
play()
} else {
pause()
}
// force rerendering if window is hidden,
// in order to bypass `raf` and play/pause media immediately
if (!state.window.isVisible) render(state)
ipcRenderer.send('updateThumbnailBar', state.playing.isPaused)
}
function jumpToTime (time) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B