Old 6th October 2015, 18:57   #881
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
rotation layer

Hi peeps
I know you guys are always busy with us noobs, but if we don't ask we don't learn
I have coded all this tape deck to work as it should but I am struggling to get a script to rotate the cassette tape reels x4 at different speeds on play and stop on stop&pause.

Any help will be greatly appreciated
Steven
Attached Thumbnails
Click image for larger version

Name:	tape.png
Views:	189
Size:	44.5 KB
ID:	52024   Click image for larger version

Name:	cassette.png
Views:	162
Size:	607.7 KB
ID:	52025  
scottiescotsman is offline   Reply With Quote
Old 7th October 2015, 00:50   #882
garetjax
Candyass
(Major Dude)
 
garetjax's Avatar
 
Join Date: Apr 2001
Location: Benton, AR
Posts: 2,317
Send a message via ICQ to garetjax Send a message via AIM to garetjax Send a message via MSN to garetjax Send a message via Yahoo to garetjax
The easiest approach for me would be to have multiple images one each state

1. Stopped
2. Playing (this would be an animated layer in xml)
3. FWD (same as above but, with faster transitions)
4. RWD (same as above but, reversed)
5. Pause (Perhaps, one frame and tick back and forth)

1001skins |
That's not a skin, it's some god awful piece of skinner gunk. - Mr. Jones
garetjax is offline   Reply With Quote
Old 7th October 2015, 01:24   #883
Victhor
Late skinner & Moderator
 
Victhor's Avatar
 
Join Date: May 2003
Location: Argentina
Posts: 1,438
Quote:
Originally Posted by garetjax View Post
The easiest approach for me would be to have multiple images one each state

1. Stopped
2. Playing (this would be an animated layer in xml)
3. FWD (same as above but, with faster transitions)
4. RWD (same as above but, reversed)
5. Pause (Perhaps, one frame and tick back and forth)
And with a script you trigger each animation depending on what buttons is pressed. May be very complex if you want to use the current frame as the starting point of the next animation (so it doesn't start from 0 when it's paused and you hit FWD). But that may be optional and not really worth the trouble, the thing is I don't think I've ever seen such a script, can you do it? / point out where to?

· · TMCT · KOMODO X
Victhor is offline   Reply With Quote
Old 7th October 2015, 01:54   #884
Victhor
Late skinner & Moderator
 
Victhor's Avatar
 
Join Date: May 2003
Location: Argentina
Posts: 1,438
Quote:
Originally Posted by Victhor View Post
And with a script you trigger each animation depending on what buttons is pressed. May be very complex if you want to use the current frame as the starting point of the next animation (so it doesn't start from 0 when it's paused and you hit FWD). But that may be optional and not really worth the trouble, the thing is I don't think I've ever seen such a script, can you do it? / point out where to?
[auto-response day] the attached script here -yeah, my own post- has a simple mechanism like:

code:
System.onPlay() {
voltAnimation.show(); // Shows the animation on first play;
voltAnimation.play(); // Plays the animation the first time a song plays;
}

System.onTitleChange(string newtitle) {
voltAnimation.show();
voltAnimation.play(); // Shows and plays the animation after the playlist changes the first time;
}



So I guess it wouldn't be hard to use something like
code:
System.onNEXT() { bla bla bla..
and
System.onPREV() { bla bla bla..



and show/hide the other animations accordingly. In my experience this is easier to say than to do, so it can take (me) weeks before doing it right...

· · TMCT · KOMODO X
Victhor is offline   Reply With Quote
Old 7th October 2015, 03:24   #885
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
sorry I didn't make it clear but all 4 reels are 4 individual layers or pngs just stuck them in one png to show you them .

hope someone can do it as I just got to learn about xml. lol but learn fast as I got a good teacher
scottiescotsman is offline   Reply With Quote
Old 7th October 2015, 15:43   #886
garetjax
Candyass
(Major Dude)
 
garetjax's Avatar
 
Join Date: Apr 2001
Location: Benton, AR
Posts: 2,317
Send a message via ICQ to garetjax Send a message via AIM to garetjax Send a message via MSN to garetjax Send a message via Yahoo to garetjax
I am thinking this only needs to be several animatedlayers in the player xml; one for each state. Then it should be a matter of just enabling them in some way (like using the width/height = 0 when not in use and when x (button) is clicked set their width/height.

This is a hack; but one that should be relatively easily used.

Sample RunningDisplay.m
code:

Global AnimatedLayer1 layerStaticCassettes;
Global AnimatedLayer2 layerRunningCassettes;
Global AnimatedLayer3 layerFastRunningCassettes;
Global AnimatedLayer4 layerRewindRunningCassettes;
Global AnimatedLayer5 layerPausingCassettes;

initBehaviors() {
AnimatedLayer1.hide();
AnimatedLayer2.hide();
AnimatedLayer3.hide();
AnimatedLayer4.hide();
AnimatedLayer5.hide();
}

System.onPlay() {
AnimatedLayer1.hide();
AnimatedLayer2.show()
AnimatedLayer3.hide();
AnimatedLayer4.hide();
AnimatedLayer5.hide();
}

System.onStop() {
AnimatedLayer1.show();
AnimatedLayer2.hide()
AnimatedLayer3.hide();
AnimatedLayer4.hide();
AnimatedLayer5.hide();
}
System.onPause() {
AnimatedLayer1.hide();
AnimatedLayer2.hide()
AnimatedLayer3.hide();
AnimatedLayer4.hide();
AnimatedLayer5.show();
}
System.onResume(){
AnimatedLayer1.hide();
AnimatedLayer2.Show()
AnimatedLayer3.hide();
AnimatedLayer4.hide();
AnimatedLayer5.hide();
}

System.onNext() {
AnimatedLayer1.hide();
AnimatedLayer2.hide()
AnimatedLayer3.Show();
AnimatedLayer4.hide();
AnimatedLayer5.hide();
}
System.onPrev() {
AnimatedLayer1.hide();
AnimatedLayer2.hide()
AnimatedLayer3.hide();
AnimatedLayer4.show();
AnimatedLayer5.hide();
}




Note: This is pseudo code for a maki script to handle animated layer swapping based on user clicks.

1001skins |
That's not a skin, it's some god awful piece of skinner gunk. - Mr. Jones
garetjax is offline   Reply With Quote
Old 7th October 2015, 17:23   #887
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
Cool

I like the theory as same was in flash I was doing a project.
question 1
wouldn't all layers be running constant even though invisible?
question 2
or would you save the position of the active layer on button click so that the next visible layer would start as the same position ?

thanks for your help guys
Steven

ps. if we or you lol figure this out it be so cool for all different animations in winamp skinning
scottiescotsman is offline   Reply With Quote
Old 7th October 2015, 17:32   #888
garetjax
Candyass
(Major Dude)
 
garetjax's Avatar
 
Join Date: Apr 2001
Location: Benton, AR
Posts: 2,317
Send a message via ICQ to garetjax Send a message via AIM to garetjax Send a message via MSN to garetjax Send a message via Yahoo to garetjax
The hide method disables the acrive layer. Technically it is still running I suppose, but as it is an png is should be very limited...And of course you could just disable the frame entirely instead of hiding/showing. And yes ro question 2, the ordinal position are.expected to be in the same position...though it could be u used in any situation.

1001skins |
That's not a skin, it's some god awful piece of skinner gunk. - Mr. Jones
garetjax is offline   Reply With Quote
Old 8th October 2015, 13:43   #889
Victhor
Late skinner & Moderator
 
Victhor's Avatar
 
Join Date: May 2003
Location: Argentina
Posts: 1,438
When I get home I'll compile it and test it, it's a handy script to have.. It's probably missing a few lines but it should be straight forward (like EVERYTHING in Winamp skinning lol)

· · TMCT · KOMODO X
Victhor is offline   Reply With Quote
Old 9th October 2015, 05:03   #890
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
05:03 am here waiting on the test results and designing the eq
scottiescotsman is offline   Reply With Quote
Old 9th October 2015, 05:20   #891
Victhor
Late skinner & Moderator
 
Victhor's Avatar
 
Join Date: May 2003
Location: Argentina
Posts: 1,438
Oops, I totally forgot about it, sorry, maybe tomorrow, now I'm off to sleep!

· · TMCT · KOMODO X
Victhor is offline   Reply With Quote
Old 9th October 2015, 15:58   #892
garetjax
Candyass
(Major Dude)
 
garetjax's Avatar
 
Join Date: Apr 2001
Location: Benton, AR
Posts: 2,317
Send a message via ICQ to garetjax Send a message via AIM to garetjax Send a message via MSN to garetjax Send a message via Yahoo to garetjax
Funny, technically speaking I have yet to create a modern winamp skin.

1001skins |
That's not a skin, it's some god awful piece of skinner gunk. - Mr. Jones
garetjax is offline   Reply With Quote
Old 9th October 2015, 21:16   #893
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
well get to it
scottiescotsman is offline   Reply With Quote
Old 23rd October 2015, 23:18   #894
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
Cant get my maki script to compile windows 10 pro grr
scottiescotsman is offline   Reply With Quote
Old 27th October 2015, 22:57   #895
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
If you want to spin the layers via scripting, I did that on an old Stargate skin years ago.
The gate itself is the seeker, and spins clockwise during playback.
There is also a "simulator" mode, where the gate can be dialed, like in the show, and the gate will spin both directions and lock chevrons, just like in the show.

Feel free to dig around the code and use what you want:
Stargate Winamp - SG1 Edition

The scripts you might be interested in are:
scripts\lib\rotationlayer.m
scripts\gate-playermode.m
and maybe:
scripts\gate-simmode.m
Plague is offline   Reply With Quote
Old 30th October 2015, 00:21   #896
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
Talking biG tA!

Thanks m8 will have a look as I know zero about maki

and most other things lol

quick question...

how do I get a toggle button to hide then unhide a layer?

Thanks
Steven
scottiescotsman is offline   Reply With Quote
Old 30th October 2015, 23:06   #897
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
It was ages since I last played with maki, but basically if you want to specifically use a tooglebutton (so that it stays pressed when the layer is in one state, and then stays unpressed when the layer is in another state), then I'd suggest using cfgattribs for that.

For example, in dhd-playermode.xml, you find this line, that will toggle the iris on the gate:
code:

<togglebutton id="Iris" x="244" y="133" image="dhd.Iris" downImage="dhd.Iris-on" activeImage="dhd.Iris-on" tooltip="Toggle Iris" cfgattrib="{258968BA-8E47-453c-A008-4433A6EB298E};Iris"/>



The cfgattrib is the interesting part, the GUID you see there {258968BA-8E47-453c-A008-4433A6EB298E} is for a hidden config page in Winamp.
After the GUID, you specify the variable you want to use (Iris).

Then, in attribs.m and gate-playermode.m, you will find the needed script code to handle it.

Basically, you need to add the attrib in maki and use it to toggle the layer you want to show/hide.
For example:
code:

#include <lib/std.mi>
#include <lib/config.mi>
#define HIDDEN_PAGE "{258968BA-8E47-453c-A008-4433A6EB298E}"
Global ConfigAttribute myattr_toggleIris;
Global Layer iris;
System.onScriptLoaded() {
ConfigItem hidden_page = Config.newItem(getSkinName() + " Hidden", HIDDEN_PAGE);
myattr_toggleIris = hidden_page.newAttribute("Iris", "0");
Group sgroup = getScriptGroup();
iris = sgroup.findObject("iris");
myattr_toggleIris.onDataChanged();
}
myattr_toggleIris.onDataChanged() {
if (getData() == "1")
iris.show();
else
iris.hide();
}



The reason for using cfgattribs is that the layer and buttonstate will always be synced.
Plague is offline   Reply With Quote
Old 31st October 2015, 12:21   #898
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
Smile Thanks

Cheers m8 saw this last night but was to sleepy to comprehend what the code was doing

Now that I am awake lol I giving it a go!

Thanks a lot
Steven

p.s Is there a maki book that I could get to learn it ?

also I read a few of the posts on forum about where to store/learn/teach the maki scripts to the masses. I have a web domain that I have had for ages and have struggled to find a useful use for it but would gladly hand to someone to do as they please for the purpose of store/learn/teach the maki script
scottiescotsman is offline   Reply With Quote
Old 31st October 2015, 13:31   #899
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
No there is no maki book as far as I know.
The best source for learning maki was the so called "Canada" documents, but those are offline since a very long time.

There is a Wiki for Modern Skins that you can use for reference:
http://wiki.shoutcast.com/wiki/Creating_Modern_Skins

Otherwise, I'd just suggest digging into the included .mi files in Winamp, for example std.mi and config.mi.
They have good commenting on most of the functions to help you understand how things work.

Another tip is to start digging through a simple skins sources, for example the Winamp3 base skin or the Wasabi.player base skin (links in my signature).

My D-Reliction skin (link in my sig) could also be a good source for doing a little bit more advanced stuff, without it getting too complicated to understand.

All my maki sources are included, and they should be fairly easy to understand.

The Bento and Winamp Modern skins are in my opinion built in a way that is a bit too complicated if you want to learn basic maki.

Also, dig through this forum thread, from the beginning, as there are tons of useful small scripts and tips right from the start.
Plague is offline   Reply With Quote
Old 2nd November 2015, 01:09   #900
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
I give up I cant complete my skin as I don't have the knowledge or xpertise so I will leave it there

ta
scottiescotsman is offline   Reply With Quote
Old 2nd November 2015, 06:46   #901
ariszlo
Senior Member
 
Join Date: Jun 2015
Location: Hungary
Posts: 299
Quote:
Originally Posted by Plague View Post
The best source for learning maki was the so called "Canada" documents, but those are offline since a very long time.
Here is an archived copy of the Maki docs by Ghislain 'Aus' Lacroix.
ariszlo is offline   Reply With Quote
Old 2nd November 2015, 12:35   #902
Victhor
Late skinner & Moderator
 
Victhor's Avatar
 
Join Date: May 2003
Location: Argentina
Posts: 1,438
Quote:
Originally Posted by scottiescotsman View Post
I give up I cant complete my skin as I don't have the knowledge or xpertise so I will leave it there
You gave up quickly. My first skin took 3 to 4 months. It would be good anyway to have a break and rest from it, when you feel it you'll get back to it .

· · TMCT · KOMODO X
Victhor is offline   Reply With Quote
Old 2nd November 2015, 13:41   #903
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
Its just the stupid little things like bass/treble like volume .. did everything as asked and doesn't work no errors or anything.. I been on this every days for weeks and I only got 3 things left to do and I have done all asked but nothing works ... maybe I over working it I don't know.

thanks victhor
Steven
scottiescotsman is offline   Reply With Quote
Old 2nd November 2015, 21:29   #904
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
Quote:
Originally Posted by ariszlo View Post
Here is an archived copy of the Maki docs by Ghislain 'Aus' Lacroix.
Hmm, I was actually referring to the Wasabi XML Object Reference docs (part of Aus's "Canada" docs), but I remembered wrong about them being about Maki.
The original url was:
http://canada.landoleet.org/docs/pub...guiobjects.php
I can't find them on the Wayback Machine, but I do have a local backup of them.

They are still very good for learning modern skinning though and, as it happens, a Wa5 version is still online:
http://wiki.winamp.com/wiki/XML_GUI_Objects

The above docs are great for learning how the XML and XUI components work.
And there are some pretty advanced stuff that can be done simply by learning how XUI objects work, how to create them, etc.
Plague is offline   Reply With Quote
Old 3rd November 2015, 15:54   #905
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
hi plague
the backup copy of them can you send me a copy please

tA Steven
scottiescotsman is offline   Reply With Quote
Old 4th November 2015, 00:59   #906
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
I actually recommend you work with the Winamp5 version that I linked in my previous post.
It contains mostly the same stuff anyways.
My local copy of the old docs are from the Winamp3 days, and contain some stuff that would not work in Winamp5.
Plague is offline   Reply With Quote
Old 27th November 2015, 00:41   #907
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
can u still ask for a maki script help ?

I need a maki script [half] written/fixed and compiled as it wont compile on windows 10

as soon as I get this done my first skin will be complete

I am making a double tape jvc skin and all working apart from the rotation, the way that I
have did it is ...
if I would have did it as one big animation the .png would have been huge [and would have needed 5 of them], so I split it into an individual reel for each animation and then just multiplied it by 4 to make the double cassette. but when I run the script it only works on the first reel and not on the other 3. I have seen a for statement used in a maki script but I have no idea how to write it.

I included the .m file I am using at present and some .xml code

hope someone still knows this stuff lol

Steven

code:
<groupdef id="tape.normal.group.cassette" x="0" y="0" w="1284" h="320">

<!-- Cassettes Back -->

<layer id="cassette1.base.back" image="cassette.back" x="154" y="34" sysregion="1"/>
<layer id="cassette2.base.back" image="cassette.back" x="818" y="34" sysregion="1"/>

<!-- Stop Cassettes -->

<animatedlayer id="layerStaticCassettes" x="173" y="52" w="134" h="134" image="cassette.tape.stop" autoplay="1" autoreplay="1" speed="60" ghost="1" />
<animatedlayer id="layerStaticCassettes" x="313" y="52" w="134" h="134" image="cassette.tape.stop" autoplay="1" autoreplay="1" speed="53" ghost="1" />
<animatedlayer id="layerStaticCassettes" x="837" y="52" w="134" h="134" image="cassette.tape.stop" autoplay="1" autoreplay="1" speed="57" ghost="1" />
<animatedlayer id="layerStaticCassettes" x="977" y="52" w="134" h="134" image="cassette.tape.stop" autoplay="1" autoreplay="1" speed="51" ghost="1" />

<!-- Play Cassettes -->

<animatedlayer id="layerRunningCassettes" x="173" y="52" w="134" h="134" image="cassette.tape.play" autoplay="1" autoreplay="1" speed="60" ghost="1" />
<animatedlayer id="layerRunningCassettes" x="313" y="52" w="134" h="134" image="cassette.tape.play" autoplay="1" autoreplay="1" speed="53" ghost="1" />
<animatedlayer id="layerRunningCassettes" x="837" y="52" w="134" h="134" image="cassette.tape.play" autoplay="1" autoreplay="1" speed="57" ghost="1" />
<animatedlayer id="layerRunningCassettes" x="977" y="52" w="134" h="134" image="cassette.tape.play" autoplay="1" autoreplay="1" speed="51" ghost="1" />

<!-- Forward Cassettes -->

<animatedlayer id="layerFastRunningCassettes" x="173" y="52" w="134" h="134" image="cassette.tape.forward" autoplay="1" autoreplay="1" speed="60" ghost="1" />
<animatedlayer id="layerFastRunningCassettes" x="313" y="52" w="134" h="134" image="cassette.tape.forward" autoplay="1" autoreplay="1" speed="53" ghost="1" />
<animatedlayer id="layerFastRunningCassettes" x="837" y="52" w="134" h="134" image="cassette.tape.forward" autoplay="1" autoreplay="1" speed="57" ghost="1" />
<animatedlayer id="layerFastRunningCassettes" x="977" y="52" w="134" h="134" image="cassette.tape.forward" autoplay="1" autoreplay="1" speed="51" ghost="1" />

<!-- Rewind Cassettes -->

<animatedlayer id="layerRewindRunningCassettes" x="173" y="52" w="134" h="134" image="cassette.tape.rewind" autoplay="1" autoreplay="1" speed="60" ghost="1" />
<animatedlayer id="layerRewindRunningCassettes" x="313" y="52" w="134" h="134" image="cassette.tape.rewind" autoplay="1" autoreplay="1" speed="53" ghost="1" />
<animatedlayer id="layerRewindRunningCassettes" x="837" y="52" w="134" h="134" image="cassette.tape.rewind" autoplay="1" autoreplay="1" speed="57" ghost="1" />
<animatedlayer id="layerRewindRunningCassettes" x="977" y="52" w="134" h="134" image="cassette.tape.rewind" autoplay="1" autoreplay="1" speed="51" ghost="1" />

<!-- Pause Cassettes -->

<animatedlayer id="layerPausingCassettes" x="173" y="52" w="134" h="134" image="cassette.tape.pause" autoplay="1" autoreplay="1" speed="120" ghost="1" />
<animatedlayer id="layerPausingCassettes" x="313" y="52" w="134" h="134" image="cassette.tape.pause" autoplay="1" autoreplay="1" speed="120" ghost="1" />
<animatedlayer id="layerPausingCassettes" x="837" y="52" w="134" h="134" image="cassette.tape.pause" autoplay="1" autoreplay="1" speed="120" ghost="1" />
<animatedlayer id="layerPausingCassettes" x="977" y="52" w="134" h="134" image="cassette.tape.pause" autoplay="1" autoreplay="1" speed="120" ghost="1" />

<!-- Cassettes Front -->

<layer id="cassette1.base.front" image="cassette.front" x="154" y="34" sysregion="1"/>
<layer id="cassette2.base.front" image="cassette.front" x="818" y="34" sysregion="1"/>

<script id="Animation" file="scripts/playbackanimation.maki"/>


</groupdef>

Attached Files
File Type: m playbackanimation.m (1.9 KB, 116 views)
scottiescotsman is offline   Reply With Quote
Old 27th November 2015, 23:31   #908
scottiescotsman
Senior Member
 
Join Date: Aug 2015
Posts: 180
forget last comment all fixed
scottiescotsman is offline   Reply With Quote
Old 20th February 2016, 01:02   #909
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
Local file path string handling in maki

Aight, so it's not exactly straight forward to do file handling in maki.
One problem is that backslashes in strings cannot easily be handled in maki.
For example, consider this path (which is what a path from getPlayItemString() would look like):
file:\\c:\music\artist1\album1\song1.mp3

What if I want to get a string with only:
c:\music\artist1 ?

That's not easy.
getPath(getPlayItemString()) will only return:
file:\\c:\music\artist1\album1

We still need to remove:
file:\\
and:
\album1

Backslash is an escape character, so to search for a backslash in a string, one would normally have to write two backslashes: "\\".
But, the compiler will not compile the script if one tries to do that.
Another way is to look for the ASCII code for backslash: 92
But, if one tries to do a string search for Chr(92), it will return true for every single character in that string.
Not even getToken will work with backslash as separator.

However, there is one way to do it: urlEncode.
If we urlEncode the string, then every backslash will be replaced with: %5C
Now that we can search for.

So, here is a small script that finds the parent folder of the currently playing file:
PHP Code:
// get the complete path to the currently playing file.
string path getPath(getPlayItemString());
string parentpath "";

if (
strlen(path) > 0) {
    
// make sure the file is a local file by searching for "file:\\"
    // the backslashes in "file:\\" are not included in this search, because the script will not compile with them included.
    // we still need to remove the backslashes later however.
    
int start strsearch(path"file:");
    if (
start > -1) {
        
// the 7 is the number of characters to remove ( file:\\ )
        // we must urlEncode the string, because we cannot search for a single backslash otherwise
        
path urlEncode(strright(pathstrlen(path) - (start 7)));
        
int i strlen(path) - 1;
        while (
> -1) {
            
// search for the last backslash ( %5C ) position.
            // we urlDecode all text before that position.
            // the parentpath will then be that decoded text.
            
if (getToken(strright(pathstrlen(path) - i), "%5C"1) != "") {
                
parentpath urlDecode(strleft(pathi));
                break;
            }
            else
                
i--;
        }
    }
}

if (
parentpath != "") {
    
// do stuff
    // this messagebox will show the parent folder path
    
messagebox(parentpath"test"0"");

Plague is offline   Reply With Quote
Old 24th February 2016, 00:15   #910
Plague
f(caffeine){
return wasabi;
}
(Forum King)
 
Plague's Avatar
 
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
Attempt #2: Local file path string handling in maki

Hmm, so it seems getToken doesn't handle multiple characters as token, which means my previous script may not always work.

There's also an easier way to get the full filepath without the "File:\\" part.
So, here's a better version, that I've also put into it's own function, for easier handling.
PHP Code:
String getParentFolderPath(String path) {
   
string parentpath "";
   
   
// we make sure the input path is not empty and that the second to last character is not a colon.
   // if the second to last character is a colon, it means the input is the root of the drive ( c:\ )
   
if (strlen(path) > && strmid(strright(path2), 01) != ":") {
        
// we must urlEncode the string, because we cannot search for a single backslash otherwise
        
path urlEncode(path);
        
int i strlen(path) - 1;
        while (
> -1) {
            
// search for the last backslash ( %5C ) position.
            // we urlDecode all text before that position.
            // the parentpath will then be that decoded text.
            
if (strsearch(strright(pathstrlen(path) - i), "%5C") > -1) {
                
parentpath urlDecode(strleft(pathi));
                break;
            }
            else
                
i--;
        }
    }

    return 
parentpath;

Here's how you use it:
You need to add the following line where you declare your global variables:
PHP Code:
Function String getParentFolderPath(String path); 
Then you can call the function wherever you want, like this:
PHP Code:
// get the complete path to the currently playing file.
string filepath getPath(getPlayItemMetaDataString("filename"));

// get the parent folder path.
string parentpath getParentFolderPath(filepath);

// this messagebox will show the parent folder path
messagebox(parentpath"test"0""); 
Plague is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Skinning and Design > Modern Skins

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump