Player not rendering until second click when using AjaxPress
-
Hi,
I’m running into an issue while trying to use AjaxPress together with a persistent audio player (Mediastream). What I’m trying to achieve
I want to load and play episodes dynamically via AJAX, keeping a sticky player across navigation, while also maintaining a live stream player. The issues 1. On-demand player (AOD)
The audio starts playing correctly on the first click, but the player UI does not render in the DOM until I click the button a second time.
- First click → audio plays, but player is not visible
- Second click → player appears and works correctly
2. Live player
The live player resets on the second click.
So:
- First click → everything works fine
- Second click → the live stream player reloads/restarts unexpectedly
Expected behavior
- The AOD player should render immediately on the first click
- The live player should persist and not reset
Live example
You may need to click once to trigger the issue.
document.addEventListener('click', function(e) {
const btn = e.target.closest('.rp-play-episode');
if (!btn) return;
e.preventDefault();
const mediaId = btn.getAttribute('data-media-id');
if (!mediaId) {
alert('This episode does not have a media_id yet.');
return;
}
const sticky = document.getElementById('rtt-player-sticky');
if (!sticky) return;
if (!window.loadMSPlayer) {
console.error('loadMSPlayer is not available');
return;
}
if (window.rttPlayer && typeof window.rttPlayer.pause === 'function') {
window.rttPlayer.pause();
}
sticky.innerHTML = '<div id="rtt-mdstrm-aod-player"></div>';
sticky.offsetHeight;
window.loadMSPlayer('rtt-mdstrm-aod-player', {
type: 'media',
id: mediaId,
player: 'YOUR_PLAYER_ID'
});
});What I’ve already checked
loadMSPlayeris available and working- Audio playback works correctly
- The container is injected into the DOM
- The issue only happens on first interaction
Question
Could this be related to how AjaxPress handles DOM updates or lifecycle when injecting dynamic content?
It feels like a timing/render issue, but I’m not sure how to hook properly into AjaxPress events.
Also, I’ve opened a support ticket but haven’t received a response yet, so any help would be really appreciated
The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.