reactjs - Changing src attribute for an audio element doesn't work -


changing src attribute audio element doesn't work:

var audio = react.createclass({     render : function() {         return (             <audio src={this.props.data.songurl}/>         );     }    });  var music = react.createclass({     render : function() {         return (             <article classname="music">                 <article classname="musiccontent">                     <musicbutton data={data} />                     <list />                     <footer />                 </article>             </article>         );     } });  var musicbutton = react.createclass({     getinitialstate : function() {         return {             isplay : true,             count : 0         }     },     musicplay : function () {         var audio = react.finddomnode(this.refs.audio);         if(this.state.isplay) {             audio.play();             this.setstate({isplay: false});         } else {             audio.pause();             this.setstate({isplay: true});         }     },     getbackwardmusic : function() {         this.setstate({count: ++this.state.count});         var audio = react.finddomnode(this.refs.audio);         audio.play();     },     getforwardmusic : function() {         this.setstate({count: --this.state.count});         var audio = react.finddomnode(this.refs.audio);         audio.play();     },      render : function() {         var classstring = 'iconmusic icon-pause';         if(this.state.isplay) {             classstring = 'iconmusic icon-pause';         } else {             classstring += ' rotate';         }          return (             <header classname="musicheader">                 <audio ref="audio" data={this.props.data[this.state.count]} />                 <span onclick={this.getbackwardmusic} classname="iconmusic icon-backward"></span>                 <span onclick={this.musicplay} classname={classstring}></span>                 <span onclick={this.getforwardmusic} classname="iconmusic icon-forward"></span>             </header>         );     } }); 

after changing source of audio need .load() first, before play() plays new source. may use .oncanplaythroug = .play()


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -