Audio codec detection
Posted: Sun Nov 27, 2016 3:33 pm
This is an example of detecting what codecs should be able to be used in a browser :
Produces 1 and 0 on Internet Explorer (and Edge), whilst it results in 1 and 1 for Chrome
Code: Select all
Declare.b canPlay(vidType.s,codType.s)
Debug "MP3 : "+canPlay("audio/mp3","")
Debug "OGG : "+canPlay("audio/ogg","vorbis")
Procedure.b canPlay(vidType.s,codType.s)
Define text.s
Define result.b
text=vidType+";codecs="+Chr(34)+codType+Chr(34)
!var obj = document.createElement('audio');
!if (obj.canPlayType(v_text)=="")
! v_result=false
!else
! v_result=true
ProcedureReturn result
EndProcedure