BackgroundAudioTrackManager = function()
    {
        var _spineItemIframeMap = {};
        var _wasPlaying = false;
    
        var _callback_playPause = undefined;
        this.setCallback_PlayPause = function(callback)
        {
            _callback_playPause = callback;
        };
        
        var _callback_isAvailable = undefined;
        this.setCallback_IsAvailable = function(callback)
        {
            _callback_isAvailable = callback;
        };
    
        this.playPause = function(doPlay)
        {
            _playPause(doPlay);
        };
    
        var _playPause = function(doPlay)
        {
            if (_callback_playPause)
            {
                _callback_playPause(doPlay);
            }

            try
            {
                var $iframe = undefined;
        
                for (var prop in _spineItemIframeMap)
                {
                    if (!_spineItemIframeMap.hasOwnProperty(prop)) continue;

                    var data = _spineItemIframeMap[prop];
                    if (!data || !data.active) continue;

                    if ($iframe) console.error("More than one active iframe?? (pagination)");
                    
                    $iframe = data["$iframe"];
                    if (!$iframe) continue;
        
                    var $audios = $("audio", $iframe[0].contentDocument);

                    $.each($audios, function() {

                        var attr = this.getAttribute("epub:type") || this.getAttribute("type");

                        if (!attr) return true; // continue

                        if (attr.indexOf("ibooks:soundtrack") < 0 && attr.indexOf("media:soundtrack") < 0 && attr.indexOf("media:background") < 0) return true; // continue

                        if (doPlay && this.play)
                        {
                            this.play();
                        }
                        else if (this.pause)
                        {
                            this.pause();
                        }
                    
                        return true; // continue (more than one track?)
                    });
                }
            }
            catch (err)
            {
                console.error(err);
            }
        };
        
        this.setPlayState = function(wasPlaying)
        {
            _wasPlaying = wasPlaying;
        };
        
    
        self.on(ReadiumSDK.Events.CONTENT_DOCUMENT_LOADED, function ($iframe, spineItem)
        {
            try
            {
                if (spineItem && spineItem.idref && $iframe && $iframe[0])
                {
                    // console.log("CONTENT_DOCUMENT_LOADED");
                    // console.debug(spineItem.href);
                    // console.debug(spineItem.idref);
                    
                    _spineItemIframeMap[spineItem.idref] = {"$iframe": $iframe, href: spineItem.href};
                }
            }
            catch (err)
            {
                console.error(err);
            }
        });
        
        self.on(ReadiumSDK.Events.PAGINATION_CHANGED, function (pageChangeData)
        {
            // console.log("PAGINATION_CHANGED");
            // console.debug(pageChangeData);
            // 
            // if (pageChangeData.spineItem)
            // {
            //     console.debug(pageChangeData.spineItem.href);
            //     console.debug(pageChangeData.spineItem.idref);
            // }
            // else
            // {
            //     //console.error(pageChangeData);
            // }
            // 
            // if (pageChangeData.paginationInfo && pageChangeData.paginationInfo.openPages && pageChangeData.paginationInfo.openPages.length)
            // {
            //     for (var i = 0; i < pageChangeData.paginationInfo.openPages.length; i++)
            //     {
            //         console.log(pageChangeData.paginationInfo.openPages[i].idref);
            //     }
            // }

            var atLeastOne = false;
            
            try
            {
                for (var prop in _spineItemIframeMap)
                {
                    if (!_spineItemIframeMap.hasOwnProperty(prop)) continue;

                    var isActive = pageChangeData.spineItem && pageChangeData.spineItem.idref === prop;
                    
                    var isDisplayed = false;

                    if (pageChangeData.paginationInfo && pageChangeData.paginationInfo.openPages.length)
                    {
                        var allSame = true;
                        
                        for (var i = 0; i < pageChangeData.paginationInfo.openPages.length; i++)
                        {
                            if (pageChangeData.paginationInfo.openPages[i].idref === prop)
                            {
                                isDisplayed = true;
                            }
                            else
                            {
                                allSame = false;
                            }
                        }
                        
                        if (!isActive && allSame) isActive = true;
                    }
                    
                    if (isActive || isDisplayed)
                    {
                        var data = _spineItemIframeMap[prop];
                        if (!data) continue;
                    
                        _spineItemIframeMap[prop]["active"] = isActive;
                    
                        var $iframe = data["$iframe"];
                        var href = data.href;

                        var $audios = $("audio", $iframe[0].contentDocument);
                        $.each($audios, function() {

                            var attr = this.getAttribute("epub:type") || this.getAttribute("type");

                            if (!attr) return true; // continue

                            if (attr.indexOf("ibooks:soundtrack") < 0 && attr.indexOf("media:soundtrack") < 0 && attr.indexOf("media:background") < 0) return true; // continue

                            this.setAttribute("loop", "loop");
                            this.removeAttribute("autoplay");

                            // DEBUG!
                            //this.setAttribute("controls", "controls");

                            if (isActive)
                            {
                                // DEBUG!
                                //$(this).css({border:"2px solid green"});
                            }
                            else
                            {
                                if (this.pause) this.pause();
                                
                                // DEBUG!
                                //$(this).css({border:"2px solid red"});
                            }
        
                            atLeastOne = true;

                            return true; // continue (more than one track?)
                        });
                        
                        continue;
                    }
                    else
                    {
                        if (_spineItemIframeMap[prop]) _spineItemIframeMap[prop]["$iframe"] = undefined;
                        _spineItemIframeMap[prop] = undefined;
                    }
                }
            }
            catch (err)
            {
                console.error(err);
            }

            if (_callback_isAvailable)
            {
                _callback_isAvailable(atLeastOne);
            }

            if (atLeastOne)
            {
                if (_wasPlaying)
                {
                    _playPause(true);
                }
                else
                {
                    _playPause(false); // ensure correct paused state
                }
            }
            else
            {
                _playPause(false); // ensure correct paused state
            }
        });
        
        self.on(ReadiumSDK.Events.MEDIA_OVERLAY_STATUS_CHANGED, function (value)
        {
            if (!value.smilIndex) return;
            var package = self.package();
            var smil = package.media_overlay.smilAt(value.smilIndex);
            if (!smil || !smil.spineItemId) return;

            var needUpdate = false;
            for (var prop in _spineItemIframeMap)
            {
                if (!_spineItemIframeMap.hasOwnProperty(prop)) continue;
                
                var data = _spineItemIframeMap[prop];
                if (!data) continue;
                
                if (data.active)
                {
                    if (prop !== smil.spineItemId)
                    {
                        _playPause(false); // ensure correct paused state
                        data.active = false;
                        needUpdate = true;
                    }
                }
            }

            if (needUpdate)
            {
                for (var prop in _spineItemIframeMap)
                {
                    if (!_spineItemIframeMap.hasOwnProperty(prop)) continue;
                
                    var data = _spineItemIframeMap[prop];
                    if (!data) continue;
                
                    if (!data.active)
                    {
                        if (prop === smil.spineItemId)
                        {
                            data.active = true;
                        }
                    }
                }
            
                if (_wasPlaying)
                {
                    _playPause(true);
                }
            }
        });
    }
Lets user to subscribe to iframe's window events

@method addIFrameEventsListener
@param {string} eventName event name.
@param {string} callback callback function.
@param {string} context user specified data passed to the callback function.

@returns {undefined}