diff --git a/package.json b/package.json index d37b1ac..fc65213 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "top.yutent.sonist", - "version": "2.0.0-alpha-3", + "version": "2.0.0-alpha-4", "description": "Music Player", "main": "src/main.js", "scripts": { diff --git a/src/depends.html b/src/depends.html deleted file mode 100644 index 5aafa24..0000000 --- a/src/depends.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - -

欢迎使用Sonist!

-
-检测到你系统中没有安装ffmpeg。
-请先安装ffmpeg。
-
-如果你的系统是MacOS, 可以使用brew来安装:
-brew install ffmpeg
-
-如果你的系统是Linux, 可以使用包管理器"apt/yum/pacman等来安装":
-sudo apt install ffmpeg   # 以debian系为例
-
-
- - \ No newline at end of file diff --git a/src/desktop-lrc.html b/src/desktop-lrc.html deleted file mode 100644 index 588ccd6..0000000 --- a/src/desktop-lrc.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - -
-
- -
-
- -
-
-
-
- -
-
- -
-
- - -
- - -
- - \ No newline at end of file diff --git a/src/js/app.js b/src/js/app.js index 390066a..78af4df 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -229,6 +229,7 @@ Anot({ } return } + // player.stop() this.curr = i this.song.name = it.name this.song.artist = it.artist @@ -240,6 +241,8 @@ Anot({ player.play(i) this.$refs.list.scrollTop = (i - 3) * 26 + app.dispatch('update-lrc', { lrc: '正在播放: ' + it.name }) + // if (!it.lrc) { // Api.searchLrc(it.name, it.duration).then(list => { // var { id, accesskey } = list[0] diff --git a/src/js/lib/audio/index.js b/src/js/lib/audio/index.js index 3e16346..a937091 100644 --- a/src/js/lib/audio/index.js +++ b/src/js/lib/audio/index.js @@ -72,8 +72,10 @@ export default class Player { this.gain = this.__AC__.createGain() this.gain.gain.value = this.volume - this.track = this.__AC__.createMediaElementSource(this.__AUDIO__) - this.track.connect(this.gain).connect(this.__AC__.destination) + this.track = this.__AC__ + .createMediaElementSource(this.__AUDIO__) + .connect(this.gain) + .connect(this.__AC__.destination) } get volume() { @@ -147,6 +149,7 @@ export default class Player { stop() { if (this.track) { + this.track.disconnect() this.track = null this.gain = null this.__destroy__() diff --git a/src/main.js b/src/main.js index a67467c..2f10992 100644 --- a/src/main.js +++ b/src/main.js @@ -4,13 +4,13 @@ * @date 2020/11/18 09:27:09 */ -const { app, session, protocol, globalShortcut } = require('electron') +const { app, session, protocol, globalShortcut, ipcMain } = require('electron') const path = require('path') const fs = require('iofs') require('./tools/init.js') -const { createMainWindow, createMiniWindow } = require('./tools/windows.js') +const { createMainWindow } = require('./tools/windows.js') const MIME_TYPES = { '.js': 'text/javascript', @@ -45,14 +45,14 @@ protocol.registerSchemesAsPrivileged([ // 初始化应用 app.once('ready', () => { // 注册协议 - protocol.registerBufferProtocol('app', function(req, cb) { + protocol.registerBufferProtocol('app', function (req, cb) { var file = decodeURIComponent(req.url.replace(/^app:\/\/local\//, '')) var ext = path.extname(req.url) var buff = fs.cat(path.resolve(__dirname, file)) cb({ data: buff, mimeType: MIME_TYPES[ext] }) }) - protocol.registerBufferProtocol('sonist', function(req, cb) { + protocol.registerBufferProtocol('sonist', function (req, cb) { var file = decodeURIComponent(req.url.replace(/^sonist:[\/]+/, '/')) var ext = path.extname(req.url) cb({ data: fs.cat(file), mimeType: MIME_TYPES[ext] || MIME_TYPES.all }) @@ -70,6 +70,18 @@ app.once('ready', () => { win.restore() } }) + + ipcMain.on('app', (ev, conn) => { + switch (conn.type) { + case 'update-lrc': + win.__lrc__.setTitle(conn.data.lrc) + ev.returnValue = true + break + + default: + break + } + }) }) // 退出前清空所有快捷键 diff --git a/src/mini-win.html b/src/mini-win.html deleted file mode 100644 index d7c9624..0000000 --- a/src/mini-win.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - -
- - - -
-

-
- - - - - -
-
-
- - -
- -
- - - -
- -
- - \ No newline at end of file diff --git a/src/tools/tray.js b/src/tools/tray.js index 1c07a85..01f5193 100644 --- a/src/tools/tray.js +++ b/src/tools/tray.js @@ -5,7 +5,7 @@ */ const path = require('path') -const { ipcMain, Tray, Menu, nativeImage } = require('electron') +const { Tray, Menu, nativeImage } = require('electron') const ICON_DICT = { app: path.join(__dirname, '../images/trays/tray.png'), @@ -74,7 +74,7 @@ exports.createAppTray = function (win) { exports.createLrcTray = function (win) { var tray = create() - tray.setTitle('这是顶栏歌词, blablablabla...') + tray.setTitle('Hello Sonist!') win.__lrc__ = tray return tray diff --git a/src/tools/windows.js b/src/tools/windows.js index 2714913..0a86d18 100644 --- a/src/tools/windows.js +++ b/src/tools/windows.js @@ -24,7 +24,6 @@ exports.createMainWindow = function (icon) { maximizable: false, icon, transparent: true, - backgroundColor: '#00ffffff', vibrancy: 'dark', visualEffectState: 'active', webPreferences: { @@ -47,7 +46,7 @@ exports.createMainWindow = function (icon) { win.on('ready-to-show', _ => { win.show() - win.openDevTools() + // win.openDevTools() }) win.on('close', ev => { @@ -57,29 +56,3 @@ exports.createMainWindow = function (icon) { return win } - -/** - * 应用迷你窗口 - */ -exports.createMiniWindow = function (screen) { - let win = new BrowserWindow({ - title: '', - width: 320, - height: 60, - frame: false, - resizable: false, - alwaysOnTop: true, - skipTaskbar: true, - x: screen.width - 320, - y: 0, - show: false, - webPreferences: { - webSecurity: false, - experimentalFeatures: true, - nodeIntegration: true - } - }) - - win.loadURL('app://local/mini-win.html') - return win -}