1 | import { ComponentType } from 'react'
|
2 | import { StandardProps, CommonEventFunction } from './common'
|
3 | interface AudioProps extends StandardProps {
|
4 | /** audio 组件的唯一标识符
|
5 | * @supported weapp, swan, qq
|
6 | */
|
7 | id?: string
|
8 | /** 要播放音频的资源地址
|
9 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
10 | */
|
11 | src?: string
|
12 | /** 是否循环播放
|
13 | * @default false
|
14 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
15 | */
|
16 | loop?: boolean
|
17 | /** 是否静音播放
|
18 | * @default false
|
19 | * @supported h5, harmony_hybrid
|
20 | */
|
21 | muted?: boolean
|
22 | /** 是否显示默认控件
|
23 | * @default false
|
24 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
25 | */
|
26 | controls?: boolean
|
27 | /** 默认控件上的音频封面的图片资源地址,如果 controls 属性值为 false 则设置 poster 无效
|
28 | * @supported weapp, swan, qq
|
29 | */
|
30 | poster?: string
|
31 | /** 默认控件上的音频名字,如果 controls 属性值为 false 则设置 name 无效
|
32 | * @default "未知音频"
|
33 | * @supported weapp, swan, qq
|
34 | */
|
35 | name?: string
|
36 | /** 默认控件上的作者名字,如果 controls 属性值为 false 则设置 author 无效
|
37 | * @default "未知作者"
|
38 | * @supported weapp, swan, qq
|
39 | */
|
40 | author?: string
|
41 | /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
|
42 | * @supported h5, harmony_hybrid
|
43 | */
|
44 | nativeProps?: Record<string, unknown>
|
45 | /** 当发生错误时触发 error 事件,detail = {errMsg: MediaError.code}
|
46 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
47 | */
|
48 | onError?: CommonEventFunction<AudioProps.onErrorEventDetail>
|
49 | /** 当开始/继续播放时触发play事件
|
50 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
51 | */
|
52 | onPlay?: CommonEventFunction
|
53 | /** 当暂停播放时触发 pause 事件
|
54 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
55 | */
|
56 | onPause?: CommonEventFunction
|
57 | /** 当播放进度改变时触发 timeupdate 事件,detail = {currentTime, duration}
|
58 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
59 | */
|
60 | onTimeUpdate?: CommonEventFunction<AudioProps.onTimeUpdateEventDetail>
|
61 | /** 当播放到末尾时触发 ended 事件
|
62 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
63 | */
|
64 | onEnded?: CommonEventFunction
|
65 | }
|
66 | declare namespace AudioProps {
|
67 | interface onErrorEventDetail {
|
68 | errMsg: keyof MediaError.Code
|
69 | }
|
70 | interface onTimeUpdateEventDetail {
|
71 | /** 当前时间 */
|
72 | currentTime: number
|
73 | /** 持续时间 */
|
74 | duration: number
|
75 | }
|
76 | namespace MediaError {
|
77 | interface Code {
|
78 | /** 获取资源被用户禁止 */
|
79 | 1
|
80 | /** 网络错误 */
|
81 | 2
|
82 | /** 解码错误 */
|
83 | 3
|
84 | /** 不合适资源 */
|
85 | 4
|
86 | }
|
87 | }
|
88 | }
|
89 | /** 音频。1.6.0版本开始,该组件不再维护。建议使用能力更强的 Taro.createInnerAudioContext 接口
|
90 | * @classification media
|
91 | * @deprecated
|
92 | * @supported weapp, swan, qq, h5, harmony_hybrid
|
93 | * @example_react
|
94 | * ```tsx
|
95 | * export default class PageView extends Component {
|
96 | * constructor() {
|
97 | * super(...arguments)
|
98 | * }
|
99 | *
|
100 | * render() {
|
101 | * return (
|
102 | * <View className='components-page'>
|
103 | * <Audio
|
104 | * src='https://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46'
|
105 | * controls={true}
|
106 | * autoplay={false}
|
107 | * loop={false}
|
108 | * muted={true}
|
109 | * initialTime='30'
|
110 | * id='video'
|
111 | * />
|
112 | * </View>
|
113 | * )
|
114 | * }
|
115 | * }
|
116 | * ```
|
117 | * @example_vue
|
118 | * ```html
|
119 | * <template>
|
120 | * <view class="components-page">
|
121 | * <audio
|
122 | * id="video"
|
123 | * src="https://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46"
|
124 | * :controls="true"
|
125 | * :autoplay="false"
|
126 | * :loop="false"
|
127 | * :muted="true"
|
128 | * />
|
129 | * </view>
|
130 | * </template>
|
131 | * ```
|
132 | * @see https://developers.weixin.qq.com/miniprogram/dev/component/audio.html
|
133 | */
|
134 | declare const Audio: ComponentType<AudioProps>
|
135 | export { Audio, AudioProps }
|