@react-element/bg-music
Version:
React (微信) 背景音乐
82 lines (81 loc) • 1.93 kB
TypeScript
import * as React from 'react';
import Default from './default';
import './bg-music.less';
export declare type Props = {
src: string;
playContent: React.ReactNode | (() => React.ReactNode);
pauseContent: React.ReactNode;
prefixCls?: string;
onChange?: (state: State) => any;
isPlaying?: boolean;
className?: string;
rotate?: boolean;
loop?: boolean;
};
export declare type State = {
isPlaying?: boolean;
};
export default class BgMusic extends React.Component<Props, State> {
static Default: typeof Default;
static defaultProps: Partial<Props>;
/**
* 音频 react ref 钩子
*/
private readonly audioRef;
constructor(props: Props);
/**
* 更新 state 状态
* @param nextState
*/
updateState(nextState: State): void;
/**
* 创建初始状态
*/
createInitState(): State;
/**
* 判断是否是无状态组件
*/
isDumbComponent(): boolean;
/**
* 获取 isPlaying 的播放状态
*/
checkIsPlaying(): boolean;
/**
* 微信 bridge ready
* @param isPlaying
*/
onWeixinJSBridgeReady: (isPlaying?: boolean | undefined) => void;
/**
* 播放音频
*/
playAudio: () => void;
/**
* 暂停音频
*/
pauseAudio: () => void;
/**
* 处理点击事件
*/
onClick: () => void;
/**
* 处理微信 audio 播放
*/
onWeixinAudioPlay(): void;
/**
* 处理非微信 audio 播放
*/
onNonWeixinAudioPlay(): void;
/**
* 首次加载完 dom
*/
componentDidMount(): void;
/**
* 渲染播放内容
*/
renderPlayContent(isHidden?: boolean): JSX.Element;
/**
* 渲染暂停内容
*/
renderPauseContent(isHidden?: boolean): JSX.Element;
render(): JSX.Element;
}