Bookmark file playing in xmms

//Removes the path $t from the nth playlist.
function _remove($n,$t)
{
$nazw="/bm".$n.".m3u";

$a=file_get_contents($nazw);
$b=strpos($a,$t);

if ($b === false) {;} else
{
$c=strpos($a,"
",$b);
$ha=fopen($nazw,"w+");
if ($b>0)
fwrite($ha,substr($a,0,$b));
fwrite($ha, substr($a,$c+1));
fclose($ha);
}
}

if ($argc!=2) die ("usage: ".$argv[0]." [0,1,2]
");
if (!in_array($argv[1], array('0','1','2') ))
die ("usage: ".$argv[0]." [0,1,2]
");
$n=(integer)$argv[1];

$blokada=fopen("/.bm.lock",'w');
if ($blokada == false)
die("error fopen
");
if (!flock($blokada,LOCK_EX))
die ("error flock
");

//get path to currently played track
$a=file_get_contents('/tmp/xmms-info');
$b=substr($a, 6+strpos($a,"File: "));
$b=substr($b,0,strlen($b)-1);

_remove(0,$b);
_remove(1,$b);
_remove(2,$b);

//add path to a file

$nazw="/bm".$n.".m3u";

$plik=fopen($nazw,'a');
fwrite($plik, $b."
");
fclose($plik);
fclose($blokada);

source

Leave a Reply