diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..527a829 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.fla +audio_player.fla +video_player.fla diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/com/kurbmedia/AudioPlayer.as b/com/kurbmedia/AudioPlayer.as new file mode 100644 index 0000000..6787cd5 --- /dev/null +++ b/com/kurbmedia/AudioPlayer.as @@ -0,0 +1,51 @@ +package com.kurbmedia{ + + import flash.display.MovieClip; + import flash.display.Sprite; + + import com.kurbmedia.events.AudioEvent; + import com.kurbmedia.configs.AudioConfig; + + public class AudioPlayer extends MovieClip{ + + private var player_base:Sprite; + public var player_data:Object; + + private var _config:AudioConfig; + + public function AudioPlayer(){ + + _config = new AudioConfig(stage, MovieClip(root)); + addEventListener(AudioEvent.RENDER_COMPLETE, _config.render_complete); + + player_data = { + 'backgroundColor':0xFFFFFF, + 'autoPlay':true, + 'borderRadius':'10', + 'file':undefined + }; + + if(root.loaderInfo.parameters.configure != undefined){ + for(var i in root.loaderInfo.parameters.configure) player_data[i] = root.loaderInfo.parameters.configure[i]; + } + + player_base = new Sprite(); + player_base.x = player_base.y = 0; + + if(player_data.strokeColor != undefined) player_base.graphics.lineStyle(1, uint(player_data.strokeColor)); + player_base.graphics.beginFill(uint(player_data.backgroundColor)); + + if(player_data.borderRadius != undefined){ + player_base.graphics.drawRoundRect(0,0, stage.stageWidth, stage.stageHeight, player_data.borderRadius); + }else{ + player_base.graphics.drawRect(0,0, stage.stageWidth, stage.stageHeight); + } + + player_base.graphics.endFill(); + addChild(player_base); + + } + + } + +} \ No newline at end of file diff --git a/com/kurbmedia/configs/AudioConfig.as b/com/kurbmedia/configs/AudioConfig.as new file mode 100644 index 0000000..7ad8b79 --- /dev/null +++ b/com/kurbmedia/configs/AudioConfig.as @@ -0,0 +1,63 @@ +package com.kurbmedia.configs{ + + import com.kurbmedia.events.AudioEvent; + + public class AudioConfig{ + + private var __stage; + private var __root; + + // You shouldn't need to change this function. This provides a way to access both the stage + // and the root of the movie. + + public function AudioConfig(stage_instance, root_instance){ + __stage = stage_instance; + __root = root_instance; + } + + // This function is called when the stage is finished drawing all elements based on the passed configuration. + + public function render_complete(e:AudioEvent){ + + } + + // This function is called when the audio initially starts playing, or any time audio + // starts or is re-started from the beginning. + + public function audio_start(e:AudioEvent){ + + } + + // This function is called any time the audio is paused. + + public function audio_paused(e:AudioEvent){ + + } + + // This function is called any time the audio is un-paused. + + public function audio_unpaused(e:AudioEvent){ + + } + + // This function is called any time the audio is explicitly stopped (not paused). + + public function audio_stopped(e:AudioEvent){ + + } + + // This function is called any time the audio is muted. + + public function audio_mute(e:AudioEvent){ + + } + + // This function is called any time the audio is un-muted. + + public function audio_unmute(e:AudioEvent){ + + } + + } + +} \ No newline at end of file diff --git a/com/kurbmedia/events/AudioEvent.as b/com/kurbmedia/events/AudioEvent.as new file mode 100644 index 0000000..e319235 --- /dev/null +++ b/com/kurbmedia/events/AudioEvent.as @@ -0,0 +1,13 @@ +package com.kurbmedia.events{ + + import com.kurbmedia.events.PlayerEvent; + + public class AudioEvent extends PlayerEvent{ + + public function AudioEvent(val:String, obj = null){ + object = obj; + super(val, true, false); + } + } + +} \ No newline at end of file diff --git a/com/kurbmedia/events/PlayerEvent.as b/com/kurbmedia/events/PlayerEvent.as new file mode 100644 index 0000000..2c36c6e --- /dev/null +++ b/com/kurbmedia/events/PlayerEvent.as @@ -0,0 +1,17 @@ +package com.kurbmedia.events{ + + import flash.events.Event; + + public class PlayerEvent extends Event{ + + public static const RENDER_COMPLETE:String = "PlayerEvent.RENDER_COMPLETE"; + + public var object:*; + + public function PlannerEvent(val:String, obj = null){ + object = obj; + super(val, true, false); + } + } + +} \ No newline at end of file