Gramophone icon indicating copy to clipboard operation
Gramophone copied to clipboard

[FR] associate Gramophone with .m3u files

Open lschierer opened this issue 1 year ago • 8 comments

Is your feature request related to a problem? Please describe. I have some shell scripts that generate m3u playlists from my long use of mpd. Gramophone can use these, but takes forever to see a new one. When I go to open one in Android file browser, it doesn't give me the option to open the file with Gramophone, even though it can clearly use them once it has noticed them. please associate the app with these files so I can manually add any playlists I create outside the app.

Describe the solution you'd like Gramophone is an option to open m3u files with. Doing so adds them to the available playlists.

Describe alternatives you've considered the refresh button could cause it to notice a new playlist and not just new songs.

Additional context

lschierer avatar May 16 '24 14:05 lschierer

You could use this app to rescan storage media, it's been confirmed to be working on Android 13: https://f-droid.org/packages/com.gmail.jerickson314.sdscanner/ Another simple method is to rename the .m3u file using the Android built-in file manager. The Android OS does not automatically detect files placed on storage with a few methods like adb, perhaps Termux, because these don't use Android APIs but just classic filesystem. It will then only show up on the next periodic rescan.

Assosciation and telling Android to look for the opened file is planned too, yet not a solution for the underlying problem.

nift4 avatar May 16 '24 14:05 nift4

I'm running the scripts I mentioned in Termux now, I can call them whatever I want. I'm using .m3u because that's what I've always used, it sounds like there is a better extension for me to be using?

lschierer avatar May 16 '24 14:05 lschierer

No, the problem is that Termux does not (and indeed cannot) notify the Android OS of media file changes. The easiest way around it is the SD Scanner app I linked.

nift4 avatar May 16 '24 14:05 nift4

I love the .m3u format because its accessible to things like grep and shuf for shell manipulation, and I've always found a randomized playlist better than a randomization algorithm in a player (where most of the players I've come across then don't support going backwards or forwards, or knowing what songs are coming next).

lschierer avatar May 16 '24 14:05 lschierer

If Termux:API and its package are installed you can use termux-media-scan command to scan them.

pxeemo avatar May 16 '24 14:05 pxeemo

Gramophone has a couple of nice gurantees on its shuffle implementation:

  1. After enabling shuffle, all songs in the list are guranteed to play once before the list ends (the current song is the first one). The order will be completely random, though.
  2. Using the song menu item "Play next" actually plays the selected song next, but keeping all other songs shuffled.
  3. Playlist sheet shows you what the next song will be.
  4. The randomized order will change every time you change playlist or enable/disable shuffle, but will NOT change when stopping music playback and continuing on the next day (provided you haven't changed playlist in the meantime).

I also love .m3u simply because it is interoperable and I can use it everywhere. Try adding termux-media-scan to your shell scripts to instantly detect the new playlist.

nift4 avatar May 16 '24 15:05 nift4

that worked well, thanks.

lschierer avatar May 17 '24 05:05 lschierer

keeping it open as reminder for myself

nift4 avatar May 17 '24 05:05 nift4

The refresh feature recently changed and now takes several orders of magnitude longer than previous versions. since I really only need to refresh the playlists, this is change makes having a way to refresh a playlist via the UI more urgent

lschierer avatar May 28 '25 14:05 lschierer

@lschierer the refresh feature changed on the assumption that the automatic detection and reload of changes added in the previous version works well. if you run termux-media-scan on a m3u file, it should appear automatically within 5 seconds in the app.

if it doesn't for you, could you tell me whether your setup has changed since the creation of the issue? how exactly do you create and scan these m3u files? is gramophone open or closed while you create them?

nift4 avatar May 28 '25 14:05 nift4

For reference, I am currently running the following script almost daily as I switch between playing songs while putting my son to bed and then going back to my own music

~ $ cat tmplist.sh

cd ~/storage/music/playlists/
export TEMP=`mktemp -d`
sort -u Isaac.m3u > $TEMP/one
sort -u "Not Classical and Not Christmas and Not kids 2.m3u" > $TEMP/two
comm -13 $TEMP/one $TEMP/two > $TEMP/three

echo 'iTunes/Eiffel 65/Uploaded by Simpson/Blue (Da Ba Dee).mp3' >> $TEMP/three
echo 'Amazon/Harry Belafonte/Very Best of Harry Belafonte/01-03- Day-O (Banana Boat) [Remastered].mp3' >> $TEMP/three
echo 'Amazon/The Chordettes/The Chordettes Best/01 - Lollipop.mp3' >> $TEMP/three

cat $TEMP/three | shuf > ./tmp.m3u

cd $OLDPWD

rm -rf $TEMP

termux-media-scan -r ~/storage/music/playlists/

This way I neither need to try to remember where I am in a playlist nor hear the same songs over and over, nor trust the randomizer to be sufficiently different every day. It also, as I mentioned earlier in the thread preserves play order when I am thinking "what's that I just heard?" And it's an amazingly effective randomizer

lschierer avatar May 28 '25 14:05 lschierer

Gramophone is typically open when I run this, would it work better if I closed it?

lschierer avatar May 28 '25 14:05 lschierer

Oops, the last line of the script got missed when I copied.


termux-media-scan -r ~/storage/music/playlists/

Editted: Now that I'm at my desk and not on my tablet, I retroactively updated the comment above to show the full script. Sorry for the confusion.

lschierer avatar May 28 '25 14:05 lschierer

@lschierer the intention for the UX is that it auto-detects the playlist and that whether it is open or closed doesn't matter. I asked for this to try and reproduce the results.

As discussed earlier in this issue, if you amend termux-media-scan ./tmp.m3u before the cd $OLDPWD, does the playlist appear properly?

nift4 avatar May 28 '25 14:05 nift4

ah okay nevermind I see you do have a media scan, I'll try to reproduce your issue and will get back to you soon

nift4 avatar May 28 '25 14:05 nift4

I can say that visually, I actually see the playlist getting refreshed when I click refresh and it reaches that part of the refresh operation. It certainly is not getting auto detected despite the termux-media-scan. I can try running that on just the one file to see if that helps, instead of recursively on the directory.

lschierer avatar May 28 '25 14:05 lschierer

Sorry for the late reply.

I can try running that on just the one file to see if that helps, instead of recursively on the directory.

Did you ever come around to doing this? I tried to reproduce your setup as much as possible, and while a recursive termux-media-scan didn't work, termux-media-scan with the specific m3u file did.

nift4 avatar Jul 19 '25 13:07 nift4

So as best as I can tell, if the player is open, nothing I have tried prevents the need for a rescan. Sometimes went it isn't open though it picks it up as intended. It seems like it stays running a short time after I swipe up to get rid of the window maybe?

lschierer avatar Jul 19 '25 14:07 lschierer

It seems like it stays running a short time after I swipe up to get rid of the window maybe?

Hmm, Android does something like that. But I tested on my Android 14 device and about 5 seconds after reopening Gramophone, it detects the playlist change and updates the playlist.

Are you still using your Android 12 device?

nift4 avatar Jul 20 '25 07:07 nift4

No, I'm on android 17 with a Lenovo tab p12 now

lschierer avatar Jul 20 '25 12:07 lschierer

android 17?

nift4 avatar Jul 20 '25 12:07 nift4

Image

There's 17's all over the page, I got confused. Android 15 apparently, is Lenovo version 17.

lschierer avatar Jul 20 '25 12:07 lschierer

Honestly have no idea how to proceed with understanding why automatic refresh doesn't work. So I just added a "Quick refresh" option that does what the old "Refresh" option did.

nift4 avatar Jul 22 '25 16:07 nift4

awesome thanks!!

lschierer avatar Jul 22 '25 19:07 lschierer