init
This commit is contained in:
0
xhs-mini-demos/component-case/audio/audio.css
Normal file
0
xhs-mini-demos/component-case/audio/audio.css
Normal file
29
xhs-mini-demos/component-case/audio/audio.js
Normal file
29
xhs-mini-demos/component-case/audio/audio.js
Normal file
@@ -0,0 +1,29 @@
|
||||
Page({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: 'Audio',
|
||||
path: 'packageAPI/pages/audio/audio',
|
||||
};
|
||||
},
|
||||
onReady(e) {
|
||||
// 使用 xhs.createAudioContext 获取 audio 上下文 context
|
||||
this.audioCtx = xhs.createAudioContext('myAudio');
|
||||
this.audioCtx.setSrc('https://dldir1.qq.com/music/release/upload/t_mm_file_publish/2339610.m4a');
|
||||
this.audioCtx.play();
|
||||
},
|
||||
data: {
|
||||
src: '',
|
||||
},
|
||||
audioPlay() {
|
||||
this.audioCtx.play();
|
||||
},
|
||||
audioPause() {
|
||||
this.audioCtx.pause();
|
||||
},
|
||||
audio14() {
|
||||
this.audioCtx.seek(14);
|
||||
},
|
||||
audioStart() {
|
||||
this.audioCtx.seek(0);
|
||||
},
|
||||
});
|
||||
7
xhs-mini-demos/component-case/audio/audio.json
Normal file
7
xhs-mini-demos/component-case/audio/audio.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "音频",
|
||||
"usingComponents": {
|
||||
"showbox": "../../common/component/showbox/index",
|
||||
"box": "../../common/component/container/index"
|
||||
}
|
||||
}
|
||||
12
xhs-mini-demos/component-case/audio/audio.xhsml
Normal file
12
xhs-mini-demos/component-case/audio/audio.xhsml
Normal file
@@ -0,0 +1,12 @@
|
||||
<view class="container">
|
||||
<showbox title="默认">
|
||||
<box>
|
||||
<audio src="{{src}}" id="myAudio" ></audio>
|
||||
|
||||
<button type="primary" bindtap="audioPlay">播放</button>
|
||||
<button type="primary" bindtap="audioPause">暂停</button>
|
||||
<button type="primary" bindtap="audio14">设置当前播放时间为14秒</button>
|
||||
<button type="primary" bindtap="audioStart">回到开头</button>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
Reference in New Issue
Block a user