Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49076

Audio Tracks are not playing when phone is on vibrate/silent

$
0
0

@kpennell wrote:

I'm using ngAudio to control audio tracks (spotify 30 seconds previews) on an ionic app. It all works swell in the browser. However, in both ionic view and the actual demo app, the tracks will only stream when I have the phone vibrate toggle turned to not silent/ring mode. If it's in vibrate mode, the user hears nothing. I've dug all over and can't seem to solve this riddle.

Here's my service:

 .factory('PlayerService', function(ngAudio) {

    var _play = function(show) {
        if (typeof audioObject === "undefined") {

            audioObject = ngAudio.load(show.track1_preview);

            console.log(audioObject);

            audioObject.play();

            audioObject.playing = show.id;

            return audioObject;
        } else if (audioObject.paused) {
            audioObject = ngAudio.load(show.track1_preview);
            audioObject.play();

            audioObject.playing = show.id;

            return audioObject;

        } else {
            audioObject.stop();
            audioObject = ngAudio.load(show.track1_preview);
            audioObject.play();

            audioObject.playing = show.id;

            return audioObject;

        }


    }

    var _pause = function(show) {

        audioObject.stop();

        audioObject.playing = '';

    }

    return {
        play: _play,
        pause: _pause
    };

Here's the controller:

    $scope.playStream = function(show) {

        PlayerService.play(show);

        $scope.audioObject = audioObject; // this allow for styling the play/pause icons
    }

    $scope.pauseStream = function(show) {
        PlayerService.pause(show);
        $scope.audioObject = audioObject; // this allow for styling the play/pause icons

        //console.log($scope.audioObject);

    }

    $scope.togglePlayPause = function(show) {
        if (!$scope.audioObject || $scope.audioObject.paused) {
            $scope.playStream(show);
        } else if (show.track1_preview !== $scope.audioObject.id) {
            $scope.playStream(show);
        } else {
            $scope.pauseStream(show);
        }
    }

Obviously, it's a bit of a crap user experience if someone has to put the phone off vibrate to hear the tracks.

I'm wondering if this is related to asyncronous stuff and mobile. I just don't know. Giving up after 4 hours of messing with it.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49076

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>