I want to create an angularJS audio player based on soundmanager2. Before starting coding, I'm looking for advices on my current thought.
I plan to separate both player logic (sound manager wrapper) and player controls (buttons / scrubber)
I will also bootstrap the soundmanager with angular using .run()
The sound manager will be wrapped into a factory (soundplayer) and will return a soundmanager2 instance
The sound controls (buttons and scrubber + ideally a waveform if webaudio is supported) will be handled trough a directive (soundControls) wich will receive a soundplayer instance
What do you thinks ? Am I over engeeneering it, re-inventing the wheel or Am I on a good way ? Advices are welcome.
Thanks!
I finally opted for an event based communication. Once the directive is created, I emit an object containing the API I want to expose.
$scope.controls={
play: function(){
snd.play();
},
stop: function(){
snd.stop();
},
pause: function(){
snd.pause();
},
rewind: function(){
snd.stop();
snd.play();
}
}
$scope.$emit('snd:init', $scope.controls);
And from in my controller I handle this
var unregisterInit = $scope.$on('snd:init', function(event, controls){
unregisterInit();
playerApi = controls;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With