@ Override public void handleRequest ( final Request request ) { super . handleRequest ( request ) ; if ( isDisabled ( ) ) { return ; } String targ = request . getParameter ( Environment . TARGET_ID ) ; String audioFileRequested = request . getParameter ( AUDIO_INDEX_REQUEST_PARAM_KEY ) ; boolean contentReqested = targ != null && targ . equals ( getTargetId ( ) ) ; if ( contentReqested ) { int audioFileIndex = 0 ; try { audioFileIndex = Integer . parseInt ( audioFileRequested ) ; } catch ( NumberFormatException e ) { LOG . error ( "Failed to parse audio index: " + audioFileIndex ) ; } Audio [ ] audio = getAudio ( ) ; if ( audio != null && audioFileIndex >= 0 && audioFileIndex < audio . length ) { ContentEscape escape = new ContentEscape ( audio [ audioFileIndex ] ) ; escape . setCacheable ( ! Util . empty ( getCacheKey ( ) ) ) ; throw escape ; } else { LOG . error ( "Requested invalid audio clip: " + audioFileIndex ) ; } } }
When an audio element is rendered to the client the browser will make a second request to get the audio content . The handleRequest method has been overridden to detect whether the request is the content fetch request by looking for the parameter that we encode in the content url .