PHP Classes

errors?

Recommend this page to a friend!

      PHP Live Radio Streaming  >  All threads  >  errors?  >  (Un) Subscribe thread alerts  
Subject:errors?
Summary:unexpected '['
Messages:9
Author:Stefan Drugda
Date:2015-12-20 08:30:24
 

  1. errors?   Reply   Report abuse  
Picture of Stefan Drugda Stefan Drugda - 2015-12-20 08:30:24
Parse error: syntax error, unexpected '[' in .... testy\radio\offlineradio.class.php on line 7

  2. Re: errors?   Reply   Report abuse  
Picture of Rahman Haghparast Rahman Haghparast - 2015-12-20 08:58:06 - In reply to message 1 from Stefan Drugda
This is because of your version of php being less than 5.4.
You can either update your php version or replace line 7 and line 48 with the ones below:
Line 7:
public $playListFiles = array();
Line 48:
$playData = array();

  3. Re: errors?   Reply   Report abuse  
Picture of Stefan Drugda Stefan Drugda - 2015-12-20 14:14:58 - In reply to message 2 from Rahman Haghparast
if (in_array($file,['.','..'])) ?? .... Parse error: syntax error, unexpected '['

  4. Re: errors?   Reply   Report abuse  
Picture of Rahman Haghparast Rahman Haghparast - 2015-12-20 15:08:13 - In reply to message 3 from Stefan Drugda
The same issue here. Replace that with the following.
if (in_array($file,array('.','..')))

  5. Re: errors?   Reply   Report abuse  
Picture of Stuart Robertson Stuart Robertson - 2015-12-20 20:41:04 - In reply to message 4 from Rahman Haghparast
The same error in line 65

  6. Re: errors?   Reply   Report abuse  
Picture of Stefan Drugda Stefan Drugda - 2015-12-21 17:16:50 - In reply to message 5 from Stuart Robertson
My guide - Installation:

1. create folder files
2. copy to files *.mp3 songs (...two songs)
3. create list.txt
.....\radio\files\peter.mp3,00:00:00
.... \radio\files\dazd.mp3,00:03:57

4. set in offlineradio.class.php to:

public $playListName = '';
public $playListFiles = array();
public $mp3Folder = '';
public $startTime = '00:00:00';
public $timeZone = 'Europe/Prague';

5. set in generatelist.php to:

$init->playListName = 'list.txt';
$init->startTime = '00:00:00';

6. run generatelist.php
7. run index.html

results:
Playing: (null)
Next: (null)

what should I do?

  7. Re: errors?   Reply   Report abuse  
Picture of Rahman Haghparast Rahman Haghparast - 2015-12-22 08:08:43 - In reply to message 6 from Stefan Drugda
Could you give me ftp access to check the issue?

  8. Re: errors?   Reply   Report abuse  
Picture of Stefan Drugda Stefan Drugda - 2015-12-22 14:52:11 - In reply to message 7 from Rahman Haghparast
ok, send you with e-mail..

  9. Re: errors? player html   Reply   Report abuse  
Picture of free tv free tv - 2019-04-15 12:33:05 - In reply to message 7 from Rahman Haghparast
Hi!
you can insert an html player instead of "Content-type: audio/mpeg", I would like to insert a html player <source src = "horse.mp3" type = "audio / mpeg"> is it possible?

this is the class code
    public function play ($ file, $ start = 0)
    {
        if (file_exists ($ file)) {
            $ info = $ this-> get_mp3 ($ file, true, true);
            $ end = floor ($ info ['data'] ['length']);
            $ startIndex = ceil ($ start * (1 / 0.026));
            $ endIndex = $ end> &#8203;&#8203;0? ceil ($ end * (1 / 0.026)): -1;
            $ startPos = $ info ['frames'] [$ startIndex] [0];
            $ endPos = $ info ['frames'] [$ endIndex] [0] + $ info ['frames'] [$ endIndex] [2];
            $ headerBytes = $ info ['frames'] [0] [0];
            
header ("Content-type: audio / mpeg");
// header ("Content-length:". filesize ($ file));
            header ("Cache-Control: no-cache");
            header ("Content-Transfer-Encoding: binary");
            
$ fp = fopen ($ file, 'r');
            $ header = fread ($ fp, $ headerBytes);
            fseek ($ fp, $ startPos);
            $ data = fread ($ fp, $ endPos - $ startPos);
            echo $ header. $ data;
        }
else {
            header ("HTTP / 1.0 404 Not Found");
        }
    }