Adding SC Player to Flash Site
I'm in the process of learning flash and making my own website.
1 - I'd like to add the SC player to a site I make in Flash CS4 - can anyone point me in a good direction to learn more about how to do this?
2 - I'd also like to learn how to change it's size, shape and amount of detail too...
Thx
1 - I'd like to add the SC player to a site I make in Flash CS4 - can anyone point me in a good direction to learn more about how to do this?
2 - I'd also like to learn how to change it's size, shape and amount of detail too...
Thx
2
people have this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
The best answer from the company
-
Hi,
here's a simple example of widget embeded in AS3:
package myproject {
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Sprite;
public class PlayerLoader extends Sprite {
public function PlayerLoader() {
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("http://player.soundcloud.com/player.swf?track=wonderland&default_width=350&default_height=280&background_color=ff0000&show_background=true");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.load(mRequest);
}
private function onCompleteHandler(loadEvent:Event) : void {
addChild(loadEvent.currentTarget.content);
}
}
}
all customization options are supported, so if you customize the player in our share dialog, then load the player url string, you should get the same player like embeded version.
default_width and default_height are useful for controlling the height and width of the player embeded in another flash project. before that it was using all available stage area. notice: the height is effective only above 80px, because that's the base height of the waveform player.
it's a very liberal approach, normally the big guys like youtube or google video don't allow direct embed, but we are the the cloud :)
also we don't have any external api for controlling the player now, although maybe we'll have something in the future.
The company says
this answers the question
-
Inappropriate?Hi,
here's a simple example of widget embeded in AS3:
package myproject {
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Sprite;
public class PlayerLoader extends Sprite {
public function PlayerLoader() {
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("http://player.soundcloud.com/player.swf?track=wonderland&default_width=350&default_height=280&background_color=ff0000&show_background=true");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.load(mRequest);
}
private function onCompleteHandler(loadEvent:Event) : void {
addChild(loadEvent.currentTarget.content);
}
}
}
all customization options are supported, so if you customize the player in our share dialog, then load the player url string, you should get the same player like embeded version.
default_width and default_height are useful for controlling the height and width of the player embeded in another flash project. before that it was using all available stage area. notice: the height is effective only above 80px, because that's the base height of the waveform player.
it's a very liberal approach, normally the big guys like youtube or google video don't allow direct embed, but we are the the cloud :)
also we don't have any external api for controlling the player now, although maybe we'll have something in the future.
The company says
this answers the question
-
Inappropriate?all i have is this:
SecurityError: Error #2070: Security sandbox violation: caller http://a1.soundcloud.com/player.swf?t... cannot access Stage owned by http://sirup.webfactional.com/media/f....
at flash.display::Stage/set align()
at com.soundcloud.player::Player/onAddedToStage()
at flash.display::DisplayObjectContainer/addChild()
at assets.calendar::AudioSet/onCompleteHandler()
is this method ok to use with flash player 9 project? -
sorry, there's one essential line missing. before initing the loader insert this:
Security.allowDomain("*");
or more special
Security.allowDomain("soundcloud.com");
that should do the trick. -
Inappropriate?I got the same question. I tried the code as above and get the following error:
Frame 2, Line 1 1083: Syntax error: package is unexpected.
I am not really advanced with actionscript. I put the code into frame 1 on my footer layer. I have not changed the code at all from the example (as in to play the track I want as I thought I would test it first)
Here is my code:
package myproject {
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Sprite;
Security.allowDomain("soundcloud.com");
public class PlayerLoader extends Sprite {
public function PlayerLoader() {
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("http://player.soundcloud.com/player.swf?track=wonderland&default_width=350&default_height=280&background_color=ff0000&show_background=true");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.load(mRequest);
}
private function onCompleteHandler(loadEvent:Event) : void {
addChild(loadEvent.currentTarget.content);
}
}
} -
if you're using it in Flash CS3, you can omit the package part, it's for the Class files.
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Sprite;
Security.allowDomain("soundcloud.com");
Security.allowInsecureDomain("*");
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("http://player.soundcloud.com/player.swf?track=wonderland&default_width=350&default_height=280&background_color=ff0000&show_background=true");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.load(mRequest);
function onCompleteHandler(loadEvent:Event) : void {
addChild(loadEvent.currentTarget.content);
}
also, you can remove the Security.allowInsecureDomain line before deploying to server, it's there so you could test the swf inside of the Flash IDE. -
Yup - CS3 and it works fine without the package bitz. Now just need to work out on how to position it...
thanks :) -
Inappropriate?yeah... it was Security.allowDomain("*");
tnx!!!
it works well now, but there's a new problem, how can i remove it?
removeChild will remove it from screen but the player will keep on playing....
:)
is there a method we could access to stop the stream? -
for now we don't have an official API for the flash player, but you could try calling stop() (and play() if you want) on the loaded object. if that doesn't work, try this http://manewc.com/2008/07/25/actionsc...
Loading Profile...



