Skip to content

Commit dd62bef

Browse files
committed
Let unrecognized types attempt HTML5 player
1 parent e553f64 commit dd62bef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

music.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc)
568568
int i;
569569
void *context;
570570
Sint64 start;
571+
Mix_MusicType detectedType;
571572

572573
if (!src) {
573574
Mix_SetError("RWops pointer is NULL");
@@ -578,20 +579,35 @@ Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc)
578579
/* If the caller wants auto-detection, figure out what kind of file
579580
* this is. */
580581
if (type == MUS_NONE) {
582+
#ifdef MUSIC_HTML5
583+
type = MUS_HTML5;
584+
detectedType = detect_music_type(src);
585+
#else
586+
(void)detectedType;
581587
if ((type = detect_music_type(src)) == MUS_NONE) {
582588
/* Don't call Mix_SetError() since detect_music_type() does that. */
583589
if (freesrc) {
584590
SDL_RWclose(src);
585591
}
586592
return NULL;
587593
}
594+
#endif
588595
}
589596

590597
Mix_ClearError();
591598

592599
if (load_music_type(type) && open_music_type(type)) {
593600
for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
594601
Mix_MusicInterface *interface = s_music_interfaces[i];
602+
603+
#ifdef MUSIC_HTML5
604+
if (detectedType == MUS_NONE && interface->type != MUS_HTML5)
605+
continue;
606+
else if (detectedType == interface->type
607+
&& (!load_music_type(detectedType) || !open_music_type(detectedType)))
608+
continue;
609+
#endif
610+
595611
if (!interface->opened || type != interface->type || !interface->CreateFromRW) {
596612
continue;
597613
}

0 commit comments

Comments
 (0)