Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
9a7fdcca
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9a7fdcca
编写于
5月 07, 2022
作者:
N
NOBUGGERS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
audioplayer base Signed-off-by: NOBUGGERS <ruanmeng@huawei.com>
Signed-off-by:
N
NOBUGGERS
<
ruanmeng@huawei.com
>
上级
c5dfb00a
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
938 addition
and
10 deletion
+938
-10
multimedia/media/media_js_standard/AudioPlayerTestBase.js
multimedia/media/media_js_standard/AudioPlayerTestBase.js
+153
-0
multimedia/media/media_js_standard/VideoPlayerTestBase.js
multimedia/media/media_js_standard/VideoPlayerTestBase.js
+8
-6
multimedia/media/media_js_standard/audioPlayer/src/main/config.json
.../media/media_js_standard/audioPlayer/src/main/config.json
+1
-1
multimedia/media/media_js_standard/audioRecorder/src/main/config.json
...edia/media_js_standard/audioRecorder/src/main/config.json
+1
-1
multimedia/media/media_js_standard/recorderFormat/BUILD.gn
multimedia/media/media_js_standard/recorderFormat/BUILD.gn
+31
-0
multimedia/media/media_js_standard/recorderFormat/Test.json
multimedia/media/media_js_standard/recorderFormat/Test.json
+25
-0
multimedia/media/media_js_standard/recorderFormat/signature/openharmony_sx.p7b
...a_js_standard/recorderFormat/signature/openharmony_sx.p7b
+0
-0
multimedia/media/media_js_standard/recorderFormat/src/main/config.json
...dia/media_js_standard/recorderFormat/src/main/config.json
+100
-0
multimedia/media/media_js_standard/recorderFormat/src/main/java/ohos/acts/multimedia/audio/audioplayer/MainAbility.java
...a/ohos/acts/multimedia/audio/audioplayer/MainAbility.java
+35
-0
multimedia/media/media_js_standard/recorderFormat/src/main/java/ohos/acts/multimedia/audio/audioplayer/MyApplication.java
...ohos/acts/multimedia/audio/audioplayer/MyApplication.java
+29
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/app.js
...dia_js_standard/recorderFormat/src/main/js/default/app.js
+23
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/i18n/en-US.json
...andard/recorderFormat/src/main/js/default/i18n/en-US.json
+6
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/i18n/zh-CN.json
...andard/recorderFormat/src/main/js/default/i18n/zh-CN.json
+6
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/pages/index/index.css
.../recorderFormat/src/main/js/default/pages/index/index.css
+61
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/pages/index/index.hml
.../recorderFormat/src/main/js/default/pages/index/index.hml
+20
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/pages/index/index.js
...d/recorderFormat/src/main/js/default/pages/index/index.js
+41
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/test/AudioRecorderFormatCompatibilityTest.test.js
...main/js/test/AudioRecorderFormatCompatibilityTest.test.js
+368
-0
multimedia/media/media_js_standard/recorderFormat/src/main/js/test/List.test.js
..._js_standard/recorderFormat/src/main/js/test/List.test.js
+16
-0
multimedia/media/media_js_standard/recorderFormat/src/main/resources/base/element/string.json
...ecorderFormat/src/main/resources/base/element/string.json
+12
-0
multimedia/media/media_js_standard/recorderFormat/src/main/resources/base/media/icon.png
...ard/recorderFormat/src/main/resources/base/media/icon.png
+0
-0
multimedia/media/media_js_standard/videoPlayer/src/main/config.json
.../media/media_js_standard/videoPlayer/src/main/config.json
+1
-1
multimedia/media/media_js_standard/videoRecorder/src/main/config.json
...edia/media_js_standard/videoRecorder/src/main/config.json
+1
-1
未找到文件。
multimedia/media/media_js_standard/AudioPlayerTestBase.js
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
media
from
'
@ohos.multimedia.media
'
import
*
as
mediaTestBase
from
'
./MediaTestBase.js
'
;
export
function
playAudioSource
(
src
,
duration
,
playTime
,
checkSeekTime
,
done
)
{
console
.
info
(
`case media source url:
${
src
}
`
)
let
volumeChanged
=
false
;
let
playCount
=
0
;
let
pauseCount
=
0
;
let
stopCount
=
0
;
let
seekCount
=
0
;
let
audioPlayer
=
media
.
createAudioPlayer
();
if
(
audioPlayer
==
null
)
{
console
.
error
(
'
case createAudioPlayer failed
'
);
expect
().
assertFail
();
done
();
}
audioPlayer
.
src
=
src
;
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
console
.
info
(
'
case set source success
'
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
paused
'
);
expect
(
audioPlayer
.
currentTime
).
assertEqual
(
0
);
expect
(
audioPlayer
.
duration
).
assertClose
(
duration
,
500
);
// step 0: dataLoad -> play
audioPlayer
.
play
();
});
audioPlayer
.
on
(
'
play
'
,
()
=>
{
console
.
info
(
'
case start to play
'
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
playing
'
);
playCount
++
;
if
(
playCount
==
1
)
{
// step 1: play -> seek duration/3
mediaTestBase
.
msleep
(
playTime
);
audioPlayer
.
seek
(
audioPlayer
.
duration
/
3
);
}
else
if
(
playCount
==
2
)
{
// step 5: play -> seek duration when loop is true
audioPlayer
.
loop
=
true
;
audioPlayer
.
seek
(
audioPlayer
.
duration
);
}
else
if
(
playCount
==
3
)
{
// step 9: play -> stop
audioPlayer
.
stop
();
}
else
{
// step 12: play -> pause
audioPlayer
.
pause
();
}
});
audioPlayer
.
on
(
'
pause
'
,
()
=>
{
console
.
info
(
'
case now is paused
'
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
paused
'
);
pauseCount
++
;
if
(
pauseCount
==
1
)
{
// step 3: pause -> seek 0
audioPlayer
.
seek
(
0
);
}
else
{
// step 13: pause -> stop
audioPlayer
.
stop
();
}
});
audioPlayer
.
on
(
'
stop
'
,
()
=>
{
console
.
info
(
'
case stop success
'
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
stopped
'
);
stopCount
++
;
if
(
stopCount
==
1
)
{
// step 10: stop -> reset
audioPlayer
.
reset
();
}
else
{
// step 14: stop -> release
expect
(
volumeChanged
).
assertEqual
(
true
);
audioPlayer
.
release
();
done
();
}
});
audioPlayer
.
on
(
'
reset
'
,
()
=>
{
console
.
info
(
'
case reset success
'
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
idle
'
);
// step 11: reset -> dataLoad
audioPlayer
.
src
=
src
;
});
audioPlayer
.
on
(
'
timeUpdate
'
,
(
seekDoneTime
)
=>
{
seekCount
++
;
if
(
seekDoneTime
==
null
)
{
console
.
info
(
`case seek filed`
);
audioPlayer
.
release
();
expect
().
assertFail
();
done
();
return
;
}
console
.
info
(
'
case seek success, and seek time is
'
+
seekDoneTime
);
if
(
seekCount
==
1
)
{
// step 2: seek duration/3 -> pause
expect
(
audioPlayer
.
state
).
assertEqual
(
'
playing
'
);
if
(
checkSeekTime
)
{
expect
(
audioPlayer
.
duration
/
3
).
assertEqual
(
seekDoneTime
);
}
mediaTestBase
.
msleep
(
playTime
);
audioPlayer
.
pause
();
}
else
if
(
seekCount
==
2
){
// step 4: seek 0 -> play
if
(
checkSeekTime
)
{
expect
(
0
).
assertEqual
(
seekDoneTime
);
}
expect
(
audioPlayer
.
state
).
assertEqual
(
'
paused
'
);
audioPlayer
.
play
();
}
else
if
(
seekCount
==
3
){
// step 6: seek duration -> setVolume + seek duration when loop is false
if
(
checkSeekTime
)
{
expect
(
audioPlayer
.
duration
).
assertEqual
(
seekDoneTime
);
}
mediaTestBase
.
msleep
(
playTime
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
playing
'
);
audioPlayer
.
loop
=
false
;
audioPlayer
.
setVolume
(
0.5
);
audioPlayer
.
seek
(
audioPlayer
.
duration
);
}
else
if
(
seekCount
==
4
){
// step 7: seek duration -> setVolume + seek duration when loop is false
if
(
checkSeekTime
)
{
expect
(
audioPlayer
.
duration
).
assertEqual
(
seekDoneTime
);
}
mediaTestBase
.
msleep
(
playTime
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
stopped
'
);
}
});
audioPlayer
.
on
(
'
volumeChange
'
,
()
=>
{
console
.
info
(
'
case set volume success
'
);
volumeChanged
=
true
;
});
audioPlayer
.
on
(
'
finish
'
,
()
=>
{
console
.
info
(
'
case play end
'
);
expect
(
audioPlayer
.
state
).
assertEqual
(
'
stopped
'
);
// step 8: play when stream is end
audioPlayer
.
play
();
});
audioPlayer
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
error
(
`case error called,errMessage is
${
err
.
message
}
`
);
audioPlayer
.
release
();
expect
().
assertFail
();
done
();
});
}
\ No newline at end of file
multimedia/media/media_js_standard/VideoPlayerTestBase.js
浏览文件 @
9a7fdcca
...
...
@@ -38,7 +38,7 @@ export async function clearRouter() {
await
router
.
clear
();
}
export
async
function
playVideoSource
(
url
,
width
,
height
,
duration
,
playTime
)
{
export
async
function
playVideoSource
(
url
,
width
,
height
,
duration
,
playTime
,
done
)
{
console
.
info
(
`case media source url:
${
url
}
`
)
let
videoPlayer
=
null
;
let
surfaceID
=
globalThis
.
value
;
...
...
@@ -49,6 +49,7 @@ export async function playVideoSource(url, width, height, duration, playTime) {
}
else
{
console
.
error
(
'
case createVideoPlayer failed
'
);
expect
().
assertFail
();
done
();
}
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
...
...
@@ -59,13 +60,14 @@ export async function playVideoSource(url, width, height, duration, playTime) {
videoPlayer
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
error
(
`case error called, errMessage is
${
err
.
message
}
`
);
expect
().
assertFail
();
videoPlayer
.
release
();
done
();
});
videoPlayer
.
url
=
url
;
if
(
width
!=
null
&
height
!=
null
)
{
await
videoPlayer
.
setDisplaySurface
(
surfaceID
).
then
(()
=>
{
console
.
info
(
'
case setDisplaySurface success, surfaceID:
'
+
surfaceID
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
await
videoPlayer
.
setDisplaySurface
(
surfaceID
).
then
(()
=>
{
console
.
info
(
'
case setDisplaySurface success, surfaceID:
'
+
surfaceID
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
await
videoPlayer
.
prepare
().
then
(()
=>
{
console
.
info
(
'
case prepare called
'
);
...
...
multimedia/media/media_js_standard/audioPlayer/src/main/config.json
浏览文件 @
9a7fdcca
...
...
@@ -44,7 +44,7 @@
}
],
"deviceType"
:
[
"
phone
"
,
"
default
"
,
"tablet"
,
"tv"
,
"wearable"
...
...
multimedia/media/media_js_standard/audioRecorder/src/main/config.json
浏览文件 @
9a7fdcca
...
...
@@ -44,7 +44,7 @@
}
],
"deviceType"
:
[
"
phone
"
,
"
default
"
,
"tablet"
,
"tv"
,
"wearable"
...
...
multimedia/media/media_js_standard/recorderFormat/BUILD.gn
0 → 100644
浏览文件 @
9a7fdcca
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("recorder_format_js_hap") {
hap_profile = "./src/main/config.json"
deps = [
":recorder_format_js_assets",
":recorder_format_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsRecorderFormatJsTest"
}
ohos_js_assets("recorder_format_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("recorder_format_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
multimedia/media/media_js_standard/recorderFormat/Test.json
0 → 100644
浏览文件 @
9a7fdcca
{
"description"
:
"Configuration for audioRecorder Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"1000000"
,
"package"
:
"ohos.acts.multimedia.audio.recorderformat"
,
"shell-timeout"
:
"60000"
},
"kits"
:
[
{
"type"
:
"ShellKit"
,
"run-command"
:
[
],
"teardown-command"
:[
]
},
{
"test-file-name"
:
[
"ActsRecorderFormatJsTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
\ No newline at end of file
multimedia/media/media_js_standard/recorderFormat/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
9a7fdcca
文件已添加
multimedia/media/media_js_standard/recorderFormat/src/main/config.json
0 → 100644
浏览文件 @
9a7fdcca
{
"app"
:
{
"apiVersion"
:
{
"compatible"
:
6
,
"releaseType"
:
"Beta1"
,
"target"
:
7
},
"vendor"
:
"acts"
,
"bundleName"
:
"ohos.acts.multimedia.audio.recorderformat"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
}
},
"deviceConfig"
:
{
"default"
:
{
"debug"
:
true
}
},
"module"
:
{
"abilities"
:
[
{
"iconId"
:
16777218
,
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"descriptionId"
:
16777217
,
"visible"
:
true
,
"labelId"
:
16777216
,
"icon"
:
"$media:icon"
,
"name"
:
"ohos.acts.multimedia.audio.recorderformat.MainAbility"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"homeAbility"
:
true
,
"launchType"
:
"standard"
}
],
"deviceType"
:
[
"default"
,
"tablet"
,
"tv"
,
"wearable"
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name"
:
"ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name"
:
"ohos.permission.MICROPHONE"
,
"reason"
:
"use ohos.permission.MICROPHONE"
},
{
"name"
:
"ohos.permission.MEDIA_LOCATION"
,
"reason"
:
"use ohos.permission.MEDIA_LOCATION"
},
{
"name"
:
"ohos.permission.READ_MEDIA"
,
"reason"
:
"use ohos.permission.READ_MEDIA"
},
{
"name"
:
"ohos.permission.WRITE_MEDIA"
,
"reason"
:
"use ohos.permission.WRITE_MEDIA"
}
],
"mainAbility"
:
"ohos.acts.multimedia.audio.recorderformat.MainAbility"
,
"distro"
:
{
"moduleType"
:
"entry"
,
"installationFree"
:
false
,
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
},
"package"
:
"ohos.acts.multimedia.audio.recorderformat"
,
"name"
:
".MyApplication"
,
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
true
}
}
]
}
}
\ No newline at end of file
multimedia/media/media_js_standard/recorderFormat/src/main/java/ohos/acts/multimedia/audio/audioplayer/MainAbility.java
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
ohos.acts.multimedia.audio.audioplayer
;
import
ohos.ace.ability.AceAbility
;
import
ohos.aafwk.content.Intent
;
/*
* java MainAbility
*/
public
class
MainAbility
extends
AceAbility
{
@Override
public
void
onStart
(
Intent
intent
)
{
super
.
onStart
(
intent
);
}
@Override
public
void
onStop
()
{
super
.
onStop
();
}
}
multimedia/media/media_js_standard/recorderFormat/src/main/java/ohos/acts/multimedia/audio/audioplayer/MyApplication.java
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
ohos.acts.multimedia.audio.audioplayer
;
import
ohos.aafwk.ability.AbilityPackage
;
/*
* java MyApplication
*/
public
class
MyApplication
extends
AbilityPackage
{
@Override
public
void
onInitialize
()
{
super
.
onInitialize
();
}
}
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/app.js
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export
default
{
onCreate
()
{
console
.
info
(
'
AceApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
AceApplication onDestroy
'
);
}
};
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
9a7fdcca
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
}
}
\ No newline at end of file
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
9a7fdcca
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
}
}
\ No newline at end of file
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100%
;
height
:
100%
;
}
.title
{
font-size
:
40px
;
color
:
#000000
;
opacity
:
0.9
;
}
@media
screen
and
(
device-type
:
tablet
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
100px
;
}
}
@media
screen
and
(
device-type
:
wearable
)
{
.title
{
font-size
:
28px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
tv
)
{
.container
{
background-image
:
url("/common/images/Wallpaper.png")
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
}
.title
{
font-size
:
100px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
phone
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
60px
;
}
}
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
9a7fdcca
<!--
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
multimedia/media/media_js_standard/recorderFormat/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow finish
'
)
const
core
=
Core
.
getInstance
()
const
expectExtend
=
new
ExpectExtend
({
'
id
'
:
'
extend
'
})
core
.
addService
(
'
expect
'
,
expectExtend
)
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
this
.
timeout
=
60000
configService
.
setConfig
(
this
)
require
(
'
../../../test/List.test
'
)
core
.
execute
()
},
onReady
()
{
},
}
\ No newline at end of file
multimedia/media/media_js_standard/recorderFormat/src/main/js/test/AudioRecorderFormatCompatibilityTest.test.js
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
media
from
'
@ohos.multimedia.media
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
AudioRecorderFormatCompatibilityTest
'
,
function
()
{
const
END_STATE
=
0
;
const
PRE_STATE
=
1
;
const
START_STATE
=
2
;
const
PAUSE_STATE
=
3
;
const
RESUME_STATE
=
4
;
const
STOP_STATE
=
5
;
const
RESET_STATE
=
6
;
const
RELEASE_STATE
=
7
;
const
ERROR_STATE
=
8
;
const
RECORDER_TIME
=
1000
;
let
fdPath
;
let
fileAsset
;
let
fdNumber
;
let
audioRecorder
;
let
audioConfig
=
{
audioSourceType
:
media
.
AudioSourceType
.
AUDIO_SOURCE_TYPE_MIC
,
audioEncoder
:
media
.
AudioSourceType
.
AAC_LC
,
audioEncodeBitRate
:
22050
,
audioSampleRate
:
22050
,
numberOfChannels
:
2
,
format
:
media
.
AudioOutputFormat
.
AAC_ADTS
,
uri
:
'
file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a
'
,
location
:
{
latitude
:
1
,
longitude
:
1
},
}
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
function
initAudioRecorder
()
{
if
(
typeof
(
audioRecorder
)
!=
'
undefined
'
)
{
audioRecorder
.
release
();
audioRecorder
=
undefined
;
}
audioRecorder
=
media
.
createAudioRecorder
();
}
beforeAll
(
async
function
()
{
await
applyPermission
();
console
.
info
(
'
beforeAll case
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach case
'
);
})
afterEach
(
async
function
()
{
await
closeFd
();
console
.
info
(
'
afterEach case
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll case
'
);
})
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.audio.recorderformat
'
,
0
,
100
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.MICROPHONE
'
;
let
permissionName2
=
'
ohos.permission.MEDIA_LOCATION
'
;
let
permissionName3
=
'
ohos.permission.READ_MEDIA
'
;
let
permissionName4
=
'
ohos.permission.WRITE_MEDIA
'
;
await
atManager
.
grantUserGrantedPermissi
on
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName3
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName4
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
error
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
getFd
(
pathName
)
{
let
displayName
=
pathName
;
const
mediaTest
=
mediaLibrary
.
getMediaLibrary
();
let
fileKeyObj
=
mediaLibrary
.
FileKey
;
let
mediaType
=
mediaLibrary
.
MediaType
.
VIDEO
;
let
publicPath
=
await
mediaTest
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_VIDEO
);
let
dataUri
=
await
mediaTest
.
createAsset
(
mediaType
,
displayName
,
publicPath
);
if
(
dataUri
!=
undefined
)
{
let
args
=
dataUri
.
id
.
toString
();
let
fetchOp
=
{
selections
:
fileKeyObj
.
ID
+
"
=?
"
,
selectionArgs
:
[
args
],
}
let
fetchFileResult
=
await
mediaTest
.
getFileAssets
(
fetchOp
);
fileAsset
=
await
fetchFileResult
.
getAllObject
();
fdNumber
=
await
fileAsset
[
0
].
open
(
'
Rw
'
);
fdPath
=
"
fd://
"
+
fdNumber
.
toString
();
console
.
info
(
`[mediaLibrary] case fdPath:
${
fdPath
}
`
);
}
else
{
console
.
error
(
'
[mediaLibrary] case dataUri is null
'
)
}
}
async
function
closeFd
()
{
if
(
fileAsset
!=
null
)
{
await
fileAsset
[
0
].
close
(
fdNumber
).
then
(()
=>
{
console
.
info
(
'
[mediaLibrary] case close fd success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
[mediaLibrary] case close fd failed
'
);
});
}
else
{
console
.
error
(
'
[mediaLibrary] case fileAsset is null
'
);
}
}
function
nextStep
(
mySteps
,
done
)
{
if
(
mySteps
[
0
]
==
END_STATE
)
{
done
();
console
.
info
(
'
case to done
'
);
return
;
}
switch
(
mySteps
[
0
])
{
case
PRE_STATE
:
console
.
info
(
'
case to prepare
'
);
audioRecorder
.
prepare
(
audioConfig
);
break
;
case
START_STATE
:
console
.
info
(
'
case to start
'
);
audioRecorder
.
start
();
break
;
case
PAUSE_STATE
:
console
.
info
(
'
case to pause
'
);
audioRecorder
.
pause
();
break
;
case
RESUME_STATE
:
console
.
info
(
'
case to resume
'
);
audioRecorder
.
resume
();
break
;
case
STOP_STATE
:
console
.
info
(
'
case to stop
'
);
audioRecorder
.
stop
();
break
;
case
RESET_STATE
:
console
.
info
(
'
case to reset
'
);
audioRecorder
.
reset
();
break
;
case
RELEASE_STATE
:
console
.
info
(
'
case to release
'
);
audioRecorder
.
release
();
audioRecorder
=
undefined
;
break
;
case
ERROR_STATE
:
console
.
info
(
'
case to wait error callback
'
);
break
;
default
:
break
;
}
}
function
setCallback
(
mySteps
,
done
)
{
audioRecorder
.
on
(
'
prepare
'
,
()
=>
{
console
.
info
(
'
setCallback prepare() case callback is called
'
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
start
'
,
()
=>
{
console
.
info
(
'
setCallback start() case callback is called
'
);
sleep
(
RECORDER_TIME
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
pause
'
,
()
=>
{
console
.
info
(
'
setCallback pause() case callback is called
'
);
sleep
(
RECORDER_TIME
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
resume
'
,
()
=>
{
console
.
info
(
'
setCallback resume() case callback is called
'
);
sleep
(
RECORDER_TIME
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
stop
'
,
()
=>
{
console
.
info
(
'
setCallback stop() case callback is called
'
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
reset
'
,
()
=>
{
console
.
info
(
'
setCallback reset() case callback is called
'
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
release
'
,
()
=>
{
console
.
info
(
'
setCallback release() case callback is called
'
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
audioRecorder
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
info
(
`case error called,errName is
${
err
.
name
}
`
);
console
.
info
(
`case error called,errCode is
${
err
.
code
}
`
);
console
.
info
(
`case error called,errMessage is
${
err
.
message
}
`
);
mySteps
.
shift
();
expect
(
mySteps
[
0
]).
assertEqual
(
ERROR_STATE
);
mySteps
.
shift
();
nextStep
(
mySteps
,
done
);
});
}
/* *
* @tc.number : SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0100
* @tc.name : location: {latitude: -90, longitude: -180}
* @tc.desc : location test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0100
'
,
0
,
async
function
(
done
)
{
await
getFd
(
'
COMPATIBILITY_0100.m4a
'
);
audioConfig
.
uri
=
fdPath
;
audioConfig
.
location
.
latitude
=
-
90
;
audioConfig
.
location
.
longitude
=
-
180
;
initAudioRecorder
();
let
mySteps
=
new
Array
(
PRE_STATE
,
START_STATE
,
STOP_STATE
,
RELEASE_STATE
,
END_STATE
);
setCallback
(
mySteps
,
done
);
audioRecorder
.
prepare
(
audioConfig
);
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0200
* @tc.name : location: {latitude: 90, longitude: 180}
* @tc.desc : location test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0200
'
,
0
,
async
function
(
done
)
{
await
getFd
(
'
COMPATIBILITY_0200.m4a
'
);
audioConfig
.
uri
=
fdPath
;
audioConfig
.
location
.
latitude
=
90
;
audioConfig
.
location
.
longitude
=
180
;
initAudioRecorder
();
let
mySteps
=
new
Array
(
PRE_STATE
,
START_STATE
,
STOP_STATE
,
RELEASE_STATE
,
END_STATE
);
setCallback
(
mySteps
,
done
);
audioRecorder
.
prepare
(
audioConfig
);
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0300
* @tc.name : location: {latitude: 0, longitude: 0}
* @tc.desc : location test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0300
'
,
0
,
async
function
(
done
)
{
await
getFd
(
'
COMPATIBILITY_0300.m4a
'
);
audioConfig
.
uri
=
fdPath
;
audioConfig
.
location
.
latitude
=
0
;
audioConfig
.
location
.
longitude
=
0
;
initAudioRecorder
();
let
mySteps
=
new
Array
(
PRE_STATE
,
START_STATE
,
STOP_STATE
,
RELEASE_STATE
,
END_STATE
);
setCallback
(
mySteps
,
done
);
audioRecorder
.
prepare
(
audioConfig
);
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0400
* @tc.name : location: {latitude: 0, longitude: 180}
* @tc.desc : location test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0400
'
,
0
,
async
function
(
done
)
{
await
getFd
(
'
COMPATIBILITY_0400.m4a
'
);
audioConfig
.
uri
=
fdPath
;
audioConfig
.
location
.
latitude
=
0
;
audioConfig
.
location
.
longitude
=
180
;
initAudioRecorder
();
let
mySteps
=
new
Array
(
PRE_STATE
,
START_STATE
,
STOP_STATE
,
RELEASE_STATE
,
END_STATE
);
setCallback
(
mySteps
,
done
);
audioRecorder
.
prepare
(
audioConfig
);
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0500
* @tc.name : location: {latitude: -30, longitude: 60}
* @tc.desc : location test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0500
'
,
0
,
async
function
(
done
)
{
await
getFd
(
'
COMPATIBILITY_0500.m4a
'
);
audioConfig
.
uri
=
fdPath
;
audioConfig
.
location
.
latitude
=
-
30
;
audioConfig
.
location
.
longitude
=
60
;
initAudioRecorder
();
let
mySteps
=
new
Array
(
PRE_STATE
,
START_STATE
,
STOP_STATE
,
RELEASE_STATE
,
END_STATE
);
setCallback
(
mySteps
,
done
);
audioRecorder
.
prepare
(
audioConfig
);
})
/* *
* @tc.number : SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0600
* @tc.name : location: {latitude: 60, longitude: -90}
* @tc.desc : location test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_AUDIO_RECORDER_FORMAT_COMPATIBILITY_0600
'
,
0
,
async
function
(
done
)
{
await
getFd
(
'
COMPATIBILITY_0600.m4a
'
);
audioConfig
.
uri
=
fdPath
;
audioConfig
.
location
.
latitude
=
60
;
audioConfig
.
location
.
longitude
=
-
90
;
initAudioRecorder
();
let
mySteps
=
new
Array
(
PRE_STATE
,
START_STATE
,
STOP_STATE
,
RELEASE_STATE
,
END_STATE
);
setCallback
(
mySteps
,
done
);
audioRecorder
.
prepare
(
audioConfig
);
})
})
multimedia/media/media_js_standard/recorderFormat/src/main/js/test/List.test.js
0 → 100644
浏览文件 @
9a7fdcca
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require
(
'
./AudioRecorderFormatCompatibilityTest.test.js
'
)
multimedia/media/media_js_standard/recorderFormat/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
9a7fdcca
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"entry_MainAbility"
},
{
"name"
:
"mainability_description"
,
"value"
:
"JS_Empty Ability"
}
]
}
\ No newline at end of file
multimedia/media/media_js_standard/recorderFormat/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
9a7fdcca
6.6 KB
multimedia/media/media_js_standard/videoPlayer/src/main/config.json
浏览文件 @
9a7fdcca
...
...
@@ -44,7 +44,7 @@
}
],
"deviceType"
:
[
"
phone
"
,
"
default
"
,
"tablet"
,
"tv"
,
"wearable"
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/config.json
浏览文件 @
9a7fdcca
...
...
@@ -44,7 +44,7 @@
}
],
"deviceType"
:
[
"
phone
"
,
"
default
"
,
"tablet"
,
"tv"
,
"wearable"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录