Documentation

The information on this page may change as we release updated versions with changes and new functionality to be documented.



:: Vibe Script Reference
The Vibe Script language is a language designed solely for the Vibe server.
It was implemented into the stream server with the purpose of simplifying the skin creation process and making it easier to develop and add new functionality to Vibe Streamer. The language supports the basic datatypes and functionality of a script language and together with the built-in functions used for accessing data from the stream server it's more than enough.

Since the Vibe Script Language is a fully interpreted language it means that it's not as fast as pre-compiled code and doesn't either generate very useful error messages. But in every new version the Vibe Script language is improved in order to increase performance and usability.

Please note that since the Vibe Script Language follows a JavaScript/C like syntax, a basic knowledge of any of these languages are recommended for an easier use of this reference.

Using Vibe Scripts
Vibe Scripts work in the same way as ASP, PHP and other server based scripts do. The webserver in Vibe Streamer processes files that end with the extension .vibe and sends the result to the client that requested the file.

A Vibe Script file can contain HTML like a regular webpage. The only difference is that it processes anything in between the script delimiters <? and ?> as a Vibe Script. All code within the script delimiters is processed before the page is transmitted to the client. Here's an example in the form of a simple 'Hello World!' application.

01: <HTML>
02: <BODY>
03: <FONT size=1>
04:
05: <? print("Hello World!"); ?>
06:
07: </FONT>
08: </BODY>
09: </HTML>

Variables and datatypes
The datatypes supported by the Vibe Script Language are String, Integer, Double, Boolean and the data structure Array. Note that the Vibe Script Language is case-sensitive, meaning that the parser distinguishes from uppercase (capital) and lowercase (small letters). For example, you can create one variable named myVariable and another named MyVariable. All function names must also be called exactly by their names as specified in the Vibe Script reference.

Before a variable can be used it must be declared. Declaring variables is similar to doing so in javascript.

01: <?
02: var myVar; // declare variable without a value
03: var myBool = true; // declare as boolean with the value true
04: var myInteger = 0; // declare as integer with the value 0
05: var myDouble = 1.0; // declare as double with the value 1.0
06: var myString = "Hello World!"; // declare variable as string
07: ?>

An example of working with strings:

01: <?
02: var myString1 = "Hello";
03: var myString2 = "World!";
04:
05: var myString = myString1 + " " + myString2;
06: print(myString); // Outputs "Hello World!"
07: ?>

Referencing
Version 2.03 of Vibe Streamer introduced referencing into the Vibe Script Language. Assigning variables by reference means that the new variable simply reference (in other words, points to) the original variable. Changes to the new variable will also change the original and vice versa. This means that no copy of variable data is performed and the assignment will be quicker. Changes to performance will mostly be noticable when working with loops and arrays, where using referencing when possible is recommended.

To assign by reference, simply add an ampersand (&) in front of the variable that you want to assign to. Here is an example of referencing in action.

01: <?
02: var myString = "Some text"; // assign a value to myString
03: var myReference = &myString; // reference myReference to myString
04:
05: myString = "Let's change the text":
06: print(myReference); // Outputs "Let's change the text"
07: ?>

As meantioned earlier, referencing could do noticable performance improvements when looping and working with large data structures like arrays. You will notice that most functions used to manage arrays require the array to be sent to the function by reference.

Working with arrays
The array type is a data structure that stores one or more values in a single variable. An array can contain any type of variables and objects and of course also other arrays.
There are a few functions to be found for managing arrays (check the function reference further down), one of them is the array_push() function that is used to insert new elements to the end of the array.

This example creates a new array and adds three strings to the collection.

01: <?
02: var myArray = array(); // create a new array
03:
04: // insert strings into the collection
05: // note that the array must be sent by reference to this function
06: array_push(&myArray,"string 1");
07: array_push(&myArray,"string 2");
08: array_push(&myArray,"string 3");
09: ?>

In order to access elements in an array you use the brackets ("[]") and a numeric value of the element you want to access. This way you may get data from an array element aswell as modify it. This example creates a new array and adds integer values to the collection, it then adds all the values together to a total and displays it.

01: <?
02: var myNumbers = array(); // create a new array
03:
04: // insert integers into the collection
06: array_push(&myNumbers,15);
07: array_push(&myNumbers,20);
08: array_push(&myNumbers,65);
10:
11: // sum up all numbers into a total value
12: var iTotal = myNumbers[0] + myNumbers[1] + myNumbers[2];
13:
14: print(iTotal); // output the result
15: ?>

Conditional statements and loops
Conditional statements can be used to control the flow in the script. In a conditional statement the keywords if and else are used to determine if a condition is reached. The script might then take on the suited action for the situation.

Here's an example where we display different texts depending on the value of myName.

01: <?
02: var myName = "John";
03:
04: if ( myName=="John" )
05: print("Hello there John!<br>");
06: else if ( myName=="James" )
07: print("You name can not be James, now could it?<br>");
08: else
09: print("How did this happen?<br>");
10: ?>

Another way to control the flow in your scripts is to use loops. Using loops is a way to be able to repeat a sequence of code until a certain condition has been reached. So far Vibe Script only supports while loops.

01: <?
02: var i = 0;
03: while ( i<100 )
04: {
05: print("Number of times looped: " + i);
06: i++;
07: }
08: ?>

Functions
The Vibe Script engine handles a number of implemented runtime functions.
Click on a function for detailed information about it.

void abandon_session()
Abandoning the current clients session, thus disconnects the user.

array array()
Creates and returns an empty array.

void array_clear(&array)
Removes all elements in the array.

void array_push(&array,var)
Inserts variable to the end of the array.

void array_remove(&array,int)
Removes element at the specified index from array.

void array_sort(&array)
Sorts an array containing strings alphabeticly.
If the array contains variables with other datatypes except string the function will fail.

int count(&array)
Returns the number of elements in an array or the number of properties of an object.

void flush()
Flushes the contents of the buffer to the client before the end of the script.
Normally the output buffer is transmitted to the client when the script has finished executing. This function can be used in those cases when you want to send some of the output you've generate before the end of the script.

array<Session> get_active_sessions()
Returns an array of Session objects containing all the currently active sessions.

Session get_current_session()
Returns a Session object for the client executing this script.

array<Directory> get_directories(string virtualPath)
Returns all child directories of the given directory.
This function takes the virtual path to a shared directory as argument and returns all the subdirectories of the directory as an array containing Directory objects.

If no virtualPath is specified the returned array will contain all shared root directories.

array<File> get_files(string virtualPath)
Returns all files in given directory.
This function takes a virtual path to a shared directory as argument and returns all the files in it as an array containing File objects.

ID3Info get_id3info(string virtualPath)
Returns the ID3 information from the requested mp3 file.
This function takes the virtual path to a shared MP3 file as argument and returns the information found in the ID3 tag as an ID3Info object.

The returned value will be NULL if the operation failed.

ServerInfo get_serverinfo(string virtualPath)
Returns a ServerInfo object containing information and status of the Vibe server.

User get_user_by_name(string username)
Returns a User object representing the requested user.

array<User> get_users()
Returns an array of User objects containing all the users registered on the Vibe server.

bool is_numeric(string s)
Returns true if the given string is numeric otherwise return false.

bool playlist_delete(string username,string name)
Returns true if the playlist with the given name is successfully removed from the given user.
This function fails and returns false if:
- The user has no playlist by this name.

array<File> playlist_get(string username,string name)
Retrieves a playlist with the given name from the given user as an array of File objects.

bool playlist_rename(string username,string oldName,string newName)
Returns true if the playlist with the given name is successfully renamed.
This function fails and returns false if either:
- The playlist name is longer than 255 characters.
- The user has no playlist by this name.
- A playlist with the new name already exists.

bool playlist_save(string username,string name,array<string> playlist)
Returns true if the playlist is successfully saved to the given user.
If a playlist with this name already exists the existing playlist will be overwritten.
After this function has finished executing the users playlist will be sorted alphabeticly.

This function fails and returns false if either:
- The playlist name is longer than 255 characters.
- The user aren't allowed any more playlists.
- The user aren't allowed this many items on a playlist.

void print(string s)
Outputs text to the client.

int randomize(int min, int max)
Randomizes a number between the min and the max value.

array<string> request_form()
Returns an array with all the form fields in the headers.
This function extracts the information sent through the use of the POST method.

Use the function "request_form" and specify the name of the form field as argument to retrieve the value of the given form field.

string request_form(string s)
Returns the value of the requested form field from the headers.
This function extracts the information sent through the use of the POST method.

Use the function "request_form" without any arguments to retrieve the name of all the form fields sent in the headers.

array<string> request_querystring()
Returns an array with all the querystrings in the headers.
This function extracts the information sent through the use of the GET method.

Use the function "request_querystring" and specify the name of the querystring as argument to retrieve the value of the given querystring.

string request_querystring(string s)
Returns the requested querystring from the headers.
This function extracts the information sent through the use of the GET method.

Use the function "request_querystring" without any arguments to retrieve the name of all the querystrings sent in the headers.

int str_findfirst(string s, string find)
Searches for the first occurence of a substring in a string. If found it returns the position of the first character of the matching substring. If not found it returns -1.

int str_findlast(string s, string find)
Searches for the last occurence of a substring in a string. If found it returns the position of the first character of the matching substring. If not found it returns -1.

int str_len(string s)
Returns the length of the string.

string str_jsafe(string s)
Returns a JavaScript safe version of the given string.
This function simply replaces (') with (\') and (\) with (\\) in order to prepare the string for being used together with JavaScript without causing any errors.

string str_replace(string s, string oldValue, string newValue)
Finds and replaces a substring in a string with another substring.

string str_substr(string s, int pos, [int len])
Returns a substring of the current string, starting at position pos and of length len:

string str_tolower(string s)
Converts a string to lower case.

string str_toupper(string s)
Converts a string to upper case.

double to_double(var)
Attempts to convert a variable into a double datatype.

int to_int(var)
Attempts to convert a variable into an integer datatype.

string to_string(var)
Attempts to convert a variable into a string datatype.

array<string> tokenize(string s,string delimiter)
Tokenizes the string by the delimiter and returns the segments as an array.

Predefined objects

Directory
The directory object is an object representing a certain shared directory.

Properties:
string Name
string VirtualPath
boolean HasSubdirectories

File
The file object is an object representing a certain shared file.

Properties:
string Name
string VirtualPath
string MIMEType

ID3Info
The id3info object contains the id3 info of a shared audio file.

Properties:
string Title
string Artist
string Album
string Year
string Comment

If a property can not be found the string value will be "Unknown" except Title where the value will be the filename.

ServerInfo
The serverinfo object represents information and status of the Vibe server.

Properties:
string ServerName
string IPAddress

int Port
int NumSessions

Session
The session object is an object created from data of a connected user.

Properties:
string IPAddress
string LogonDate
string LogonTime
string LastStreamedFile

int LastHttpError

User User

User
The user object represents a user on the Vibe server.

Properties:
string Username
string LastKnownIP

int MaxNumberOfPlaylists
int MaxItemsPerPlaylist
int NumLogins

boolean HasBrowseAccessOnly
boolean HasPLaylistsEnabled

array<string> Playlists

Version: 2.06 (Jul 06 2006)
File Size: 661kb

Minimum Requirements
CPU: 200Mhz - RAM: 16Mb
WinNT/Win2k/WinXP/Win2003
Free MP3 Streaming Server
Easy installation and setup
Easy group/user management
Monitor your streaming activities
No Adware or Spyware

More features
Want to support Vibe Streamer?
Vibe Streamer is developed by versionstudio.com graphics and org idea by creationrebel.se / credits / partners