空间音频2.0支持场景化
Signed-off-by: chuxixue <chuxixue@huawei.com>
@ -27,6 +27,26 @@
|
||||
{
|
||||
"name": "TRACKING_TEXT",
|
||||
"value": "头部跟踪"
|
||||
},
|
||||
{
|
||||
"name": "SPATIAL_SCENE_MODE",
|
||||
"value": "空间模式"
|
||||
},
|
||||
{
|
||||
"name": "SCENE_MODE_DEFAULT",
|
||||
"value": "默认空间模式"
|
||||
},
|
||||
{
|
||||
"name": "SCENE_MODE_AUDIOBOOK",
|
||||
"value": "有声剧场"
|
||||
},
|
||||
{
|
||||
"name": "SCENE_MODE_MOVIE",
|
||||
"value": "电影院"
|
||||
},
|
||||
{
|
||||
"name": "SCENE_MODE_MUSIC",
|
||||
"value": "音乐厅"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
实现效果如下:
|
||||
|
||||
### 效果预览
|
||||
| 主页 | 空间音频界面 |
|
||||
|----------------------------------------|-----------------------------------------|
|
||||
| ![index](screenshot/devices/index.png) | ![main](screenshot/devices/spatial.png) |
|
||||
| 主页 | 空间音频界面 | 空间音频(支持场景化) |
|
||||
|----------------------------------------|-----------------------------------------|----------------------|
|
||||
| ![index](screenshot/devices/index.png) | ![main](screenshot/devices/spatial.png) |![scene](screenshot/devices/spatialSceneMode.jpg)|
|
||||
|
||||
使用说明
|
||||
|
||||
@ -30,7 +30,9 @@
|
||||
|
||||
4. 点击三个按钮,分别会启用”关闭空间音频“,”启用空间音频固定模式“,”启用空间音频头动追踪模式“
|
||||
|
||||
5. 当前版本对是否支持空间音频的判断仍简单,即当前发声设备具备不为空的mac地址就会显示三态按钮UX。
|
||||
5. 当前版本,音频管家判断二级支持空间音频会显示三态按钮UX,否则页面只有关闭模式使能。
|
||||
|
||||
6. 当空间音频可以使用时,可以通过空间模式卡片选择场景。
|
||||
|
||||
### 工程目录
|
||||
|
||||
@ -53,12 +55,14 @@ entry/src/main/ets/
|
||||
* 使用isSpatializationSupported(), isHeadTrackingSupported(), isSpatializationSupportedForDevice(AudioDeviceDescriptor), isHeadTrackingSupportedForDevice(AudioDeviceDescriptor)四个接口查询系统和设备是否支持空间音频和头动跟踪,根据查询结果设置用户UX界面状态:只有系统和设备全都支持某功能,其按钮状态才不会被置灰。
|
||||
* 使用isSpatializationEnabled(), isHeadTrackingEnabled()在每次UX界面出现时查询当前空间音频和头动跟踪是否开启,同步在其他app对开关状态的改动
|
||||
* 使用setSpatializationEnabled(enable: boolean), setHeadTrackingEnabled(enable: boolean),在点击UX按钮时设置空间音频和头动跟踪状态。
|
||||
* 使用setSpatializationSceneType(spatializationSceneType: AudioSpatializationSceneType),设置空间模式
|
||||
* 使用getSpatializationSceneType(),查询当前的空间模式
|
||||
|
||||
### 约束与限制
|
||||
|
||||
1.本示例仅支持标准系统上运行。
|
||||
|
||||
2.本示例为Stage模型,仅支持API11版本SDK。
|
||||
2.本示例为Stage模型,仅支持API12版本SDK。
|
||||
|
||||
3.本示例需要使用DevEco Studio 版本号(3.1.1Release)版本才可编译运行。
|
||||
|
||||
|
@ -20,10 +20,10 @@
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"compileSdkVersion": 11,
|
||||
"compatibleSdkVersion": 11
|
||||
}
|
||||
],
|
||||
"compileSdkVersion": 12,
|
||||
"compatibleSdkVersion": 12
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ struct Index {
|
||||
Row(){
|
||||
Row() {
|
||||
Column() {
|
||||
Image($r('app.media.ic_spatialaudio')).width(72).height(72).margin({ top: 36 })
|
||||
Image($r("app.media.ic_index_spatial")).width(72).height(72).margin({ top: 36 })
|
||||
Text($r('app.string.SPATIAL_AUDIO')).fontColor(Color.Black).fontSize(16).margin({ top: 12 })
|
||||
}
|
||||
.id('spatial_audio_card')
|
||||
|
@ -62,19 +62,21 @@ struct SpatialAudio {
|
||||
private audioSources = ['/2p0.pcm', '/5p1.pcm'];
|
||||
private audioSpatializationManager?: audio.AudioSpatializationManager;
|
||||
private audioRoutingManager?: audio.AudioRoutingManager;
|
||||
private curPos: number[] = [0, 0]
|
||||
@State supportState: number = 1;
|
||||
@State spatializationEnabled: boolean = false;
|
||||
@State trackingEnabled: boolean = false;
|
||||
@State musicState1: boolean = false;
|
||||
@State musicState2: boolean = false;
|
||||
@State spatialSceneMode: audio.AudioSpatializationSceneType = audio.AudioSpatializationSceneType.DEFAULT;
|
||||
|
||||
@Builder Press2PlayDemo1() {
|
||||
Image($r("app.media.ic_pause_spa"))
|
||||
.height(36)
|
||||
.width(36)
|
||||
.margin({right: 16})
|
||||
.margin({ right: 16 })
|
||||
.id("2P0_play_btn")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
this.musicState1 = !this.musicState1;
|
||||
await this.playAudio(0);
|
||||
})
|
||||
@ -84,9 +86,9 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_play_spa"))
|
||||
.height(36)
|
||||
.width(36)
|
||||
.margin({right: 16})
|
||||
.margin({ right: 16 })
|
||||
.id("2P0_pause_btn")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
this.musicState1 = !this.musicState1;
|
||||
await this.pauseAudio(0);
|
||||
})
|
||||
@ -96,9 +98,9 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_pause_spa"))
|
||||
.height(36)
|
||||
.width(36)
|
||||
.margin({right: 16})
|
||||
.margin({ right: 16 })
|
||||
.id("5P1_play_btn")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
this.musicState2 = !this.musicState2;
|
||||
await this.playAudio(1);
|
||||
})
|
||||
@ -108,9 +110,9 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_play_spa"))
|
||||
.height(36)
|
||||
.width(36)
|
||||
.margin({right: 16})
|
||||
.margin({ right: 16 })
|
||||
.id("5P1_pause_btn")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
this.musicState2 = !this.musicState2;
|
||||
await this.pauseAudio(1);
|
||||
})
|
||||
@ -121,7 +123,7 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_audio_close_on"))
|
||||
.height(48)
|
||||
.width(48)
|
||||
.margin({left: 8})
|
||||
.margin({ left: 8 })
|
||||
.id("close_mode_on")
|
||||
}
|
||||
|
||||
@ -129,9 +131,9 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_audio_close_normal"))
|
||||
.height(48)
|
||||
.width(48)
|
||||
.margin({left: 8})
|
||||
.margin({ left: 8 })
|
||||
.id("close_mode_off")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
if (this.supportState !== CLOSE_MODE && this.audioSpatializationManager) {
|
||||
try {
|
||||
this.audioSpatializationManager.setSpatializationEnabled(false, () => {
|
||||
@ -164,7 +166,7 @@ struct SpatialAudio {
|
||||
.height(48)
|
||||
.width(48)
|
||||
.id("open_mode_off")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
if (this.audioSpatializationManager) {
|
||||
try {
|
||||
this.audioSpatializationManager.setSpatializationEnabled(true, () => {
|
||||
@ -184,7 +186,7 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_audio_track_on"))
|
||||
.height(48)
|
||||
.width(48)
|
||||
.margin({right: 8})
|
||||
.margin({ right: 8 })
|
||||
.id("tracking_mode_on")
|
||||
}
|
||||
|
||||
@ -192,9 +194,9 @@ struct SpatialAudio {
|
||||
Image($r("app.media.ic_audio_track_normal"))
|
||||
.height(48)
|
||||
.width(48)
|
||||
.margin({right: 8})
|
||||
.margin({ right: 8 })
|
||||
.id("tracking_mode_off")
|
||||
.onClick(async ()=>{
|
||||
.onClick(async () => {
|
||||
if (this.audioSpatializationManager) {
|
||||
try {
|
||||
this.audioSpatializationManager.setSpatializationEnabled(true, () => {
|
||||
@ -208,13 +210,15 @@ struct SpatialAudio {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Builder TrackingModeDisabled() {
|
||||
Image($r("app.media.ic_audio_track_disable"))
|
||||
.height(48)
|
||||
.width(48)
|
||||
.margin({right: 8})
|
||||
.margin({ right: 8 })
|
||||
.fillColor("#182431")
|
||||
}
|
||||
|
||||
@Builder UIForClose() {
|
||||
this.CloseModeOn();
|
||||
this.OpenModeDisabled();
|
||||
@ -254,7 +258,7 @@ struct SpatialAudio {
|
||||
.width(64)
|
||||
.fontSize(12)
|
||||
.fontWeight(500)
|
||||
.margin({right:68})
|
||||
.margin({ right: 68 })
|
||||
.fontColor("#182431")
|
||||
.textAlign(TextAlign.Center)
|
||||
}
|
||||
@ -265,7 +269,7 @@ struct SpatialAudio {
|
||||
.width(64)
|
||||
.fontSize(12)
|
||||
.fontWeight(500)
|
||||
.margin({right:68})
|
||||
.margin({ right: 68 })
|
||||
.fontColor(Color.Grey)
|
||||
.textAlign(TextAlign.Center)
|
||||
.id("open_mode_disabled")
|
||||
@ -293,14 +297,210 @@ struct SpatialAudio {
|
||||
}
|
||||
|
||||
@Builder DIYTitle() {
|
||||
Row(){
|
||||
Row() {
|
||||
Text($r('app.string.SPATIAL_AUDIO'))
|
||||
.fontWeight(700)
|
||||
.fontSize(20)
|
||||
}
|
||||
.height("100%")
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}
|
||||
|
||||
@Builder ChooseSpatialSceneMode() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text($r('app.string.SPATIAL_SCENE_MODE'))
|
||||
.fontSize(14)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.fontColor('#000000')
|
||||
.opacity(0.6)
|
||||
.fontWeight(500)
|
||||
}
|
||||
.height(20)
|
||||
.width(176)
|
||||
.margin({ top: 28, left: 28 })
|
||||
.justifyContent(FlexAlign.Start)
|
||||
}
|
||||
.width('100%')
|
||||
.height(56)
|
||||
.justifyContent(FlexAlign.Start)
|
||||
|
||||
Column() {
|
||||
Row() {
|
||||
Image($r('app.media.ic_space_normal'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
Row() {
|
||||
Text($r('app.string.SCENE_MODE_DEFAULT'))
|
||||
.fontSize(16)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.fontColor('#000000')
|
||||
.opacity(0.9)
|
||||
.fontWeight(500)
|
||||
Checkbox()
|
||||
.shape((CheckBoxShape.CIRCLE))
|
||||
.select(this.spatialSceneMode === audio.AudioSpatializationSceneType.DEFAULT)
|
||||
.margin({ right: 2 })
|
||||
.height(20)
|
||||
.width(20)
|
||||
.onChange((value: boolean) => {
|
||||
if (value === true) {
|
||||
this.spatialSceneMode = audio.AudioSpatializationSceneType.DEFAULT;
|
||||
if (this.audioSpatializationManager) {
|
||||
this.audioSpatializationManager.setSpatializationSceneType(this.spatialSceneMode)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(264)
|
||||
.height(22)
|
||||
.margin({ left: 16 })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.width(304)
|
||||
.height(55.5)
|
||||
|
||||
Row() {
|
||||
Column() {
|
||||
}
|
||||
.width(264)
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.width(304)
|
||||
.height(0.5)
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_space_theatre'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
Row() {
|
||||
Text($r('app.string.SCENE_MODE_AUDIOBOOK'))
|
||||
.fontSize(16)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.fontColor('#000000')
|
||||
.opacity(0.9)
|
||||
.fontWeight(500)
|
||||
Checkbox()
|
||||
.shape((CheckBoxShape.CIRCLE))
|
||||
.margin({ right: 2 })
|
||||
.height(20)
|
||||
.width(20)
|
||||
.select(this.spatialSceneMode === audio.AudioSpatializationSceneType.AUDIOBOOK)
|
||||
.onChange((value: boolean) => {
|
||||
if (value === true) {
|
||||
this.spatialSceneMode = audio.AudioSpatializationSceneType.AUDIOBOOK;
|
||||
if (this.audioSpatializationManager) {
|
||||
this.audioSpatializationManager.setSpatializationSceneType(this.spatialSceneMode)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(264)
|
||||
.height(22)
|
||||
.margin({ left: 16 })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.width(304)
|
||||
.height(55.5)
|
||||
|
||||
Row() {
|
||||
Column() {
|
||||
}
|
||||
.width(264)
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.width(304)
|
||||
.height(0.5)
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_space_movie'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
Row() {
|
||||
Text($r('app.string.SCENE_MODE_MOVIE'))
|
||||
.fontSize(16)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.fontColor('#000000')
|
||||
.opacity(0.9)
|
||||
.fontWeight(500)
|
||||
Checkbox()
|
||||
.shape((CheckBoxShape.CIRCLE))
|
||||
.margin({ right: 2 })
|
||||
.height(20)
|
||||
.width(20)
|
||||
.select(this.spatialSceneMode === audio.AudioSpatializationSceneType.MOVIE)
|
||||
.onChange((value: boolean) => {
|
||||
if (value === true) {
|
||||
this.spatialSceneMode = audio.AudioSpatializationSceneType.MOVIE;
|
||||
if (this.audioSpatializationManager) {
|
||||
this.audioSpatializationManager.setSpatializationSceneType(this.spatialSceneMode)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(264)
|
||||
.height(22)
|
||||
.margin({ left: 16 })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.width(304)
|
||||
.height(55.5)
|
||||
|
||||
Row() {
|
||||
Column() {
|
||||
}
|
||||
.width(264)
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.width(304)
|
||||
.height(0.5)
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_space_music'))
|
||||
.height(24)
|
||||
.width(24)
|
||||
Row() {
|
||||
Text($r('app.string.SCENE_MODE_MUSIC'))
|
||||
.fontSize(16)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.fontColor('#000000')
|
||||
.opacity(0.9)
|
||||
.fontWeight(500)
|
||||
Checkbox()
|
||||
.shape((CheckBoxShape.CIRCLE))
|
||||
.margin({ right: 2 })
|
||||
.height(20)
|
||||
.width(20)
|
||||
.select(this.spatialSceneMode === audio.AudioSpatializationSceneType.MUSIC)
|
||||
.onChange((value: boolean) => {
|
||||
if (value === true) {
|
||||
this.spatialSceneMode = audio.AudioSpatializationSceneType.MUSIC;
|
||||
if (this.audioSpatializationManager) {
|
||||
this.audioSpatializationManager.setSpatializationSceneType(this.spatialSceneMode)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.width(264)
|
||||
.height(22)
|
||||
.margin({ left: 16 })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.width(304)
|
||||
.height(56)
|
||||
}
|
||||
.backgroundColor('#FFFFFF')
|
||||
.borderRadius(24)
|
||||
.height(232)
|
||||
.width(328)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}
|
||||
|
||||
updateSupportStateUI(): void {
|
||||
@ -309,6 +509,7 @@ struct SpatialAudio {
|
||||
try {
|
||||
this.spatializationEnabled = this.audioSpatializationManager.isSpatializationEnabled();
|
||||
this.trackingEnabled = this.audioSpatializationManager.isHeadTrackingEnabled();
|
||||
this.spatialSceneMode = this.audioSpatializationManager.getSpatializationSceneType();
|
||||
} catch (err) {
|
||||
Logger.error(`update Support State UI failed ,Error: ${JSON.stringify(err)}`);
|
||||
return;
|
||||
@ -327,20 +528,19 @@ struct SpatialAudio {
|
||||
|
||||
let isSpaSupported: boolean = false;
|
||||
let isSpaSupportedForDevice: boolean = false;
|
||||
let isTraSupported: boolean = false;
|
||||
let isTraSupported: boolean = false;
|
||||
let isTraSupportedForDevice: boolean = false;
|
||||
if (this.audioSpatializationManager) {
|
||||
try {
|
||||
isSpaSupported = this.audioSpatializationManager.isSpatializationSupported();
|
||||
isSpaSupported = this.audioSpatializationManager.isSpatializationSupported();
|
||||
isSpaSupportedForDevice =
|
||||
this.audioSpatializationManager.isSpatializationSupportedForDevice(audioDeviceDescriptors[0]);
|
||||
isTraSupported = this.audioSpatializationManager.isHeadTrackingSupported();
|
||||
isTraSupported = this.audioSpatializationManager.isHeadTrackingSupported();
|
||||
isTraSupportedForDevice =
|
||||
this.audioSpatializationManager.isHeadTrackingSupportedForDevice(audioDeviceDescriptors[0]);
|
||||
} catch (err) {
|
||||
Logger.error(`supportStateQuery ,Error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
|
||||
} else {
|
||||
Logger.info("Get manager failed.");
|
||||
}
|
||||
@ -384,7 +584,7 @@ struct SpatialAudio {
|
||||
|
||||
this.audioRoutingManager = audioManager.getRoutingManager();
|
||||
this.updateSupportStateUI();
|
||||
let t_audioRendererInfo:audio.AudioRendererInfo = {
|
||||
let t_audioRendererInfo: audio.AudioRendererInfo = {
|
||||
usage: audio.StreamUsage.STREAM_USAGE_MUSIC,
|
||||
rendererFlags: 0
|
||||
}
|
||||
@ -433,49 +633,57 @@ struct SpatialAudio {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.audioRenderers[index].state === audio.AudioState.STATE_PAUSED) {
|
||||
await this.audioRenderers[index].start();
|
||||
} else {
|
||||
let bufferSize: number = 0;
|
||||
try {
|
||||
bufferSize = await this.audioRenderers[index].getBufferSize();
|
||||
await this.audioRenderers[index].start();
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
Logger.error(`AudioRenderer start : Error: ${JSON.stringify(error)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let buf = new ArrayBuffer(bufferSize);
|
||||
let filePath:string = "";
|
||||
if (this.appContext) {
|
||||
filePath = this.appContext.filesDir + this.audioSources[index];
|
||||
}
|
||||
let stat = await fs.stat(filePath);
|
||||
let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
|
||||
let file = await fs.open(filePath, 0o0);
|
||||
while (true) {
|
||||
if (!this.audioRenderers[index]) {
|
||||
break;
|
||||
}
|
||||
if (this.audioRenderers[index].state === audio.AudioState.STATE_RELEASED) {
|
||||
break;
|
||||
}
|
||||
Logger.info("start write");
|
||||
for (let i = 0; i < len; i++) {
|
||||
class options {
|
||||
offset: number = 0
|
||||
length: number = 0
|
||||
}
|
||||
let readOptions: options = {
|
||||
offset: i * bufferSize,
|
||||
length: bufferSize
|
||||
}
|
||||
await fs.read(file.fd, buf, readOptions);
|
||||
await this.audioRenderers[index].write(buf);
|
||||
}
|
||||
}
|
||||
let bufferSize: number = 0;
|
||||
try {
|
||||
bufferSize = await this.audioRenderers[index].getBufferSize();
|
||||
await this.audioRenderers[index].start();
|
||||
} catch (err) {
|
||||
let error = err as BusinessError;
|
||||
Logger.error(`AudioRenderer start : Error: ${JSON.stringify(error)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let buf = new ArrayBuffer(bufferSize);
|
||||
let filePath: string = "";
|
||||
if (this.appContext) {
|
||||
filePath = this.appContext.filesDir + this.audioSources[index];
|
||||
}
|
||||
let stat = await fs.stat(filePath);
|
||||
let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
|
||||
let file = await fs.open(filePath, 0o0);
|
||||
let i: number = this.curPos[index]
|
||||
|
||||
while (true) {
|
||||
if (!this.audioRenderers[index]) {
|
||||
break;
|
||||
}
|
||||
Logger.info("start write");
|
||||
while (i < len) {
|
||||
if (this.audioRenderers[index].state === audio.AudioState.STATE_RELEASED) {
|
||||
return;
|
||||
}
|
||||
if (this.audioRenderers[index].state === audio.AudioState.STATE_PAUSED) {
|
||||
this.curPos[index] = i;
|
||||
return;
|
||||
}
|
||||
|
||||
class options {
|
||||
offset: number = 0
|
||||
length: number = 0
|
||||
}
|
||||
|
||||
let readOptions: options = {
|
||||
offset: i * bufferSize,
|
||||
length: bufferSize
|
||||
}
|
||||
await fs.read(file.fd, buf, readOptions);
|
||||
await this.audioRenderers[index].write(buf);
|
||||
i += 1;
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async pauseAudio(index: number): Promise<void> {
|
||||
@ -498,7 +706,7 @@ struct SpatialAudio {
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
if (this.audioSpatializationManager === undefined){
|
||||
if (this.audioSpatializationManager === undefined) {
|
||||
return;
|
||||
}
|
||||
this.updateSupportStateUI()
|
||||
@ -526,12 +734,10 @@ struct SpatialAudio {
|
||||
.hideBackButton(false)
|
||||
.titleMode(NavigationTitleMode.Mini)
|
||||
.title(this.DIYTitle())
|
||||
.height("100%")
|
||||
.mode(NavigationMode.Stack)
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
.height(56)
|
||||
.width('100%')
|
||||
.width(360)
|
||||
.id('spatial_audio_back_btn')
|
||||
.onClick(async () => {
|
||||
await router.replaceUrl({ url: 'pages/Index' });
|
||||
@ -543,7 +749,7 @@ struct SpatialAudio {
|
||||
.fontSize(20)
|
||||
.fontWeight(500)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.margin({top: 21, bottom: 21, left: 16.5})
|
||||
.margin({ top: 21, bottom: 21, left: 16.5 })
|
||||
if (!this.musicState1) {
|
||||
this.Press2PlayDemo1();
|
||||
} else {
|
||||
@ -567,7 +773,7 @@ struct SpatialAudio {
|
||||
.fontSize(20)
|
||||
.fontWeight(500)
|
||||
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
|
||||
.margin({top: 21, bottom: 21, left: 16.5})
|
||||
.margin({ top: 21, bottom: 21, left: 16.5 })
|
||||
|
||||
if (!this.musicState2) {
|
||||
this.Press2PlayDemo2();
|
||||
@ -585,9 +791,14 @@ struct SpatialAudio {
|
||||
.height(68)
|
||||
.width('100%')
|
||||
.margin({ top: 12 })
|
||||
|
||||
if (this.spatializationEnabled === true) {
|
||||
this.ChooseSpatialSceneMode()
|
||||
}
|
||||
}
|
||||
.height(212)
|
||||
.width('100%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
|
||||
|
||||
Column() {
|
||||
Row() {
|
||||
@ -600,7 +811,7 @@ struct SpatialAudio {
|
||||
}
|
||||
}
|
||||
.height(64)
|
||||
.width(336)
|
||||
.width(312)
|
||||
.borderRadius(100)
|
||||
.backgroundColor('#FFFFFF')
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
@ -611,7 +822,7 @@ struct SpatialAudio {
|
||||
.width(64)
|
||||
.fontSize(12)
|
||||
.fontWeight(500)
|
||||
.margin({right:60})
|
||||
.margin({ right: 60 })
|
||||
.fontColor(Color.Black)
|
||||
.textAlign(TextAlign.Center)
|
||||
|
||||
@ -627,8 +838,8 @@ struct SpatialAudio {
|
||||
}
|
||||
}
|
||||
.height(16)
|
||||
.width(304)
|
||||
.margin({left: 24, right: 32, top: 8})
|
||||
.width(312)
|
||||
.margin({ left: 24, right: 24, top: 8 })
|
||||
}
|
||||
.height(112)
|
||||
.width('100%')
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_space_movie</title>
|
||||
<g id="ic_space_movie" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" fill-opacity="0.6">
|
||||
<path d="M12.5412541,2 C18.3131051,2 22.9922992,6.477 22.9922992,12 C22.9922992,17.4582858 18.4217031,21.8953364 12.7429171,21.9981754 L12.7153947,21.99975 L12.6135961,21.9997654 C12.5895014,21.9999217 12.5653873,22 12.5412541,22 L12.469209,21.999 L3.48268014,21.99975 C3.08585839,21.99975 2.75790961,21.7175961 2.70600719,21.3515206 L2.69885176,21.24975 C2.69885176,20.8355364 3.04978368,20.49975 3.48268014,20.49975 L7.03310352,20.4999453 C4.065823,18.7357082 2.09020902,15.5885657 2.09020902,12 C2.09020902,6.477 6.76940319,2 12.5412541,2 Z M12.5412541,3.5 C7.64284928,3.5 3.65786579,7.313 3.65786579,12 C3.65786579,16.6653668 7.60656943,20.4651861 12.4742649,20.4997621 L12.608209,20.499 L12.8075155,20.4962359 C17.5832501,20.3610476 21.4246425,16.6015364 21.4246425,12 C21.4246425,7.313 17.439659,3.5 12.5412541,3.5 Z M12.5412541,14 C13.9842822,14 15.1540154,15.11925 15.1540154,16.5 C15.1540154,17.8805 13.9842822,19 12.5412541,19 C11.0982261,19 9.92849285,17.8805 9.92849285,16.5 C9.92849285,15.11925 11.0982261,14 12.5412541,14 Z M12.5412541,15.5 C11.964879,15.5 11.4961496,15.9485 11.4961496,16.5 C11.4961496,17.05125 11.964879,17.5 12.5412541,17.5 C13.1176293,17.5 13.5863586,17.05125 13.5863586,16.5 C13.5863586,15.9485 13.1176293,15.5 12.5412541,15.5 Z M16.9749271,9.5 C18.4176939,9.5 19.5876884,10.61925 19.5876884,12 C19.5876884,13.3805 18.4176939,14.5 16.9749271,14.5 C15.5318991,14.5 14.3621658,13.3805 14.3621658,12 C14.3621658,10.61925 15.5318991,9.5 16.9749271,9.5 Z M7.83828383,9.5 C9.28131188,9.5 10.4510451,10.61925 10.4510451,12 C10.4510451,13.3805 9.28131188,14.5 7.83828383,14.5 C6.39525578,14.5 5.22552255,13.3805 5.22552255,12 C5.22552255,10.61925 6.39525578,9.5 7.83828383,9.5 Z M16.9749271,11 C16.398552,11 15.9298226,11.4485 15.9298226,12 C15.9298226,12.55125 16.398552,13 16.9749271,13 C17.5513023,13 18.0200316,12.55125 18.0200316,12 C18.0200316,11.4485 17.5513023,11 16.9749271,11 Z M7.83828383,11 C7.26190869,11 6.79317932,11.4485 6.79317932,12 C6.79317932,12.55125 7.26190869,13 7.83828383,13 C8.41465897,13 8.88338834,12.55125 8.88338834,12 C8.88338834,11.4485 8.41465897,11 7.83828383,11 Z M12.5412541,5 C13.9842822,5 15.1540154,6.11925 15.1540154,7.5 C15.1540154,8.8805 13.9842822,10 12.5412541,10 C11.0982261,10 9.92849285,8.8805 9.92849285,7.5 C9.92849285,6.11925 11.0982261,5 12.5412541,5 Z M12.5412541,6.5 C11.964879,6.5 11.4961496,6.9485 11.4961496,7.5 C11.4961496,8.05125 11.964879,8.5 12.5412541,8.5 C13.1176293,8.5 13.5863586,8.05125 13.5863586,7.5 C13.5863586,6.9485 13.1176293,6.5 12.5412541,6.5 Z" id="形状结合" fill="#000000" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.9 KiB |
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_space_music</title>
|
||||
<defs>
|
||||
<path d="M20.4685995,3.76981657 C20.4837672,3.86618904 20.4932763,3.96333912 20.4970878,4.06076767 L20.4989987,4.15827057 L20.5,15.2499323 L20.498186,15.2641337 L20.498814,16.3478965 C20.498814,18.2169213 19.170289,19.7571952 17.4591633,19.9665276 L17.3811246,19.9751226 C16.230417,20.1162947 15.1206963,19.6554964 14.5754983,18.7128361 C13.8085709,17.3868005 14.4431741,15.5877669 15.9929242,14.6945821 C16.152076,14.6028563 16.3336328,14.5148183 16.5251932,14.4263496 L16.9977953,14.2110889 C17.4369794,14.0091426 17.8765624,13.7891647 18.1844939,13.5073012 L18.279204,13.4193645 L18.3118578,13.3880809 L18.3781693,13.3221664 C18.6675215,13.0263028 18.9751251,12.5925083 18.9975137,11.8301831 L18.998814,11.7407537 L18.999186,11.7061337 L18.9989987,4.15840598 C18.998994,4.10637464 18.9949285,4.05442303 18.9868391,4.00302438 C18.9035763,3.47398763 18.4197277,3.10753566 17.8930203,3.16410526 L17.8435269,3.17065593 L9.34452813,4.5082762 C8.87502029,4.58216999 8.52485927,4.97536237 8.50126851,5.44546511 L8.5,5.49611652 L8.5,7.54413367 L17.9997742,6.05406036 L17.9997742,7.57206036 L8.5,9.06213367 L8.50002798,16.6355385 L8.50118603,17.0101232 L8.49993603,17.3652463 L8.5,18.6071429 C8.5,20.4761676 7.17147506,22.0164416 5.46034933,22.2257739 L5.38231068,22.2343689 C4.23160307,22.375541 3.12188235,21.9147427 2.57668432,20.9720825 C1.80975692,19.6460469 2.4443601,17.8470132 3.99411018,16.9538284 C4.15326202,16.8621026 4.33481883,16.7740646 4.5263792,16.6855959 L4.99898137,16.4703352 C5.43816547,16.2683889 5.87774844,16.048411 6.18567989,15.7665475 L6.2482091,15.7088653 C6.26948246,15.6890242 6.29114008,15.6685404 6.31304382,15.6473272 L6.37935529,15.5814127 C6.6687075,15.2855491 6.97631118,14.8517547 6.99869972,14.0894294 L7,14 L7,5.49611652 C7,4.28868212 7.86215186,3.25744563 9.04285337,3.03825583 L9.11132032,3.02651572 L17.6103191,1.68889545 C18.9742419,1.47423359 20.2539377,2.40589371 20.4685995,3.76981657 Z M6.99918603,17.0431337 C6.66047053,17.3148981 6.27752198,17.5285989 5.73958471,17.7803239 L5.10135041,18.0724303 L4.99058,18.1249863 L4.89496413,18.1721554 L4.8129854,18.2147128 L4.74312644,18.253434 C3.87096548,18.7560963 3.55155568,19.6615896 3.87515371,20.2210983 C4.08567475,20.5850941 4.56023488,20.8036318 5.151884,20.7504216 L5.27820321,20.736874 C6.21618485,20.6221251 6.96808834,19.7547997 6.99901055,18.6763395 L7,18.6072201 L6.99918603,17.0431337 Z M19,14.78275 C18.6591854,15.0557338 18.2763297,15.2693577 17.7383983,15.5210779 L17.5573279,15.6045145 L17.1001644,15.813184 L16.989394,15.86574 L16.8937781,15.912909 C16.8790207,15.9203647 16.8648315,15.9276282 16.8511789,15.9347157 L16.7754498,15.9752581 C16.7638171,15.9817063 16.7526579,15.9880107 16.7419404,15.9941876 C15.8697794,16.4968499 15.5503696,17.4023433 15.8739677,17.961852 C16.0844887,18.3258478 16.5590488,18.5443855 17.150698,18.4911753 L17.2770172,18.4776277 C18.2149988,18.3628788 18.9669023,17.4955534 18.9978245,16.4170932 L18.998814,16.3479738 L18.9987593,15.1007202 L19,14.78275 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="ic_space_music" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="蒙版" fill-opacity="0.6" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_space_normal</title>
|
||||
<defs>
|
||||
<path d="M4.75,3.925 C5.02614237,3.925 5.25,4.14885763 5.25,4.425 L5.25,8.25 C5.25,8.52614237 5.02614237,8.75 4.75,8.75 L3.0675,8.75 C2.01296497,11.6634799 2.44348082,14.9079937 4.22132846,17.4456436 C5.9991761,19.9832934 8.90154983,21.4960527 12,21.5 C12.6813512,21.5020875 13.3607253,21.4266015 14.025,21.275 C14.2207114,21.2304498 14.4261135,21.2662063 14.5952577,21.3742706 C14.7644018,21.482335 14.8831723,21.6536888 14.925,21.85 C14.9996749,22.2544993 14.7484254,22.6477592 14.35,22.75 C13.5784747,22.9209162 12.7902157,23.0047736 12,23 C8.50799335,22.9971671 5.22476512,21.3364543 3.15330945,18.525193 C1.08185378,15.7139318 0.468269274,12.086113 1.5,8.75 L1.475,8.75 C1.98973081,7.09638299 2.88935525,5.58844108 4.1,4.35 L4.4,4.05 C4.50041219,3.97218621 4.62301169,3.92840067 4.75,3.925 Z M12,1 C18.0751322,1 23,5.92486775 23,12 C22.9977181,13.1023132 22.8291547,14.1979749 22.5,15.25 L22.525,15.25 C22.0102692,16.903617 21.1106448,18.4115589 19.9,19.65 L19.6,19.95 C19.4995878,20.0278138 19.3769883,20.0715993 19.25,20.075 C18.9738576,20.075 18.75,19.8511424 18.75,19.575 L18.75,15.75 C18.75,15.4738576 18.9738576,15.25 19.25,15.25 L20.93,15.25 C21.9906064,12.3368295 21.5630196,9.0894018 19.7844841,6.5500594 C18.0059486,4.010717 15.1002334,2.49895093 12,2.5 C11.3186488,2.49791251 10.6392747,2.57339852 9.975,2.725 C9.56769,2.81474626 9.16474629,2.55730999 9.07500002,2.15 C8.98525375,1.74269 9.24269001,1.33974628 9.65,1.25 C10.4215253,1.07908378 11.2097843,0.995226449 12,1 Z M12,7 C12.345178,7 12.625,7.27982203 12.625,7.625 L12.625,16.625 C12.625,16.970178 12.345178,17.25 12,17.25 C11.654822,17.25 11.375,16.970178 11.375,16.625 L11.375,7.625 C11.375,7.27982203 11.654822,7 12,7 Z M9.5,9.00000003 C9.84517796,9.00000003 10.125,9.27982204 10.125,9.625 L10.125,15.375 C10.125,15.720178 9.84517797,16 9.5,16 C9.15482203,16 8.875,15.720178 8.875,15.375 L8.875,9.625 C8.875,9.27982204 9.15482204,9.00000003 9.5,9.00000003 Z M14.5,9.75 C14.845178,9.75 15.125,10.029822 15.125,10.375 L15.125,14.125 C15.125,14.470178 14.845178,14.75 14.5,14.75 C14.154822,14.75 13.875,14.470178 13.875,14.125 L13.875,10.375 C13.875,10.029822 14.154822,9.75 14.5,9.75 Z M17,11 C17.345178,11 17.625,11.279822 17.625,11.625 L17.625,13.125 C17.625,13.470178 17.345178,13.75 17,13.75 C16.654822,13.75 16.375,13.470178 16.375,13.125 L16.375,11.625 C16.375,11.279822 16.654822,11 17,11 Z M7,11.25 C7.34517797,11.25 7.625,11.529822 7.625,11.875 L7.625,13.125 C7.625,13.470178 7.34517797,13.75 7,13.75 C6.65482203,13.75 6.375,13.470178 6.375,13.125 L6.375,11.875 C6.375,11.529822 6.65482203,11.25 7,11.25 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="ic_space_normal" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="形状结合" fill-opacity="0.6" fill="#1A1A1A" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_space_theatre</title>
|
||||
<g id="ic_space_theatre" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" fill-opacity="0.6">
|
||||
<path d="M2.487468,4.09512848 C2.81675486,2.61247135 4.28562569,1.67748002 5.76828282,2.00676689 L7.67025159,2.42917968 C10.5253709,3.06327996 13.4848798,3.0629136 16.3398421,2.42810645 L18.231007,2.00760176 C18.3587074,1.97920731 18.488107,1.95999744 18.6182148,1.95004794 L18.8137838,1.94207846 L19.0096716,1.94805639 C20.5251331,2.048447 21.6722748,3.35835399 21.5718842,4.87381554 L20.9082629,14.8916097 C20.7880513,16.7013144 19.9446377,18.3867811 18.5677347,19.5689397 C15.8155421,21.9278035 13.6650578,23.1245346 12.0148057,23.1245346 C10.3652334,23.1245346 8.20885953,21.9283768 5.44331368,19.5697625 C4.06026591,18.388415 3.21221133,16.6991384 3.09123983,14.8841033 L2.42807033,4.87312837 C2.41079129,4.61229009 2.43079178,4.35032052 2.487468,4.09512848 Z M5.4430683,3.47108773 C4.76913324,3.32141188 4.10146468,3.74640794 3.95178883,4.42034299 C3.92602692,4.53633938 3.91693579,4.65541645 3.92478989,4.77397931 L4.58793932,14.7846522 C4.68201997,16.196221 5.34169261,17.5102514 6.41710871,18.4288317 C8.92846275,20.5706567 10.8283416,21.6245346 12.0148057,21.6245346 C13.2005902,21.6245346 15.0933421,20.57123 17.5911006,18.4304383 C18.6619357,17.5110582 19.318054,16.1998799 19.4115523,14.7923252 L20.0751646,4.77466648 C20.1207967,4.08582032 19.5993687,3.49040805 18.9105225,3.44477596 C18.7918562,3.436915 18.6726753,3.44602889 18.5565841,3.47184203 L16.6654191,3.89234673 C13.5961463,4.57480631 10.4144788,4.57520018 7.34503707,3.89350052 Z M16.0250778,14.8746828 C16.31104,15.1743467 16.2999326,15.6490905 16.0002686,15.9350527 C14.981908,16.9068502 13.5272614,17.4683443 11.9732225,17.4683443 C10.4874913,17.4683443 9.09149396,16.9554025 8.07958292,16.0577866 C7.76971309,15.7829165 7.7413402,15.3088912 8.01621029,14.9990213 C8.29108038,14.6891515 8.76510574,14.6607786 9.07497556,14.9356487 C9.80807442,15.5859442 10.8487959,15.9683443 11.9732225,15.9683443 C13.1481412,15.9683443 14.2304249,15.5505824 14.9647078,14.8498736 C15.2643717,14.5639114 15.7391155,14.5750188 16.0250778,14.8746828 Z M8.0120393,7.25 C8.95495605,7.25 9.84202633,7.57963027 10.4654744,8.15659894 C10.7694805,8.43794069 10.7878535,8.91245886 10.5065118,9.21646494 C10.22517,9.52047101 9.75065187,9.53884407 9.4466458,9.25750231 C9.10764506,8.94377482 8.58617631,8.75 8.0120393,8.75 C7.39164233,8.75 6.83479309,8.97649114 6.50406652,9.33044571 C6.22127247,9.63310129 5.74667177,9.64920225 5.44401619,9.3664082 C5.14136061,9.08361415 5.12525965,8.60901345 5.4080537,8.30635787 C6.03154763,7.63907395 6.98812162,7.25 8.0120393,7.25 Z M16.0120393,7.25 C16.954956,7.25 17.8420263,7.57963027 18.4654744,8.15659894 C18.7694805,8.43794069 18.7878535,8.91245886 18.5065118,9.21646494 C18.22517,9.52047101 17.7506519,9.53884407 17.4466458,9.25750231 C17.1076451,8.94377482 16.5861763,8.75 16.0120393,8.75 C15.3916423,8.75 14.8347931,8.97649114 14.5040665,9.33044571 C14.2212725,9.63310129 13.7466718,9.64920225 13.4440162,9.3664082 C13.1413606,9.08361415 13.1252597,8.60901345 13.4080537,8.30635787 C14.0315476,7.63907395 14.9881216,7.25 16.0120393,7.25 Z" id="形状结合" fill="#000000" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
{
|
||||
"hvigorVersion": "4.0.2",
|
||||
"hvigorVersion": "2.4.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "4.0.2"
|
||||
"@ohos/hvigor-ohos-plugin": "2.4.2"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 89 KiB |