Giter VIP home page Giter VIP logo

Comments (9)

subratappt avatar subratappt commented on May 14, 2024 1

Thank you for the implementation.

Version: 1.3.1

  1. For Windows, when the tray is on, please change close button behaviour of window from quit to hide.
  2. In the tray, play/pause is not working properly.

from youtube-music.

benji009 avatar benji009 commented on May 14, 2024 1

Is it possible to add auto start when you turn on the computer?

from youtube-music.

th-ch avatar th-ch commented on May 14, 2024 1

Hey @benji009, thank you for the feedback!

#32 adds an option to autostart the application at login (YouTube Music then starts playing automatically) which is available in the 1.4.0 pre-release but only works for Mac/Win (limitation of electron), would this do the job for you?

from youtube-music.

benji009 avatar benji009 commented on May 14, 2024 1

yes that is perfect :)

from youtube-music.

subratappt avatar subratappt commented on May 14, 2024

The following codes will give you tray

const path = require('path');
const trayIcon = path.join(__dirname, 'assets/icon.ico');
//const trayIcon = nativeImage.createFromPath("./assets/icon.png");

app.on("ready", () => {
  tray = new Tray(trayIcon)
  const contextMenu = Menu.buildFromTemplate([
    {
      label: 'Play/Pause', click: function () {
        hook_ytm("#left-controls > div > paper-icon-button.play-pause-button.style-scope.ytmusic-player-bar")
      }
    },
    {
      label: 'Next', click: function () {
        hook_ytm("#left-controls > div > paper-icon-button.next-button.style-scope.ytmusic-player-bar")
      }
    },
    {
      label: 'Prev', click: function () {
        hook_ytm("#left-controls > div > paper-icon-button.previous-button.style-scope.ytmusic-player-bar")
      }
    },
    {
      label: 'Show', click: function () {
        win.show()
      }
    },

    {
      label: 'Quit', click: function () {
        app.quit()
      }
    },
  ])
  tray.setToolTip('Youtube Music')
  tray.on('double-click', () => {
    win.show()
  })
  if (process.platform == 'win32') {
    tray.on('click', tray.popUpContextMenu)
  }
  tray.setContextMenu(contextMenu);
  createWindow();
}
)

// bla bla bla

async function createWindow() {
  win = new BrowserWindow({
    backgroundColor: "#000",
    webPreferences: { nodeIntegration: false, contextIsolation: true },
	// bla bla bla
  })

  win.on('close', (event) => {
    if (app.quitting) {
      win = null
    } else {
      if (process.platform == 'darwin') {
        app.dock.hide()
      }
      event.preventDefault()
      win.hide()
    }
  })

  await win.loadURL('https://music.youtube.com')

  return win;
}


function hook_ytm(selector) {
  win.webContents.executeJavaScript('document.querySelector("' + selector + '").click();', true)
}

from youtube-music.

th-ch avatar th-ch commented on May 14, 2024

Hey @fernandogobah , thanks for submitting the issue! The latest version (v1.3.1) has an "options" menu, you can enable tray and set the window visible or hidden - with "Tray + hidden window", you should have the behavior "start in tray".

Feel free to re-open this issue if it does not work properly!

PS: Thank you @subratappt for the code snippet, it has been implemented in the app!

from youtube-music.

th-ch avatar th-ch commented on May 14, 2024

Hey @subratappt, thanks for reporting both issues!

v1.3.2 should fix issue 1, the app should now not exit if the tray is on (unless you select "Quit" in the tray menu) + clicking on the tray icon should now show/hide the app.

For the second issue, play/pause seems to work fine for me (tested on Windows/Mac) unless the plugin "autoconfirm when paused" is enabled (playing is resumed automatically by the plugin just after pausing), do yo have it enabled? This plugin is still quite experimental (it also messes up with play/pause through media keys) - if you don't have this plugin enabled, then it might be another bug! - which plugins do you use in the app?

from youtube-music.

subratappt avatar subratappt commented on May 14, 2024

Hey @subratappt, thanks for reporting both issues!

v1.3.2 should fix issue 1, the app should now not exit if the tray is on (unless you select "Quit" in the tray menu) + clicking on the tray icon should now show/hide the app.

For the second issue, play/pause seems to work fine for me (tested on Windows/Mac) unless the plugin "autoconfirm when paused" is enabled (playing is resumed automatically by the plugin just after pausing), do yo have it enabled? This plugin is still quite experimental (it also messes up with play/pause through media keys) - if you don't have this plugin enabled, then it might be another bug! - which plugins do you use in the app?

Thank you for the update. Yes for the second issue, "autoconfirm when paused" was enabled. I hope you will get the issue solved soon.

from youtube-music.

th-ch avatar th-ch commented on May 14, 2024

It seems the last open problem in this issue is the auto-confirm-when-paused vs media keys - it seems it is fixed in the last versions but in case it's not, it will be tracked in #129 - closing this one, feel free to re-open/open a new issue if needed!

from youtube-music.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.