Gibt es eine Möglichkeit mit Script auf die Tonfiles des Smartphones zuzugreifen?
Als Beispiel: Bei einer Akkuladung von 90 % spiele Sound.
Das funktioniert super mit Conditionen-Sound Aber würde es gern als Script Syntax haben wollen. Wie muss da vorgehen?
Script und Sound
Moderator: Martin
Re: Script und Sound
Action sound playing and variable from battery only can be accessed by those elements. You can still do it in script, but you have to know how to use java. I still don't know how use it yet.
Why do you want those 2 actions to be executed inside a script? Is it because you want put it into widget? Or maybe there is some grand design you want to include inside a bigger script format? Maybe there is alternative method to do it if you can share the big picture of the flow.
Why do you want those 2 actions to be executed inside a script? Is it because you want put it into widget? Or maybe there is some grand design you want to include inside a bigger script format? Maybe there is alternative method to do it if you can share the big picture of the flow.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Script und Sound
Hi,
die Idee dahinter sollte lediglich dazu dienen den Flow möglichst übersichtlich zu halten. Über das Script läuft z.B. auch die Abfrage von Akkuladung und Status.
if (battery_level > 90)
{
// Spiele Sound, z.B Alamrton von Smartphone
}
Laut Forum ist es nur möglich eine externe Tondatei abzuspielen über eine initialisierte Variable. Ich müsste also die Tondatei direkt mit Pfad ansteuern, richtig?
die Idee dahinter sollte lediglich dazu dienen den Flow möglichst übersichtlich zu halten. Über das Script läuft z.B. auch die Abfrage von Akkuladung und Status.
if (battery_level > 90)
{
// Spiele Sound, z.B Alamrton von Smartphone
}
Laut Forum ist es nur möglich eine externe Tondatei abzuspielen über eine initialisierte Variable. Ich müsste also die Tondatei direkt mit Pfad ansteuern, richtig?
Re: Script und Sound
As I understand, you want to keep all of the element execution purely in script. If that so, I suggest just keep the whole element which can be done without script the way they are. Until now, I don't know if there is a way to execute the element action in script, AFAIK Automagic doesn't have the function to do it. There is a global lock that occur when a script, expression or control UI is running. Even if there is a way to do it, you will suffer from a lot of unnecessary delay caused by the global lock. So better split them as the way they are.
But if you mean to control the sound file path per level, and create some sound based on the level; you can do it using map dan some lookup logic similar to vlookup in excel. Example, you splitted the level per 10% and give 10 different sounds for each stage. You will need a map to store all the possible path and loop the battery_level to it. You can get the battery_level from the trigger or condition battery level.
Change each level sound file path to the real sound path those you have prepared. The script will loop check the battery_level, if it is higher than one of the sounddb's key, then it will assign {path} to the sound path. After passing the script, the sound {path} will be mapped to the correct sound path according to the level. Example if your current battery_level is 42, then it will get "/sdcard/Automagic/sound/echo.mp3". You can then use {path} in the action sound, to produce the sound.
If this is not what you want, you have to be more specific. Sorry, but my German is not that good yet, I still relied on Google Translate.
But if you mean to control the sound file path per level, and create some sound based on the level; you can do it using map dan some lookup logic similar to vlookup in excel. Example, you splitted the level per 10% and give 10 different sounds for each stage. You will need a map to store all the possible path and loop the battery_level to it. You can get the battery_level from the trigger or condition battery level.
Code: Select all
sounddb = newMapFromValues(
0, "/sdcard/Automagic/sound/alpha.mp3",
10, "/sdcard/Automagic/sound/bravo.mp3",
20, "/sdcard/Automagic/sound/charlie.mp3",
30, "/sdcard/Automagic/sound/delta.mp3",
40, "/sdcard/Automagic/sound/echo.mp3",
50, "/sdcard/Automagic/sound/foxtrot.mp3",
60, "/sdcard/Automagic/sound/golf.mp3",
70, "/sdcard/Automagic/sound/hotel.mp3",
80, "/sdcard/Automagic/sound/india.mp3",
90, "/sdcard/Automagic/sound/kilo.mp3" );
for(i in getMapKeys(sounddb))
if(battery_level > i) path = sounddb[i];
If this is not what you want, you have to be more specific. Sorry, but my German is not that good yet, I still relied on Google Translate.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Script und Sound
Hi, Thanks for your help.
best regards.
best regards.