Moode Forum
[SOLVED] moOde 9.0.5 and 9.0.7: Adding radio station to playlist does not work - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [SOLVED] moOde 9.0.5 and 9.0.7: Adding radio station to playlist does not work (/showthread.php?tid=6770)

Pages: 1 2 3 4 5 6 7 8 9 10 11


RE: moOde 9.0.5: Adding radio station to playlist does not work - kurt1970 - 08-04-2024

@TheOldPresbyope , @Tim Curtis , @Nutul I just sent you via PM a movie where I explain how to reproduce the issue, but also how you can workaround it.
As mentioned earlier, I bet on a playlist file locking issue, caused by MPD locking the file when scanning the PL folder.
The reproducer scenario works consistent on my 3 PIs.


RE: moOde 9.0.5: Adding radio station to playlist does not work - the_bertrum - 08-04-2024

(08-03-2024, 10:48 AM)kurt1970 Wrote: I use IP reservations as well, and always address my instances via the IP address instead of its name.

Bang goes my simplistic and optimistic hypothesis...

(08-03-2024, 02:44 PM)TheOldPresbyope Wrote: Aw, rats. I woke up all set to post a brilliant argument on the reasons I thought a poor WiFi connection was unlikely to be the culprit, given the symptoms you describe. Too late, you've already established that for yourself. Tongue 

Yeah I slept on it and thought - "hang on how come..." as well.


RE: moOde 9.0.5: Adding radio station to playlist does not work - the_bertrum - 08-04-2024

(08-04-2024, 08:03 AM)kurt1970 Wrote: @TheOldPresbyope , @Tim Curtis , @Nutul I just sent you via PM a movie where I explain how to reproduce the issue, but also how you can workaround it.
As mentioned earlier, I bet on a playlist file locking issue, caused by MPD locking the file when scanning the PL folder.
The reproducer scenario works consistent on my 3 PIs.

Just so I'm sure I've got the case straight in my head, you get this error when:

A stored playlist is loaded into the queue, you start to play that playlist, then you try to re-add to the playlist a station that is already on the playlist?

Or


A stored playlist is loaded into the queue, you start to play that playlist, then you try to add a new station to the playlist?

And you get the error when using the three dot on a station and selecting "add to playlist" but not when adding a station to the queue then saving the queue as a playlist?


RE: moOde 9.0.5: Adding radio station to playlist does not work - kurt1970 - 08-04-2024

(08-04-2024, 11:19 AM)the_bertrum Wrote:
(08-04-2024, 08:03 AM)kurt1970 Wrote: @TheOldPresbyope , @Tim Curtis , @Nutul I just sent you via PM a movie where I explain how to reproduce the issue, but also how you can workaround it.
As mentioned earlier, I bet on a playlist file locking issue, caused by MPD locking the file when scanning the PL folder.
The reproducer scenario works consistent on my 3 PIs.

Just so I'm sure I've got the case straight in my head, you get this error when:

A stored playlist is loaded into the queue, you start to play that playlist, then you try to re-add to the playlist a station that is already on the playlist?

Or


A stored playlist is loaded into the queue, you start to play that playlist, then you try to add a new station to the playlist?

And you get the error when using the three dot on a station and selecting "add to playlist" but not when adding a station to the queue then saving the queue as a playlist?


Hi Robert,

It's just about adding radio stations to whatever playlist. This causes an issue when 

In this video you can see what happens and how to reproduce the issue. Turn on the volume, as I explain the steps.


RE: moOde 9.0.5: Adding radio station to playlist does not work - Tim Curtis - 08-04-2024

I ran some quick tests with something playing and am not able to repro. Adding to playlist was 100% reliable.

I'd suggest adding the logging statements to playlist.php to determine if the script is crashing. A crash might help explain why the round trip between client and server is apparently not happening on your end.
https://moodeaudio.org/forum/showthread.php?tid=6770&pid=56595#pid56595

Also turn on Debug logging in System Config because there are some debugLog() statements in that script that would log errors in the moode log if the playlist file could not be opened.


RE: moOde 9.0.5: Adding radio station to playlist does not work - kurt1970 - 08-04-2024

(08-04-2024, 01:45 PM)Tim Curtis Wrote: I ran some quick tests with something playing and am not able to repro. Adding to playlist was 100% reliable.

I'd suggest adding the logging statements to playlist.php to determine if the script is crashing. A crash might help explain why the round trip between client and server is apparently not happening on your end.
https://moodeaudio.org/forum/showthread.php?tid=6770&pid=56595#pid56595

Also turn on Debug logging in System Config because there are some debugLog() statements in that script that would log errors in the moode log if the playlist file could not be opened.
Hi Tim,

Strange you cannot reproduce it. I can reproduce it on 3 different PIs and even on a fresh install. Did you follow the steps in the movie I sent you this morning?

I'll add the logging statements in playlist.php file.

Keep you posted.


RE: moOde 9.0.5: Adding radio station to playlist does not work - kurt1970 - 08-04-2024

hi @Tim Curtis

I addedd the log statements and I switched on debug logging.

Below you see a sequence of here0 and here1. These are all attempts that failed because a radio station was playing when I updated a PL.
For the last attempt I first stopped the music and tried again. As explained in my video, this worked.

In summary, logging output is the same when it works or when it fails.

Can you point me to the code where the actual write to the PL file takes place and tell me where to put some logging statements?

20240804 181128 here0
20240804 181128 here1
20240804 181214 here0
20240804 181214 here1
20240804 181228 here0
20240804 181228 here1
20240804 181422 waitWorker(): Start sys-config, w_active=0
20240804 181422 waitWorker(): End sys-config, w_active=0
20240804 181458 here0
20240804 181458 here1
20240804 181522 here0
20240804 181522 here1
20240804 181537 here0
20240804 181537 here1
20240804 181545 here0
20240804 181545 here1
20240804 181607 here0
20240804 181607 here1
20240804 181616 here0
20240804 181616 here1
20240804 181624 here0
20240804 181624 here1


RE: moOde 9.0.5: Adding radio station to playlist does not work - Tim Curtis - 08-04-2024

If you added all 4 workerLog() statements then you should see 4 log entries if the script executed to completion.
here0
here1
here2
here3

Here's that code block again.

Code:
   case 'add_to_playlist':
       $plName = html_entity_decode($_POST['path']['playlist']);
workerLog('here0);
       // Get metadata (may not exist so defaults will be returned)
       $plMeta = getPlaylistMetadata($plName);
workerLog('here1);
       // Replace with URL if radio station
       if (count($_POST['path']['items']) == 1 && substr($_POST['path']['items'][0], -4) == '.pls') {
           $stName = substr($_POST['path']['items'][0], 6, -4); // Trim RADIO/ and .pls
           $result = sqlQuery("SELECT station FROM cfg_radio WHERE name='" . SQLite3::escapeString($stName) . "'", sqlConnect());
           $_POST['path']['items'][0] = $result[0]['station']; // URL
       }
workerLog('here2);
.
.
.
workerLog('here3);
       break;



RE: moOde 9.0.5: Adding radio station to playlist does not work - kurt1970 - 08-04-2024

Hi @Tim Curtis ,

Mistake on my side, as I didn't scroll through your code fragment. All logging statements are added now.

Test 1: A radio station is playing, and I try to add a radio station to a PL. Test failed. Following info in the log:
20240804 190728 here0
20240804 190728 here1

Test 2: No radio station is playing, and I try to add a radio station to a PL. Test passed. Following info in the log:
20240804 190940 here0
20240804 190940 here1
20240804 190940 here2
20240804 190943 here3


RE: moOde 9.0.5: Adding radio station to playlist does not work - kurt1970 - 08-04-2024

Hi @Tim Curtis ,

I added some more logging in playlist.php. Now it looks like this:
Code:
case 'upd_playlist':
              $plName = html_entity_decode($_POST['path']['name']);
              // Get metadata (may not exist so defaults will be returned)
              $plMeta = getPlaylistMetadata($plName);
              $updPlMeta = array('genre' => $_POST['path']['genre'], 'cover' => $plMeta['cover']);
              $plItems = $_POST['path']['items'];

              // Write metadata tags, contents and cover image
              putPlaylistContents($plName, $updPlMeta, $plItems);
              putPlaylistCover($plName);
              break;
      case 'add_to_playlist':
              $plName = html_entity_decode($_POST['path']['playlist']);
workerLog('here0');
              // Get metadata (may not exist so defaults will be returned)
              $plMeta = getPlaylistMetadata($plName);
workerLog('here1');

              // Replace with URL if radio station
              if (count($_POST['path']['items']) == 1 && substr($_POST['path']['items'][0], -4) == '.pls') {

workerLog('here1.1');
                      $stName = substr($_POST['path']['items'][0], 6, -4); // Trim RADIO/ and .pls
workerLog('here1.2');
                      $result = sqlQuery("SELECT station FROM cfg_radio WHERE name='" . SQLite3::escapeString($stName) . "'", sqlConnect());
workerLog('here1.3');
                      $_POST['path']['items'][0] = $result[0]['station']; // URL
              }
workerLog('here2');

              // Write metadata tags, contents and cover image
              putPlaylistMetadata($plName, array('#EXTGENRE:' . $plMeta['genre'], '#EXTIMG:' . $plMeta['cover']));
              putPlaylistContents($plName, $plMeta, $_POST['path']['items'], FILE_APPEND);
              putPlaylistCover($plName);
workerLog('here3');
              break;


Test 1: A radio station is playing, and I try to add a radio station to a PL. Test failed. Following info in the log:
20240804 193502 here0
20240804 193502 here1

Test 2: No radio station is playing, and I try to add a radio station to a PL. Test passed. Following info in the log:
20240804 193533 here0
20240804 193533 here1
20240804 193533 here1.1
20240804 193533 here1.2
20240804 193533 here1.3
20240804 193533 here2
20240804 193536 here3