This code example shows how to stream a sound (.ogg) from a web site. All the code and assets are in the projects Scripts directory. You can download the project using the link above.
// Turn on debug so that Chat.printDebug() and Chat.dump() work
Chat.debugOutput = true;
// Display the stats panel in the bottom left corner of screen
Application.statsVisible = true;
// Turn on collisions, but allow the user to turn it off
Actor.setCollisionSetting( true, false );
// Turn on gravity, but allow the user to turn it off
Actor.setGravitySetting( true, false );
// Show the avatar
Actor.showAvatar = false;
// Show the chat panel
Application.chatPaneVisible = false;
// Set ambient light for the scene
Scene.ambientLightColor = Color(0.5, 0.5, 0.5, 0);
// Create a point light over the oger head to give meanacing look
var oPointLight = Scene.createPointLight( "SceneLight" );
oPointLight.position = Vector( 0, 600, -500 );
// Create the floor
var oGround = Scene.createGround( "MainFloor", "RustySteel", 3000.0, 3000.0, true );
// Create a Skydome
oSkyDome = Scene.createSkyDome();
oSkyDome.materialName = "CloudySky";
oSkyDome.curvature = 5;
oSkyDome.tiling = 8;
oSkyDome.distance = 4000;
oSkyDome.enable = true;
// Test to see if sound is supported
if ( System.hasAudio )
{
// Create the sound object
oSound = SoundSystem.createSound();
if ( oSound )
{
// Specify the sound to be played, that it should be ambient and
// should loop indefinatly and play at half volume
oSound.setFileName( "http://www.pelicancrossing.com/blinkscriptexamples/sound/ambientstream/testfile.ogg" )
oSound.ambient = true;
oSound.volume = 0.5;
oSound.loopCount = 0;
oSound.play();
}
}