Thank you for this Andreas! I'm testing this and so far it is working great. I just have the following questions:
Is it expected BTTCurrentlyPlaying to show 0, when in reality media is playing
BTTCurrentlyPlayingApp is empty
BTTNowPlayingInfoAlbum is empty
I see that there's new var BTTNowPlayingInfoSequoia which contains all of the info now in 1 var, but how to extract only isPlaying for example or appName? chatGPT tried with JXA, but it was only able to do it in the terminal not in BTT .
All info from that should be available via the standard variables, you shouldn't need to extract yourself. If that doesn't work, I'll need to check!
Which media app are you testing with?
Is this expected? I think BTTNowPlayingInfoSequoia.bundleIdentifier is also useful piece of info, but as the the name of BTTCurrentlyPlayingApp suggests I guess it should be == BTTNowPlayingInfoSequoia.appName
If you have few spear minutes can you let me know what is the easiest way to extract the data from BTTNowPlayingInfoSequoia - this is out of curiosity. I guess I can run some external script to get the data and then tell BTT to get the data, but I guess there's more elegant/intelligent way.
5.363 might resolve this (uploading).
(Problem is the process that is playing is com.apple.WebKit.GPU, but that's a sub-process of Safari in this case - however it's always named the same even for webviews in other apps.). I'm now returning the parent processes bundle identifier if available.
If you'd like to parse a JSON like in BTTNowPlayingInfoSequoia, you'd use JSON.parse like in your ChatGPT example, but you need to return it as a string, not log it. You could also use BTT's standard Java Script, that would be more performant than JXA, but if you want to use JXA do it like this:
I could, however retrieving that info got way more expensive with 15.4, thus I would recommend to rely on BTTâs change detection and not call for manual updates too often. These variables you metioned sound quite dynamic and probably only make sense when updated continuously, correct?
The artwork identifier I donât know yet, I had hoped I could somehow get the artwork using that but thatâs something I havenât figured out yet (for spotify and music Iâll soon provide the artwork in a variable)
the BTTNowPlayingInfoSequoia variable is only updated by BTT if it recognizes a track or pause-state change in the playing media
The variable custom_var_test_title which BTT is "monitoring", in the 1st screenshot, is being set from a script running in a floating menu every X seconds, this means that the current timestamp will only be updated if new song started playing. I guess it is not ideal, but it gets the job done.
Sorry, haven't managed to get this working. Is there something aside definining a CAG with a condition BTTCurrentlyPlaying == "" and triggering this javascript?
async function someJavaScriptFunction() {
let sequoia = await get_string_variable({variableName: "BTTNowPlayingInfoSequoia"});
let json = JSON.parse(sequoia);
return json.title;
}
if possible donât query the â BTTNowPlayingInfoSequoiaâ directly, better use the standard variables like
BTTNowPlayingInfoTitle, BTTNowPlayingInfoArtist etc.. As soon as a number variable that starts with BTTNowPlaying is queried it will start the media observation
You could also do it like this
async function someJavaScriptFunction() {
let startObservation = await get_number_variable({variableName: "BTTCurrentlyPlaying"});
let sequoia = await get_string_variable({variableName: "BTTNowPlayingInfoSequoia"});
let json = JSON.parse(sequoia);
return json.title;
}
I'll add some more robust checks to automatically start the media observation with the next version.
//edit 5.382 (uploading) should also start the observation when querying only BTTNowPlayingInfoSequoia