Quantcast
Viewing all articles
Browse latest Browse all 8068

Play sounds (createSound) and music(iPod) when locked? (Both play when app is open, only music plays when locked)

I can not get sound (createSound) and music(ipod) to play when the slider is locked. BackgroundModes are set in plist and tiapp.xml. Is there a work around, am I missing something, or is it just not going to work?

When app is running in foreground:

Sound and music play together.

When locked:

Sound only works. Music only works. Sound and music: Only music plays.

var player = Titanium.Media.systemMusicPlayer;
        var audioPlaying = systemAudioPlaying();
 
        if (audioPlaying) {
            player.pause();
        }
 
 
        PlayAudio(audio[timerRepeat], audioPlaying);
 
        function PlayAudio(files, audioplaying) {
            //code here to play audio files
            var sound = Titanium.Media.createSound({
                url : '/sounds1/' + files + '.wav',
                allowBackground : true
            });
 
            sound.play();
 
            if (audioPlaying) {
                setTimeout(function() {
                    player.play();
                }, 4500);
            }
 
        }
 
        function systemAudioPlaying() {
            if (player.playbackState == Titanium.Media.MUSIC_PLAYER_STATE_PLAYING) {
                return true;
            } else {
                return false;
            }
 
        }

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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