forked from NervJS/taro
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from tangcq-code/release-3.6.8-app
fix: 增加createAudioContext等接口的实现,补齐playground的样例
- Loading branch information
Showing
8 changed files
with
227 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/taro-mpharmony/src/api/data-analysis/getExptInfoSync.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// null-implementation | ||
export const getExptInfoSync = function () { | ||
return {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { temporarilyNotSupport } from '../../utils' | ||
|
||
export const reportMonitor = /* @__PURE__ */ temporarilyNotSupport('reportMonitor') | ||
export const reportAnalytics = /* @__PURE__ */ temporarilyNotSupport('reportAnalytics') | ||
export const reportEvent = /* @__PURE__ */ temporarilyNotSupport('reportEvent') | ||
export const getExptInfoSync = /* @__PURE__ */ temporarilyNotSupport('getExptInfoSync') | ||
|
||
export * from './getExptInfoSync' | ||
export * from './reportAnalytics' |
2 changes: 2 additions & 0 deletions
2
packages/taro-mpharmony/src/api/data-analysis/reportAnalytics.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// null-implementation | ||
export const reportAnalytics = function () {} |
52 changes: 52 additions & 0 deletions
52
packages/taro-mpharmony/src/api/media/audio/AudioContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Taro from '@tarojs/api' | ||
|
||
export class AudioContext implements Taro.AudioContext { | ||
Instance?: HTMLAudioElement | ||
|
||
constructor () { | ||
this.Instance = new Audio() | ||
|
||
Taro.eventCenter.on('__taroRouterChange', () => { | ||
this.stop() | ||
}) | ||
} | ||
|
||
get paused () { | ||
return this.Instance?.paused ?? true | ||
} | ||
|
||
get src () { | ||
return this.Instance?.src || '' | ||
} | ||
|
||
set src (e) { | ||
this.setProperty('src', e) | ||
} | ||
|
||
private setProperty (key: string, value: unknown) { | ||
if (this.Instance) { | ||
this.Instance[key] = value | ||
} | ||
} | ||
|
||
play = () => this.Instance?.play() | ||
|
||
pause = () => this.Instance?.pause() | ||
|
||
stop = () => { | ||
this.pause() | ||
this.seek(0) | ||
} | ||
|
||
seek = (position: number) => { | ||
if (this.Instance) { | ||
this.Instance.currentTime = position | ||
} | ||
} | ||
|
||
setSrc = (src: string) => { | ||
if (this.Instance) { | ||
this.Instance.src = src | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters