angularjs - Ionic slide box How to play a sound when switching slide? without a click -
i want play sound when switching slides ionic slide box, need without clicking buttons, have tried put ng-focus directive angular , tried property on-slide-changed ionic slide box... here code:
<ion-slide-box on-slide-changed="slidehaschanged($index)" class="fondo-rojo" show-pager="false" does-continue="true" ng-if="sencillo.length"> <ion-slide ng-repeat="senci in sencillo" ng-init="play('/android_asset/www/raw/'+senci.sound_title+'.mp3')" repeat-done="repeatdone()"> <h1 class="margen-slide slide-estilo">{{senci.title}}</h1> <a align="center" style="text-align:center !important;" ng-click="play('/android_asset/www/raw/'+senci.sound_title+'.mp3')"><img style="text-align:center !important;" ng-src="img/sonidos/play.png" width="70px" height="70px"></a> <!--<button ng-click="nextslide()"> >> </button>--> </ion-slide> </ion-slide-box>
controller
.controller("mediactrl", function($scope,$ionicplatform, $cordovamedia, $ionicloading) { $ionicplatform.ready(function(){ $scope.play = function(src) { var media = $cordovamedia.newmedia(src); //var media = new media(src, null, null, mediastatuscallback); media.play(); //$cordovamedia.play(media); } var mediastatuscallback = function(status) { if(status == 1) { $ionicloading.show({template: 'loading...'}); } else { $ionicloading.hide(); } } $scope.slidehaschanged = function(src,$index){ console.info("el slide cambio y es el: " + $index); //alert('slidehaschanged $index=' + $index); if($index >= 0){ $scope.play(src); } }; }) })
i hope can me read, regards...
note need reference "/raw", don't need "android_asset/...", not sure "play" function like.
but try this
//play on slide change $scope.slidehaschanged = function($index){ //init audio depending on selected slide clickaudio = new audio('raw/'+sencillo[$index].sound_title+'.mp3'); clickauido.play(); }
Comments
Post a Comment