Skip to content

html5资源加载 #39

Open
Open

Description

@fakefish
ResourceLoader.handleAudio = function(rsobj, callback){
  var itemObj = this;
  var audio = new Audio();
  itemobj.media = audio;
  rsobj.rs[itemobj.key] = audio;

  var filePath = itemobj.src;
  var folderPath = filePath.substr(0, filePath.lastIndexOf('.'));

  var source = document.createElement('source');
  if(audio.canPlayType('audio/mpeg')){
    source.type = 'audio/mpeg';
    source.src = folderPath + '.mp3';
  }else if(audio.canPlayType('audio/ogg')){
    source.type = 'audio/ogg';
    source.src = folderPath + '.ogg';
  }else if((audio.canPlayType('audio/wav'))){
    source.type = 'audio/wav';
    source.src = folderPath + '.wav';
  }
  audio.appendChild(source);

  ResourceLoader.mediaCheck(rsobj, itemobj, callback);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions