mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-25 10:30:26 +00:00
Central songChange function
fixed songChange for http streams Set version to 1.0.0
This commit is contained in:
parent
c04735978f
commit
2c4f0fbe7e
@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 2.6)
|
|||||||
project (ympd C)
|
project (ympd C)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "2")
|
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "3")
|
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||||
if(CMAKE_BUILD_TYPE MATCHES RELEASE)
|
if(CMAKE_BUILD_TYPE MATCHES RELEASE)
|
||||||
set(ASSETS_PATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/htdocs")
|
set(ASSETS_PATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/htdocs")
|
||||||
else()
|
else()
|
||||||
@ -12,7 +12,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(WITH_MPD_HOST_CHANGE "Let users of the web frontend change the MPD Host" ON)
|
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_IPV6 "enable IPv6 support" ON)
|
||||||
option(WITH_SSL "enable SSL support" ON)
|
option(WITH_SSL "enable SSL support" ON)
|
||||||
|
|
||||||
|
@ -518,21 +518,9 @@ function webSocketConnect() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "song_change":
|
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); }
|
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri);
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
case 'mpdhost':
|
case 'mpdhost':
|
||||||
$('#mpdhost').val(obj.data.host);
|
$('#mpdhost').val(obj.data.host);
|
||||||
@ -590,8 +578,7 @@ function get_appropriate_ws_url()
|
|||||||
return pcol + u[0] + separator + "ws";
|
return pcol + u[0] + separator + "ws";
|
||||||
}
|
}
|
||||||
|
|
||||||
var updateVolumeIcon = function(volume)
|
function updateVolumeIcon(volume) {
|
||||||
{
|
|
||||||
$('#volumePrct').text(volume+' %');
|
$('#volumePrct').text(volume+' %');
|
||||||
if(volume == 0) {
|
if(volume == 0) {
|
||||||
$("#volume-icon").text("volume_off");
|
$("#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');
|
$("#play-icon").text('play_arrow');
|
||||||
|
|
||||||
if(state == 1) { // stop
|
if(state == 1) { // stop
|
||||||
$("#play-icon").text('play_arrow');
|
$("#play-icon").text('play_arrow');
|
||||||
document.getElementById('player').pause();
|
|
||||||
playstate = 'stop';
|
playstate = 'stop';
|
||||||
} else if(state == 2) { // play
|
} else if(state == 2) { // play
|
||||||
$("#play-icon").text('pause');
|
$("#play-icon").text('pause');
|
||||||
playstate = 'play';
|
playstate = 'play';
|
||||||
} else { // pause
|
} else { // pause
|
||||||
$("#play-icon").text('play_arrow');
|
$("#play-icon").text('play_arrow');
|
||||||
document.getElementById('player').pause();
|
|
||||||
playstate = 'pause';
|
playstate = 'pause';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function updateDB() {
|
function updateDB() {
|
||||||
socket.send('MPD_API_UPDATE_DB');
|
socket.send('MPD_API_UPDATE_DB');
|
||||||
showNotification('Updating MPD Database...','','','success');
|
showNotification('Updating MPD Database...','','','success');
|
||||||
@ -841,21 +823,36 @@ function notificationsSupported() {
|
|||||||
return "Notification" in window;
|
return "Notification" in window;
|
||||||
}
|
}
|
||||||
|
|
||||||
function songNotify(title, artist, album) {
|
function songChange(title, artist, album, uri) {
|
||||||
var textNotification = '';
|
var textNotification = '';
|
||||||
var htmlNotification = '';
|
var htmlNotification = '';
|
||||||
var pageTitle = 'myMPD: ';
|
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;
|
textNotification += artist;
|
||||||
htmlNotification += '<br/>' + artist;
|
htmlNotification += '<br/>' + artist;
|
||||||
pageTitle += 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;
|
textNotification += ' - ' + album;
|
||||||
htmlNotification += '<br/>' + album;
|
htmlNotification += '<br/>' + album;
|
||||||
|
$('#album').text(album);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#album').text('');
|
||||||
}
|
}
|
||||||
if(typeof title != 'undefined' && title.length > 0) {
|
if(typeof title != 'undefined' && title.length > 0) {
|
||||||
pageTitle += title;
|
pageTitle += title;
|
||||||
|
$('#currenttrack').text(title);
|
||||||
|
} else {
|
||||||
|
$('#currenttrack').text('');
|
||||||
}
|
}
|
||||||
document.title = pageTitle;
|
document.title = pageTitle;
|
||||||
showNotification(title,textNotification,htmlNotification,'success');
|
showNotification(title,textNotification,htmlNotification,'success');
|
||||||
|
@ -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);
|
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);
|
n = mpd_put_current_song(mpd.buf);
|
||||||
mg_websocket_write(c, 1, mpd.buf, n);
|
mg_websocket_write(c, 1, mpd.buf, n);
|
||||||
@ -654,6 +654,8 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
|||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
|
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_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_raw_str(cur, end - cur, ",\"album\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
|
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
||||||
|
Loading…
Reference in New Issue
Block a user