@@ -269,23 +269,19 @@ <h2>🎉</h2>
269
269
270
270
< script >
271
271
$ ( document ) . ready ( function ( ) {
272
- show_player ( ) ;
272
+ if ( have_audio_file ( ) ) {
273
+ // Don't actually load the source -- for some reason,
274
+ // the ajax page load was causing the audio src to
275
+ // only load occasionally! Not sure why. Source loading
276
+ // is handled in load_player_source().
277
+ $ ( 'div.audio-player-container' ) . show ( ) ;
278
+ }
273
279
goto_relative_page ( 0 , true ) ;
274
280
} ) ;
275
281
276
- /**
277
- * If book_audio_file is not null, set up the player.
278
- *
279
- * Don't actually load the source -- for some reason,
280
- * the ajax page load was causing the audio src to
281
- * only load occasionally! Not sure why. Source loading
282
- * is handled in load_player_source().
283
- */
284
- let show_player = function ( ) {
285
- const have_file = ( $ ( '#book_audio_file' ) . val ( ) != '' ) ;
286
- if ( have_file ) {
287
- $ ( 'div.audio-player-container' ) . show ( ) ;
288
- }
282
+
283
+ let have_audio_file = function ( ) {
284
+ return ( $ ( '#book_audio_file' ) . val ( ) != '' ) ;
289
285
}
290
286
291
287
/**
@@ -404,7 +400,7 @@ <h2>🎉</h2>
404
400
405
401
// Magic hack for player source to load consistently
406
402
// in Firefox.
407
- if ( load_source_file ) {
403
+ if ( load_source_file && have_audio_file ( ) ) {
408
404
load_player_source ( ) ;
409
405
}
410
406
}
0 commit comments