dynamic audio loading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • genesistr
    New Member
    • Aug 2009
    • 13

    dynamic audio loading

    hi,
    I'm trying to load audio files dynamicly but i got some errors.

    my code :
    Code:
    File.prototype.OpenAudioFile = function(dPath)
    {
    	aSound= document.createElement("embed");
    	aSound.src = dPath;
    	aSound.name = "ses";
    	this.data = aSound;
    	aSound.onload = this.FileDownloaded();
    }
    it doesnt work and i tried :
    Code:
    document.write("<embed src=" + dPath + " name=" + dPath + " autostart=false onload=this.FileDownloaded()></embed>");
    and
    Code:
    document.write("<bgsound src=" + dPath + " name=" + dPath + " autostart=false onload=this.FileDownloaded()></embed>");
    first code didnt work and other two work but when they load i can see just single color, no image, no text nth else. When i use embed tag staticly it works great.waiting for answers...
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    in Firefox you may run into problems because of the built-in File object (which has nothing to do with <embed>)

    other than that:
    - line 3: the created object is not attached to the document tree anywhere
    - line 7: what does this method do?
    - how do you know that <embed> and <bgsound> are members of the File object/interface?

    note: you should quote all HTML attribute values (this becomes necessary in XHTML)

    Comment

    • genesistr
      New Member
      • Aug 2009
      • 13

      #3
      as i see in some file loader code "onload" function was used as a callback to check if element loading is completed. after geting message from onload i do something else and i call
      document.body.a ppendChild(this .audio);
      in a different class. i can see all properties of aSound and this.data from this.audio.
      and i dont understand with file object but i just tested. i wasnt sure which one will work. i had some base knowledge and i just tested :)

      Comment

      • genesistr
        New Member
        • Aug 2009
        • 13

        #4
        Code:
        File.prototype.OpenAudioFile = function(dPath)
        {
        	var rem = document.createElement("div")
        	rem.name = "divv";
        	rem.id = "divId";
        	
        	rem.innerHTML = '<embed src="' + dPath + '" autostart="false" name="' + dPath + '"></embed>';
        
        	document.body.appendChild(rem);
        }
        my sound problem is solved using the way above but when i attach div object to document sound plays automaticly.is there any solution for it?

        by the way, im not working on internet browsers, it's a part of a framework for tv. it supports js 1.2.

        Comment

        Working...