1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-06-25 22:23:16 +00:00

Central songChange function

fixed songChange for http streams
Set version to 1.0.0
This commit is contained in:
jcorporation 2018-05-24 00:42:20 +01:00
parent c04735978f
commit 2c4f0fbe7e
3 changed files with 28 additions and 29 deletions

View File

@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 2.6)
project (ympd C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "2")
set(CPACK_PACKAGE_VERSION_PATCH "3")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
if(CMAKE_BUILD_TYPE MATCHES RELEASE)
set(ASSETS_PATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/htdocs")
else()
@ -12,7 +12,7 @@ else()
endif()
option(WITH_MPD_HOST_CHANGE "Let users of the web frontend change the MPD Host" ON)
option(WITH_DYNAMIC_ASSETS "Serve assets dynamically (e.g for development/packaging)" OFF)
option(WITH_DYNAMIC_ASSETS "Serve assets dynamically (e.g for development/packaging)" ON)
option(WITH_IPV6 "enable IPv6 support" ON)
option(WITH_SSL "enable SSL support" ON)

View File

@ -518,21 +518,9 @@ function webSocketConnect() {
}
break;
case "song_change":
if (obj.data.uri) {
var coverImg='/library/'+obj.data.uri.replace(/\/[^\/]+$/,'\/folder.jpg');
$('#album-cover').css('backgroundImage','url("'+coverImg+'")');
}
if (obj.data.title) { $('#currenttrack').text(obj.data.title); }
else { $('#currenttrack').text(''); }
if(obj.data.artist) { $('#artist').text(obj.data.artist); }
else { $('#artist').text(''); }
if(obj.data.album) { $('#album').text(obj.data.album); }
else { $('#album').text(''); }
songNotify(obj.data.title, obj.data.artist, obj.data.album);
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri);
break;
case 'mpdhost':
$('#mpdhost').val(obj.data.host);
@ -590,8 +578,7 @@ function get_appropriate_ws_url()
return pcol + u[0] + separator + "ws";
}
var updateVolumeIcon = function(volume)
{
function updateVolumeIcon(volume) {
$('#volumePrct').text(volume+' %');
if(volume == 0) {
$("#volume-icon").text("volume_off");
@ -602,26 +589,21 @@ var updateVolumeIcon = function(volume)
}
}
var updatePlayIcon = function(state)
{
function updatePlayIcon(state) {
$("#play-icon").text('play_arrow');
if(state == 1) { // stop
$("#play-icon").text('play_arrow');
document.getElementById('player').pause();
playstate = 'stop';
} else if(state == 2) { // play
$("#play-icon").text('pause');
playstate = 'play';
} else { // pause
$("#play-icon").text('play_arrow');
document.getElementById('player').pause();
playstate = 'pause';
}
}
function updateDB() {
socket.send('MPD_API_UPDATE_DB');
showNotification('Updating MPD Database...','','','success');
@ -841,21 +823,36 @@ function notificationsSupported() {
return "Notification" in window;
}
function songNotify(title, artist, album) {
function songChange(title, artist, album, uri) {
var textNotification = '';
var htmlNotification = '';
var pageTitle = 'myMPD: ';
if(typeof artist != 'undefined' && artist.length > 0) {
if (typeof uri != 'undefined' && uri.length > 0) {
var coverImg='/library/'+uri.replace(/\/[^\/]+$/,'\/folder.jpg');
$('#album-cover').css('backgroundImage','url("'+coverImg+'")');
}
if(typeof artist != 'undefined' && artist.length > 0 && artist != '-') {
textNotification += artist;
htmlNotification += '<br/>' + artist;
pageTitle += artist + ' - ';
$('#artist').text(artist);
} else {
$('#artist').text('');
}
if(typeof album != 'undefined' && album.length > 0) {
if(typeof album != 'undefined' && album.length > 0 && album != '-') {
textNotification += ' - ' + album;
htmlNotification += '<br/>' + album;
$('#album').text(album);
}
else {
$('#album').text('');
}
if(typeof title != 'undefined' && title.length > 0) {
pageTitle += title;
$('#currenttrack').text(title);
} else {
$('#currenttrack').text('');
}
document.title = pageTitle;
showNotification(title,textNotification,htmlNotification,'success');

View File

@ -364,7 +364,7 @@ static int mpd_notify_callback(struct mg_connection *c, enum mg_event ev) {
{
mg_websocket_write(c, 1, mpd.buf, mpd.buf_size);
if(s->song_id != mpd.song_id)
if(s->song_id != mpd.song_id || s->queue_version != mpd.queue_version)
{
n = mpd_put_current_song(mpd.buf);
mg_websocket_write(c, 1, mpd.buf, n);
@ -653,7 +653,9 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
// cur += json_emit_raw_str(cur, end - cur, ",\"album_artist\":");
// cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_artist(song));
// cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_artist(song));
// cur += json_emit_raw_str(cur, end - cur, ",\"uri\":");
// cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song));
cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");