improvement
stop audio auto-parsing fuck wechat
This commit is contained in:
@@ -22,15 +22,11 @@ export class AudioWidget extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state={
|
this.state={
|
||||||
url: this.props.src,
|
url: this.props.src,
|
||||||
state: 'loading',
|
state: 'waiting',
|
||||||
data: null,
|
data: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
if(window.audio_cache[this.state.url]) {
|
if(window.audio_cache[this.state.url]) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -41,6 +37,9 @@ export class AudioWidget extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('fetching audio',this.state.url);
|
console.log('fetching audio',this.state.url);
|
||||||
|
this.setState({
|
||||||
|
state: 'loading',
|
||||||
|
});
|
||||||
Promise.all([
|
Promise.all([
|
||||||
fetch(this.state.url),
|
fetch(this.state.url),
|
||||||
load_amrnb(),
|
load_amrnb(),
|
||||||
@@ -80,10 +79,12 @@ export class AudioWidget extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if(this.state.state==='waiting')
|
||||||
|
return (<p><a onClick={this.load.bind(this)}>加载音频</a></p>);
|
||||||
if(this.state.state==='loading')
|
if(this.state.state==='loading')
|
||||||
return (<p><audio controls /> 正在下载……</p>);
|
return (<p>正在下载……</p>);
|
||||||
else if(this.state.state==='decoding')
|
else if(this.state.state==='decoding')
|
||||||
return (<p><audio controls /> 正在解码……</p>);
|
return (<p>正在解码……</p>);
|
||||||
else if(this.state.state==='loaded')
|
else if(this.state.state==='loaded')
|
||||||
return (<p><audio src={this.state.data} controls /></p>);
|
return (<p><audio src={this.state.data} controls /></p>);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ class ControlBar extends PureComponent {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if(window.location.hash) {
|
if(window.location.hash) {
|
||||||
const text=window.location.hash.substr(1);
|
let text=window.location.hash.substr(1);
|
||||||
|
text=text.substr(0,text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...'
|
||||||
this.setState({
|
this.setState({
|
||||||
search_text: text,
|
search_text: text,
|
||||||
}, ()=>{
|
}, ()=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user