Skip to content

Commit

Permalink
✨ Improve remote control
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerluiz committed Jul 24, 2020
1 parent 61df117 commit a9f7581
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 78 deletions.
19 changes: 14 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,17 +352,18 @@ function createWindow() {
})

function updateActivity() {
var trackInfo = infoPlayerProvider.getTrackInfo()
var playerInfo = infoPlayerProvider.getPlayerInfo()
var trackInfo = infoPlayerProvider.getTrackInfo()

var progress = playerInfo.statePercent
var trackId = trackInfo.id
var title = trackInfo.title
var author = trackInfo.author
var album = trackInfo.album
var duration = trackInfo.duration
var progress = trackInfo.statePercent
var cover = trackInfo.cover
var nowPlaying = `${title} - ${author}`
logDebug(nowPlaying)
// logDebug(nowPlaying)

if (title && author) {
discordRPC.setActivity(getAll())
Expand All @@ -377,7 +378,7 @@ function createWindow() {
mediaControl.setProgress(
mainWindow,
settingsProvider.get('settings-enable-taskbar-progressbar')
? trackInfo.statePercent
? progress
: -1,
playerInfo.isPaused
)
Expand Down Expand Up @@ -415,6 +416,10 @@ function createWindow() {
if (lastTrackId !== trackId) {
lastTrackId = trackId

infoPlayerProvider.updateQueueInfo()
infoPlayerProvider.updatePlaylistInfo()
infoPlayerProvider.isInLibrary()

if (isMac()) {
global.sharedObj.title = nowPlaying
renderer_for_status_bar.send('update-status-bar')
Expand Down Expand Up @@ -717,6 +722,10 @@ function createWindow() {
case 'media-add-library':
mediaControl.addToLibrary(view)
break

case 'media-add-playlist':
mediaControl.addToPlaylist(view, value)
break
}
})

Expand Down Expand Up @@ -1204,7 +1213,7 @@ function createWindow() {

var ytmdesktop_version = app.getVersion() || '-'

var template = `- [ ] I understand that %2A%2AYTMDesktop have NO affiliation with Google or YouTube%2A%2A.%0A- [ ] I verified that there is no open issue for the same subject.%0A%0A %2A%2ADescribe the bug%2A%2A%0A A clear and concise description of what the bug is.%0A%0A %2A%2ATo Reproduce%2A%2A%0A Steps to reproduce the behavior:%0A 1. Go to '...'%0A 2. Click on '....'%0A 3. See error%0A%0A %2A%2AExpected behavior%2A%2A%0A A clear and concise description of what you expected to happen.%0A%0A %2A%2AScreenshots%2A%2A%0A If applicable, add screenshots to help explain your problem.%0A%0A %2A%2AEnvironment (please complete the following information):%2A%2A%0A %2A YTMDesktop version: %2A%2A%2Av${ytmdesktop_version}%2A%2A%2A%0A %2A OS: %2A%2A%2A${os_platform}%2A%2A%2A%0A %2A OS version: %2A%2A%2A${os_system_version}%2A%2A%2A%0A %2A Arch: %2A%2A%2A${os_arch}%2A%2A%2A%0A %2A Installation way: %2A%2A%2Alike .exe or snapcraft or another way%2A%2A%2A%0A`
var template = `- [ ] I understand that %2A%2AYTMDesktop have NO affiliation with Google or YouTube%2A%2A.%0A- [ ] I verified that there is no open issue for the same subject.%0A%0A %2A%2ADescribe the bug%2A%2A%0A A clear and concise description of what the bug is.%0A%0A %2A%2ATo Reproduce%2A%2A%0A Steps to reproduce the behavior:%0A 1. Go to '...'%0A 2. Click on '....'%0A 3. See error%0A%0A %2A%2AExpected behavior%2A%2A%0A A clear and concise description of what you expected to happen.%0A%0A %2A%2AScreenshots%2A%2A%0A If applicable, add screenshots to help explain your problem.%0A%0A %2A%2AEnvironment:%2A%2A%0A %2A YTMDesktop version: %2A%2A%2Av${ytmdesktop_version}%2A%2A%2A%0A %2A OS: %2A%2A%2A${os_platform}%2A%2A%2A%0A %2A OS version: %2A%2A%2A${os_system_version}%2A%2A%2A%0A %2A Arch: %2A%2A%2A${os_arch}%2A%2A%2A%0A %2A Installation way: %2A%2A%2Alike .exe or snapcraft or another way%2A%2A%2A%0A`
shell.openExternal(
`https://github.com/ytmdesktop/ytmdesktop/issues/new?body=${template}`
)
Expand Down
53 changes: 47 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
},
"devDependencies": {
"electron": "^9.1.0",
"electron": "^9.1.1",
"electron-builder": "^22.7.0",
"husky": "^4.2.5",
"prettier": "^2.0.5",
Expand Down Expand Up @@ -51,7 +51,8 @@
"scribble": "0.0.5",
"socket.io": "^2.3.0",
"uuid": "^8.2.0",
"ws": "^7.3.1"
"ws": "^7.3.1",
"zeroconf": "^0.1.4"
},
"optionalDependencies": {
"@nodert-win10/windows.media.playback": "^0.2.96",
Expand Down
14 changes: 7 additions & 7 deletions src/pages/lyrics/lyrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ function getLyric(artist, song, id) {

retrieveOVHData(artist, song)
.then((success) => {
setLyrics('OVH', success)
setLyrics('OVH', success, true)
})
.catch((_) => {
retrieveVagalumeData(artist, song)
.then((success_) => {
setLyrics('Vagalume', success_)
setLyrics('Vagalume', success_, true)
})
.catch((_) => {
retrieveKsoftData(artist, song)
.then((success) => {
setLyrics('KSoft', success)
setLyrics('KSoft', success, true)
})
.catch((error) => {
elementLyric.innerText = error
setLyrics('-', error)
setLyrics('-', error, true)
})
})
})
Expand All @@ -87,17 +87,17 @@ function getLyric(artist, song, id) {
}
}

function setLyrics(source, lyrics) {
function setLyrics(source, lyrics, hasLoaded) {
elementLyricSource.innerText = `Lyrics provided by ${source}`
elementLyric.innerText = lyrics
document.getElementById('content').scrollTop = 0
infoPlayerProvider.setLyrics(source, lyrics)
infoPlayerProvider.updateLyrics(source, lyrics, hasLoaded)
}

function loadingLyrics() {
elementLyricSource.innerText = ''
elementLyric.innerText = __.trans('LABEL_LOADING')
infoPlayerProvider.setLyrics('', __.trans('LABEL_LOADING'))
infoPlayerProvider.updateLyrics('', __.trans('LABEL_LOADING'), false)
}

function removeAccents(strAccents) {
Expand Down
Loading

0 comments on commit a9f7581

Please sign in to comment.