0

HTML View

<audio ng-src="{{vm.videourlsce}}" autoplay preload="auto" controls="controls" autobuffer></audio>

Inside my controller get the data from remover server using $http service and update to player

var vm = this;
vm.videourlsce = '';
$http.get(SERVER.apiurl+"resources/get_resource/?id="+$stateParams.id)    
.success(function(response){                    
     vm.resources = response.resource;                                          
     vm.videourl = vm.resources.url;                                                                          

}).error(function(error){                    
    console.log("Resources error");
});
$scope.$watch('vm.videourl', function(newVal, oldVal){
   if (newVal !== undefined) {
       console.log("Old Val => "+oldVal);
       console.log("New Val => "+newVal);
       vm.videourlsce = $sce.trustAsResourceUrl(newVal);  
   }
});

After getting service response, the audio URL bind to audio tag on src attribute and playing the audio. But the controls are not working. When I remove autoplay option from the audio tag, nothing will happen. Those controls are not working when clicking the play button.

When I hard-code this URL instead of getting from service it works fine. Does anyone help to this?

1 Answer 1

1

It could be an issue with browser incorrectly handling the change of audio source. Try this workaround.

<div data-ng-if="vm.videourlsce">
    <audio ng-src="{{ ::vm.videourlsce }}" autoplay preload="auto" controls="controls" autobuffer></audio>
</div>

Update

After the OP has supplied the codepen it became clear the problem lies in ionic intercepting click and touch events. It is easily fixed by setting attribute data-tap-disabled="true" on a node.

<div data-ng-if="videourl" data-tap-disabled="true" class="item item-body no-padding">
    <audio autoplay preload="auto" controls="controls" autobuffer>
        <source src="{{ ::videourl }}" type="audio/mpeg"/>
    </audio>
</div>

Updated codepen

Sign up to request clarification or add additional context in comments.

5 Comments

Audio is playing, but the controls(Play and pause) still not working in Firefox. At the same time, chrome seems good. Thanks for your contribution.
I've tried ogg format for firefox. That also won't help.
create a Fiddle complying with MVCE standarts
Thanks for your support. I've created codepen. I don't know why the controls(play/pause) not works on firefox. But this is my code.codepen.io/aruljayaraj/pen/YpNrgb
@Arul start with this step next time - it's much easier to help you when we have a working example. I've checked your codepen and found the problem, updating the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.