How do you add an eventlistener to an flash embed? (new dojox.embed.Flash) I’ve tried dojo.connect and addEventListener but neither work
Snippets:
this.player = new dojox.embed.Flash({
path: 'http://player.soundcloud.com/player.swf?url='+track.stream_url+'&enable_api=true&player_type=engine&object_id='+this.playerId,
width: 5,
height: 5,
id: this.playerId,
name: this.playerId,
minimumVersion: 9,
allowScriptAccess: 'always'
}, dojo.byId('soundcloud_flash'));
None of these work:
dojo.connect(this.player.movie, 'onMediaBuffering', function(id, data) { console.log('dfg'); obj.progress(data.percent); });
dojo.connect(this.player.movie, 'onMediaBuffering', dojo.hitch(this, function(id, data){ console.log('ergh'); this.progress(data.percent);}));
dojo.connect(dojo.query(this.player.movie)[0], 'onMediaBuffering', function(id, data) { console.log('yu'); obj.progress(data.percent); });
dojo.connect(dojo.query(this.player.movie)[0], 'onMediaBuffering', dojo.hitch(this, function(id, data){ console.log('er'); this.progress(data.percent);}));
dojo.connect(this.player, 'onMediaBuffering', dojo.hitch(this, function(id, data){ console.log('ubg'); this.progress(data.percent);}));
dojo.connect(dojo.byId(this.player), 'onMediaBuffering', dojo.hitch(this, function(id, data){ console.log('asd'); this.progress(data.percent);}));
dojo.connect(dojo.query(this.player), 'onMediaBuffering', dojo.hitch(this, function(id, data){ console.log('asd'); this.progress(data.percent);}));
dojo.connect(dojo.query(this.player), 'onMediaBuffering', function(id, data){ console.log('hj'); this.progress(data.percent);});
This event is coming from Sound Cloud payer: https://github.com/soundcloud/Widget-JS-API/wiki
dojox.embed.Flash is a simple mechanism to embed Flash movies, and it also has a proxy method to make it easier to invoke ActionScript methods from the JS object via ExternalInterface. I don’t think it enables 2-way communication or supports events, but you might be able to achieve that using Flash APIs or doing an invoke to set up your own callbacks.
dojo.connect is only good for connecting between JavaScript functions and is not mirrored to ActionScript methods. Note that onReady and onLoad Javascript events are available on the player object and you can connect to those.
Edit: looking closer at this library, I guess onMediaBuffer is a Javascript method called by the Flash movie, but it’s set up to work on a global Javascript variable called soundplayer! To make matters worse, they set up one-offs for a few toolkit eventing systems, duplicating the pattern.
You might try something like this: