diff --git a/src/background-min.jpg b/src/background-min.jpg new file mode 100644 index 0000000..65fbe4c Binary files /dev/null and b/src/background-min.jpg differ diff --git a/src/background.jpg b/src/background.jpg new file mode 100644 index 0000000..3bd5ea5 Binary files /dev/null and b/src/background.jpg differ diff --git a/src/index.html b/src/index.html new file mode 100755 index 0000000..f8fd9ac --- /dev/null +++ b/src/index.html @@ -0,0 +1,284 @@ + + + + + + +Ambient + + + +
+ +
Ambient Music
+
My favorite soundtracks
such as Minecraft, Frostpunk, Warcraft and others ...
+ +
+ Handpicked ambient musics for work, focus and chill-out
from C418, Russell Brower, Piotr Musiał, and various artists.
+
+ Total playtime: 1 hour 12 minutes +
+ +
+
+ (/) Title - Artist
+ + + +
+ +
+
Alternative play method:
+ M3U Playlist +
+
+ +
+
+ + + diff --git a/src/playlist_gen.php b/src/playlist_gen.php new file mode 100644 index 0000000..6295012 --- /dev/null +++ b/src/playlist_gen.php @@ -0,0 +1,101 @@ +analyze($filename); + getid3_lib::CopyTagsToComments($fileinfo); // To get id3v1 and id3v2 tags at the same place. + $duration = (string)floor($fileinfo['playtime_seconds']); + $GLOBALS['TOTALTIME'] += $fileinfo['playtime_seconds']; + $artist = $fileinfo['comments']['artist'][0]; + $title = $fileinfo['comments']['title'][0]; + return '#EXTINF:'.$duration.','.$artist.' - '.$title; +} +/** + * Builds a m3u playlist from all mp3 files located in a directory. + * Returns a properly formatted m3u file. + * Input: $dir : directory to scan. + * $baseurl : Base URL where this directory is served. + * Output: (string) the resulting m3u file. + */ +function buildM3u($dir,$baseurl) +{ + $lines = Array(); + foreach(getFilesFromDir($dir) as $filename) + { + if (pathinfo($filename, PATHINFO_EXTENSION)=='mp3') + { + echo "Processing $filename\n"; + $lines[] = makeEXTInfLine($filename); + $lines[] = $baseurl.substr($filename, strlen($dir)); + } + } + return implode("\n",$lines); +} + +$data = buildM3u('.','https://ambient.colmaris.fr'); +file_put_contents('playlist.m3u',$data); +echo 'Playlist regénérée. Durée totale (en secondes): ',$GLOBALS['TOTALTIME']; +?> diff --git a/src/xspf_playlist.php b/src/xspf_playlist.php new file mode 100755 index 0000000..94cf5b2 --- /dev/null +++ b/src/xspf_playlist.php @@ -0,0 +1,80 @@ +\n".htmlspecialchars(trim($url))."\n".htmlspecialchars(trim($tracktitle))."\n".htmlspecialchars(trim($artist))."\n".$duration."000\n"; +} + +$lines = explode("\n",file_get_contents('playlist.m3u')); +$currentline = 0; +$nblines = count($lines); + +/* Example line: + #EXTINF:404,Jon Hopkins - The End + ^ ^ ^ track title + ^ ^ artist name + ^ duration (in seconds) + The next line contains the URL. + +This has to be transformed to: + + URLTracktitleArtistduration +*/ +$tracks = array(); +while ($currentline<$nblines ) { + $line = $lines[$currentline]; + if (startsWith($line,'#EXTINF:')) { + $data = substr($line, 8); // Remove #EXTINF: + + // Extract duration (in seconds) + $j = strpos($data,','); + $duration = intval(substr($data, 0, $j)); + $data = substr($data, $j+1); + + // Extract artist and track title + $k = strpos($data, ' - '); + $artist = substr($data, 0, $k); + $tracktitle = substr($data, $k+3); + + // Get URL in next line + $url = $lines[$currentline+1]; + + $currentline = $currentline + 1; + $tracks[] = buildTrackXspf($artist,$tracktitle,$duration,$url); // Build XSPF XML for this track + } + $currentline = $currentline + 1; +} + +shuffle($tracks); + + +echo << + +Alternative musics for Minecraft gameplay + + +XML; +foreach ($tracks as $track) { + echo $track; + echo "\n"; +} +echo << + +XML; +?>