I am trying to make a button to search for the album of the playing song.
This works up to a point.
search_options "title" off &
search_options "filepath" off &
search_options "filename" off &
search_options "comment" off &
search_options "album" on &
search_options "author" off &
Search `get_loaded_song 'album'` &
browser_sort '+album'
But... when I try to set the search options back to where they were, it no longer searches only the album field.
search_options "title" off &
search_options "filepath" off &
search_options "filename" off &
search_options "comment" off &
search_options "album" on &
search_options "author" off &
Search `get_loaded_song 'album'` &
browser_sort '+album' &
search_options "filepath" on &
search_options "filename" on &
search_options "comment" on &
search_options "album" on &
search_options "author" on
According to djdad (from an older post), scripts aren't executed in order (which makes my head hurt). I guess this explains why it doesn't work but is there another way to have the script reset the search options?
This works up to a point.
search_options "title" off &
search_options "filepath" off &
search_options "filename" off &
search_options "comment" off &
search_options "album" on &
search_options "author" off &
Search `get_loaded_song 'album'` &
browser_sort '+album'
But... when I try to set the search options back to where they were, it no longer searches only the album field.
search_options "title" off &
search_options "filepath" off &
search_options "filename" off &
search_options "comment" off &
search_options "album" on &
search_options "author" off &
Search `get_loaded_song 'album'` &
browser_sort '+album' &
search_options "filepath" on &
search_options "filename" on &
search_options "comment" on &
search_options "album" on &
search_options "author" on
According to djdad (from an older post), scripts aren't executed in order (which makes my head hurt). I guess this explains why it doesn't work but is there another way to have the script reset the search options?
Posté Wed 11 Dec 19 @ 6:43 pm
try this for searching
setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '+album'
let me try figure out your searchfields number for the other
Try that
setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '+album' & repeat_start 'BrowserIsntInstant' 100ms 1 & setting 'searchFields' 63
setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '+album'
let me try figure out your searchfields number for the other
Try that
setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '+album' & repeat_start 'BrowserIsntInstant' 100ms 1 & setting 'searchFields' 63
Posté Wed 11 Dec 19 @ 6:53 pm
The deal is the browser search isn't instant, it's quick but needs a few ms to do it.
Script is more or less instant, so I added a repeat_start to add 100ms delay before resetting the fields
Also I used setting "searchField" X
each field has a value 2^n, so so for the zeroth and first choices the X value would be 3 [Title & Artist] [2^0 + 2^1]
Album is 6th in the list [but number 5 in computer geeky start counting from zero maths stuff] so 2^5 == 32
Script is more or less instant, so I added a repeat_start to add 100ms delay before resetting the fields
Also I used setting "searchField" X
each field has a value 2^n, so so for the zeroth and first choices the X value would be 3 [Title & Artist] [2^0 + 2^1]
Album is 6th in the list [but number 5 in computer geeky start counting from zero maths stuff] so 2^5 == 32
Posté Wed 11 Dec 19 @ 7:27 pm
Thanks that is an easier way to set the search options but the result is the same. It works once, but if you highlight another song it reverts back to option 63. Even on subsequent searches. It seems highlighting another song should have no effect on the script but it does. I tried increasing the delay to 5000ms... same result. I even tried scrolling 5 times with the rs, which works fine after the delay but the search options seem to ignore the delay.
Posté Wed 11 Dec 19 @ 7:29 pm
There seems to be a race going on. The number of results varies from time to time with some searches including results from fields other than 'album' but not always the same amount of songs. Weird.
Posté Wed 11 Dec 19 @ 7:51 pm
try this
setting 'searchFields' 32 & repeat_start_instant 'BrowserIsntInstant' 200ms 2 & toggle '$flipflop' & var '$flipflop' 1 ? search `get_loaded_song 'album'` & browser_sort '+album' : setting 'searchFields' 63
setting 'searchFields' 32 & repeat_start_instant 'BrowserIsntInstant' 200ms 2 & toggle '$flipflop' & var '$flipflop' 1 ? search `get_loaded_song 'album'` & browser_sort '+album' : setting 'searchFields' 63
Posté Wed 11 Dec 19 @ 7:58 pm
I suppose database size comes into play. see what gives full results & add more ms
Posté Wed 11 Dec 19 @ 8:00 pm
Thanks! That appears to work. My DB is not that large, about 35000 songs.
Posté Wed 11 Dec 19 @ 10:34 pm
Did some more testing. Seems the rs was not needed. The toggle alone did the trick. I can't understand why but I won't argue with success!
setting 'searchFields' 32 & toggle '$flipflop' & search `get_loaded_song 'album'` & browser_sort '+album' & setting 'searchFields' 63
Nope. I take that back, It was not always right but your script has worked reliably so far.
setting 'searchFields' 32 & toggle '$flipflop' & search `get_loaded_song 'album'` & browser_sort '+album' & setting 'searchFields' 63
Nope. I take that back, It was not always right but your script has worked reliably so far.
Posté Wed 11 Dec 19 @ 10:52 pm
One more question. Is it possible to sort on two fields such as browser_sort 'album, track' ? If so what is the syntax?
Posté Wed 11 Dec 19 @ 11:42 pm
same as sorting one field, the last one you call becomes the primary order, the one called before the last one becomes the secondary so I guess you want
browser_sort 'track' & browser_sort 'album'
browser_sort 'track' & browser_sort 'album'
Posté Thu 12 Dec 19 @ 4:43 am
See if this works consistently
set '$flipflop' 0 & setting 'searchFields' 32 & repeat_start_instant 'BrowserIsntInstant' 100ms 6 & cycle '$flipflop' 6 & var '$flipflop' 0 ? setting 'searchFields' 63 : var '$flipflop' 3 ? search `get_loaded_song 'album'` & browser_sort '+album' : nothing
set '$flipflop' 0 & setting 'searchFields' 32 & repeat_start_instant 'BrowserIsntInstant' 100ms 6 & cycle '$flipflop' 6 & var '$flipflop' 0 ? setting 'searchFields' 63 : var '$flipflop' 3 ? search `get_loaded_song 'album'` & browser_sort '+album' : nothing
Posté Thu 12 Dec 19 @ 8:42 am
It does search correctly but it hangs up occasionally for some reason. I did find another way that works and could possibly help in other situations where sequencing is a problem.
down ? setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '-track' : setting 'searchFields' 63
Thanks for the tip on sorting! I have been working on that for weeks and it never occurred to me to use two commands. I was trying to pack it into one.
down ? setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '-track' : setting 'searchFields' 63
Thanks for the tip on sorting! I have been working on that for weeks and it never occurred to me to use two commands. I was trying to pack it into one.
Posté Thu 12 Dec 19 @ 6:21 pm