Username (e.g. epiz_XXX) or Website URL
epiz_33087480
(please specify the website or account you are asking about)
account suspension - writing offline will this work
Error Message
cant try this
(please share the FULL error message you see)
cant try this
Other Information
(other information and details relevant to your question)
<?php
$url = "http://".$server.":".$port."/".$mount;
class MetadataBlock {
private $expected_length, $content;
/**
* Creates a new empty MetadataBlock with the given $expected_length.
* The actual content can be added using the write() method.
*/
public function __construct($expected_length) {
$this->content = '';
$this->expected_length = $expected_length;
}
public function expected_length() {
return $this->expected_length;
}
public function write($buffer) {
$this->content .= $buffer;
}
public function content() {
return $this->content;
}
public function length() {
return strlen($this->content);
}
/**
* Determines if the metadata block is complete. A metadata block is completed
* when its content has at least $expected_length bytes of data.
* https://learn.microsoft.com/en-us/windows/win32/wmformat/id3-tag-support
*/
public function is_complete() {
return $this->remaining_length() == 0;
}
public function remaining_length() {
return $this->expected_length - $this->length();
}
public function stream_title() {
if (!$this->is_complete())
throw new \Exception("The Title is not complete yet");
$start = strlen("TIT1"); // title
$end = strpos($this->content, "TIT1", $start);
return substr($this->content, $start, $end-$start);
}public function stream_author() {
if (!$this->is_complete())
throw new \Exception("The Authur is not complete yet");
$start = strlen("TPE2"); //Author
$end = strpos($this->content, "TPE2", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_album() {
if (!$this->is_complete())
throw new \Exception("The Album is not complete yet");
$start = strlen("TALB"); // The structure of the TALB (Album) text frame
$end = strpos($this->content, "TALB", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_genre() {
if (!$this->is_complete())
throw new \Exception("The Genre is not complete yet");
$start = strlen("TCON"); // Genre
$end = strpos($this->content, "TCON", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_comment() {
if (!$this->is_complete())
throw new \Exception("The comment is not complete yet");
$start = strlen("TCOM"); // Comment
$end = strpos($this->content, "TCOM", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_year() {
if (!$this->is_complete())
throw new \Exception("The comment is not complete yet");
$start = strlen("TYER"); // Year
$end = strpos($this->content, "TYER", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_duration() {
if (!$this->is_complete())
throw new \Exception("The duration is not complete yet");
$start = strlen("TLEN"); // Duration
$end = strpos($this->content, "TLEN", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_bpm() {
if (!$this->is_complete())
throw new \Exception("The bpm is not complete yet");
$start = strlen("TBPM"); // Beats per Minute.
$end = strpos($this->content, "TBPM", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_listeners() {
if (!$this->is_complete())
throw new \Exception("The listeners is not complete yet");
$start = strlen("LISTENERS=");
$end = strpos($this->content, ";", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_song_cover() {
$start = strlen("APIC");
$end = strpos($this->content, "APIC", $start);
return substr($this->content, $start, $end-$start);
}
public function stream_lyrics() {
$start = strlen("USLT");
$end = strpos($this->content, ";", $start);
return substr($this->content, $start, $end-$start);
}
}
// Begin SHOUTcast Principle control
class stream {
private $metadata, $next_metadata_position, $icy_metaint, $mp3, $stream_bytes_count = 0;
private $length,$duration;
private $expected_length, $content;
private $options, $default_options = array(
'path' => '.',
'split_tracks' => false,
'max_track_duration' => 3600, #sec (1 h)
'max_track_length' => 102400000 #bytes (100 mb)]
);
public $title;
public function __construct($options=array()) {
$this->options = array_merge($this->default_options, $options);
}
public function start($url) {
$http_streaming = new HttpStreaming($url);
$http_streaming->open();
$response_message = $http_streaming->response_message();
var_dump($response_message);
$this->icy_metaint = $response_message->icy_metaint();
$this->next_metadata_position = $this->icy_metaint;
$lyrics = MetadataBlock->stream_lyrics(); // bytes of lyrics.
$byteStream = MetadataBlock->stream_song_cover(); //bytes of image.
$album = imagecreatefromstring($byteStream);
$title = MetadataBlock->stream_title();
$author = MetadataBlock->stream_author();
$album = MetadataBlock->stream_album();
$genre = MetadataBlock->stream_genre();
$duration = MetadataBlock->stream_duration();
$year = MetadataBlock->stream_year();
$comment = MetadataBlock->stream_comment();
$bpm = MetadataBlock->stream_bpm();
$listeners = MetadataBlock->stream_listeners();
while ($buffer = $http_streaming->read_stream()) {
$this->length += strlen($buffer);
if (!$this->process_received_buffer($buffer) || $this->are_limits_reached()) break;
}
}
private function are_limits_reached(){
//return false;
return $this->length >= $this->options['max_track_duration'];
}
private function process_received_buffer($buffer) {
$buffer_len = strlen($buffer);
$this->stream_bytes_count += $buffer_len;
var_dump( $buffer);
return TRUE;
}
}
?>