Author Topic: MP3 files detection  (Read 1773 times)

sasha19323

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +25/-24
    • View Profile
MP3 files detection
« on: July 17, 2014, 12:28:07 pm »
This snippet based on MP3Report.txt file in "mp3" folder. Snippet parse the file and prevent the crash.

Code: ("Client-side script") [Select]
function FileReadLine(f) //f - file
{
local output = "";
local tmp;
while(true)
{
tmp = f.readn('b');
if (tmp != '\n')
{
output += tmp.tochar();
}
else
{
return output;
}
}
}
function onClientCommand(cmd, text)
{
switch(cmd)
{
case "radio":
{
if (text)
{
if (IsNum(text))
{
local id = text.tointeger();
if (id >= 0 && id < 9)
{
PlayFrontEndTrack(id);
}
else if (id >= 9)
{
local f = file("mp3/MP3Report.txt", "r");
local line;
if (f)
{
while(true)
{
local line = FileReadLine(f);
if (typeof line.find("TOTAL SUPPORTED MP3s: ") != "null")
{
local count = line.slice(line.len()-1);
if (count != "0")
{
PlayFrontEndTrack(9);
break;
}
else
{
Message("[#ff0000]No MP3 files have been found");
break;
}
}
}
}
else Message("[#ff0000]No MP3 files have been found");
}
}
}
}
return 0;
}
}

 

© Liberty Unleashed Team.