Thread Tools Display Modes
09-15-09, 11:17 AM   #1
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
Is there anyway to access external files?

Hi all,

I'm trying to write a "Music player" addon, and I wonder if there's any chance I could read a text file from my addon. Or even better, read folders/files inside my addon folder so I can create the list.

Is there any way to do ti?

Thanks!
  Reply With Quote
09-15-09, 11:21 AM   #2
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
Would be really great if I could import a Windows Media Player list, which looks like:

Code:
<?wpl version="1.0"?>
<smil>
    <head>
        <meta name="Generator" content="Microsoft Windows Media Player -- 11.0.5721.5268"/>
        <meta name="AverageRating" content="0"/>
        <meta name="TotalDuration" content="365"/>
        <meta name="ItemCount" content="2"/>
        <title>llista de reproduccio de prova</title>
    </head>
    <body>
        <seq>
            <media src="Bossa ouch.mp3"/>
            <media src="2-Walkie Talkie.mp3"/>
        </seq>
    </body>
</smil>
  Reply With Quote
09-15-09, 11:33 AM   #3
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
WoW doesn't provide any file operations, because it would make communication with the outside world too easy (getting access to Internet databases via text files and program, botting information, etc).

You would need a normal .lua-file as part of your addon to store your playlist in.

Code:
MusicPlayer.data = {
    "Bossa ouch.mp3",
    "2-Walkie Talkie.mp3",
}
Importing your Windows Media Player list would be only possible by storing it in a variable, too, e.g.:
Code:
MusicPlayer.data = [[
<?wpl version="1.0"?>
<smil>
     <!-- and on goes your file -->
</smil>
]]
But you would have to write the parser for the file by yourself. Well, maybe there are XML parsers for Lua around on the Internet ...
Basically all is possible as long it is in a Lua-file, defined in a .toc and saved in a variable. But no file operations.

EDIT: You could also write a (Lua-) script which works outside of WoW, scans the directory and just generates the necessary files before starting WoW - if you installed a script language on your system.
__________________
« Website | GitHub »

Oh hai!

Last edited by xConStruct : 09-15-09 at 11:36 AM.
  Reply With Quote
09-15-09, 11:44 AM   #4
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
May be a better choice to store the list on WTF\SaveVariables\ file?? So it's not overwritten when the addon is updated...

Anyway, it would seem suspicious for some people to use an external program to "load" their playlists (either it's a lua script or c# .exe)

Also it would be somewhat "difficult" for most wow users
  Reply With Quote
09-17-09, 11:00 AM   #5
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
For those interested, I finally wrote a c# program with a user-friendly interface to user with a "library editing" interface similar to Windos Media Player.

User just need to click "Create PlayList" and all that infoormation is written to "addonsName.lua" inside SavedVariables.
  Reply With Quote
09-17-09, 11:47 AM   #6
Arxae
A Cyclonian
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 44
Originally Posted by MigGat View Post
May be a better choice to store the list on WTF\SaveVariables\ file?? So it's not overwritten when the addon is updated...

Anyway, it would seem suspicious for some people to use an external program to "load" their playlists (either it's a lua script or c# .exe)

Also it would be somewhat "difficult" for most wow users
don't wanna break it to you, but all the other (good) music addons have playlists made using a external program
  Reply With Quote
09-17-09, 11:51 AM   #7
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
Well so does mine. Why is it bad? :P

Any way, can you recommend me any of those music players? I started this one because i didn't find any, and if there is... much less work!

thanks
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Is there anyway to access external files?


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

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