diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index f4b0f53bfacb7cff5f621394de29ced09d87674c..12b1b040c1bf38ae0c3b4500a33edb0af1025600 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -46,6 +46,7 @@ group("multimedia") { "media/media_js_standard/audioPlayer:audio_player_js_hap", "media/media_js_standard/audioRecorder:audio_recorder_js_hap", "media/media_js_standard/avRecorder:av_recorder_js_hap", + "media/media_js_standard/avPlayer:avplayer_js_hap", "media/media_js_standard/recorderFormat:recorder_format_js_hap", "media/media_js_standard/videoPlayer:video_player_js_hap", "medialibrary/mediaLibrary_album:mediaLibrary_album_hap", diff --git a/multimedia/media/media_js_standard/AVPlayerTestBase.js b/multimedia/media/media_js_standard/AVPlayerTestBase.js new file mode 100644 index 0000000000000000000000000000000000000000..b609c55bd0cf24dea4a2dc7c5379849eda54457c --- /dev/null +++ b/multimedia/media/media_js_standard/AVPlayerTestBase.js @@ -0,0 +1,2342 @@ +/* + * 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 const AV_PLAYER_STATE = { + IDLE : 'idle', + INITIALIZED : 'initialized', + PREPARED : 'prepared', + PLAYING : 'playing', + PAUSED : 'paused', + COMPLETED : 'completed', + STOPPED : 'stopped', + RELEASED : 'released', + ERROR : 'error', +} + +let playTest = { + width: 0, + height: 0, + duration: -1 +} +export {playTest}; + +export function setSource(avPlayer, src) { + if (typeof(avPlayer) == 'undefined') { + console.error('case avPlayer is undefined'); + return; + } + if (typeof(src) == 'string') { + console.info('case src test'); + avPlayer.url = src; + } else { + console.info('case fdsrc test'); + avPlayer.fdSrc = src; + } +} + +function checkPlayTest(avPlayer, playTest) { + if (avPlayer == null) { + return; + } + expect(Math.abs(avPlayer.duration - playTest.duration)).assertLess(500); + if (playTest.width > 0) { + expect(avPlayer.width).assertEqual(playTest.width); + expect(avPlayer.height).assertEqual(playTest.height); + } +} + +function toPreparePromise(avPlayer, playTest) { + if (typeof(avPlayer) == 'undefined') { + return; + } + avPlayer.prepare().then(() => { + console.info('case prepare called'); + console.info('case avPlayer.duration: ' + avPlayer.duration); + checkPlayTest(avPlayer, playTest); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +async function preparePromise(avPlayer) { + if (typeof(avPlayer) == 'undefined') { + return; + } + await avPlayer.prepare().then(() => { + console.info('case prepare called'); + console.info('case avPlayer.duration: ' + avPlayer.duration); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +function addCnt(countArr) { + if (countArr != null) { + countArr[0]++; + } +} + +export function setCallback(avPlayer, type, countArr) { + if (avPlayer == null) { + return; + } + switch (type) { + case 'volumeChange': + avPlayer.on('volumeChange', (volume) => { + console.info(`case volumeChange called, volume is ${volume}`); + addCnt(countArr); + }); + break; + case 'endOfStream': + avPlayer.on('endOfStream', () => { + console.info(`case endOfStream called`); + addCnt(countArr); + }); + break; + case 'speedDone': + avPlayer.on('speedDone', (speedMode) => { + console.info(`case speedDone called, speedMode is ${speedMode}`); + addCnt(countArr); + }); + break; + case 'bitrateDone': + avPlayer.on('bitrateDone', (bitrate) => { + console.info(`case bitrateDone called, bitrate is ${bitrate}`); + }); + break; + case 'timeUpdate': + avPlayer.on('timeUpdate', (time) => { + console.info('case timeUpdate callback, time:' + time); + }); + break; + case 'bufferingUpdate': + avPlayer.on('bufferingUpdate', (infoType, value) => { + }); + break; + case 'durationUpdate': + avPlayer.on('durationUpdate', (duration) => { + console.info('case durationUpdate called,duration:' + duration); + addCnt(countArr); + }); + break; + case 'startRenderFrame': + avPlayer.on('startRenderFrame', () => { + console.info('case startRenderFrame called'); + addCnt(countArr); + }); + break; + case 'videoSizeChange': + avPlayer.on('videoSizeChange', (w, h) => { + console.info(`case videoSizeChange called, weight is ${w}, height is ${h}`); + addCnt(countArr); + }); + break; + case 'audioInterrupt': + avPlayer.on('audioInterrupt', (info) => { + console.info(`case audioInterrupt called, info is ${info}`); + }); + break; + case 'availableBitrates': + avPlayer.on('availableBitrates', (bitrates) => { + for (let i = 0; i < bitrates.length; i++) { + console.info('case availableBitrates : ' + bitrates[i]); + } + addCnt(countArr); + }); + break; + default: + break; + } +} + +export function offCallback(avPlayer, typeArr) +{ + if (avPlayer == null) { + return; + } + for (let i = 0; i < typeArr.length; i++) { + switch (typeArr[i]) { + case 'stateChange': + avPlayer.off('stateChange'); + break; + case 'volumeChange': + avPlayer.off('volumeChange'); + break; + case 'endOfStream': + avPlayer.off('endOfStream'); + break; + case 'seekDone': + avPlayer.off('seekDone'); + break; + case 'speedDone': + avPlayer.off('speedDone'); + break; + case 'speedDone': + avPlayer.off('speedDone'); + break; + case 'timeUpdate': + avPlayer.off('timeUpdate'); + break; + case 'durationUpdate': + avPlayer.off('durationUpdate'); + break; + case 'bufferingUpdate': + avPlayer.off('bufferingUpdate'); + break; + case 'startRenderFrame': + avPlayer.off('startRenderFrame'); + break; + case 'videoSizeChange': + avPlayer.off('videoSizeChange'); + break; + case 'audioInterrupt': + avPlayer.off('audioInterrupt'); + break; + case 'availableBitrates': + avPlayer.off('availableBitrates'); + break; + case 'error': + avPlayer.off('error'); + break; + default: + break; + } + } +} + +export function setAVPlayerFunCb(src, avPlayer, playTest, playTime, done) { + let volumeCnt = [0]; + let endOfStreamCnt = [0]; + let speedDoneCnt = [0]; + let videoSizeCnt = [0]; + let startRenderFrameCnt = [0]; + let durationUpdateCnt = [0]; + let seekDoneCnt = [0]; + let prepareCnt = 0; + let playCnt = 0; + let completedCnt = 0; + let surfaceID = globalThis.value; + console.info(`case setAVPlayerFunCb in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + if (reason == media.StateChangeReason.BACKGROUND) { + console.info(`case media.StateChangeReason.BACKGROUND`); + await avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + avPlayer.surfaceId = surfaceID; + // step 1, 13: initialized -> prepared + toPreparePromise(avPlayer, playTest); + break; + case AV_PLAYER_STATE.PREPARED: + prepareCnt++; + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + checkPlayTest(avPlayer, playTest); + expect(avPlayer.currentTime).assertEqual(0); + if (prepareCnt == 1) { + // step 2: prepared -> playing + avPlayer.play().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } else { + // step 14: prepared -> seek + avPlayer.seek(avPlayer.duration); + } + break; + case AV_PLAYER_STATE.PLAYING: + playCnt++; + if (playCnt == 1) { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + // step 3: playing -> seek duration/3 + await mediaTestBase.msleepAsync(playTime); + avPlayer.seek(avPlayer.duration / 3); + } else if (playCnt == 2) { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + // step 7: playing -> seek duration when loop true + avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC); + } else if (playCnt == 3) { + // step 10: playing -> stop + avPlayer.stop().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + break; + case AV_PLAYER_STATE.PAUSED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + // step 5: pause -> seek 0 + avPlayer.loop = true; + avPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC); + break; + case AV_PLAYER_STATE.COMPLETED: + completedCnt++; + expect(avPlayer.currentTime).assertEqual(avPlayer.duration); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.COMPLETED); + if (completedCnt == 1) { + // step 9: completed -> play + avPlayer.play(); + } else { + // step 16: completed -> reset + avPlayer.reset().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + // step 17: reset -> release + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + break; + case AV_PLAYER_STATE.STOPPED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.STOPPED); + // step 11: stop -> reset + avPlayer.reset().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + // step 12: reset -> initialized + setSource(avPlayer, src); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case AV_PLAYER_STATE.RELEASED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + // step 18: release -> done + avPlayer = null; + expect(volumeCnt[0]).assertLarger(0); + expect(endOfStreamCnt[0]).assertLarger(0); + expect(seekDoneCnt[0]).assertLarger(0); + expect(speedDoneCnt[0]).assertLarger(0); + expect(completedCnt).assertLarger(0); + if (playTest.width != 0) { + expect(startRenderFrameCnt[0]).assertLarger(0); + expect(videoSizeCnt[0]).assertLarger(0); + } else { + expect(startRenderFrameCnt[0]).assertEqual(0); + expect(videoSizeCnt[0]).assertEqual(0); + } + expect(durationUpdateCnt[0]).assertLarger(0) + done(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('seekDone', async (seekDoneTime) => { + seekDoneCnt[0]++; + console.info(`case seekDone called, seekDoneCnt is ${seekDoneCnt}, seekDoneTime is ${seekDoneTime}`); + switch (seekDoneCnt[0]) { + case 2: + // step 6: seek(paused) -> play + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + avPlayer.play(); + avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X); + avPlayer.setVolume(0.5); + break; + case 1: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + // step 4: seek(playing) -> pause + avPlayer.pause().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case 3: + case 4: + case 5: + let nowTime = avPlayer.currentTime; + if (avPlayer.state == AV_PLAYER_STATE.PREPARED) { + // step 15: prepared -> play + avPlayer.play(); + } + if (nowTime > avPlayer.duration / 2) { + avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X); + await mediaTestBase.msleepAsync(avPlayer.duration - nowTime + playTime); + } + if (avPlayer.loop == true) { + // step 8: playing -> seek duration when loop false + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + avPlayer.loop = false; + avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC); + } + break; + } + }); + setCallback(avPlayer, 'volumeChange', volumeCnt); + setCallback(avPlayer, 'endOfStream', endOfStreamCnt); + setCallback(avPlayer, 'speedDone', speedDoneCnt); + setCallback(avPlayer, 'bitrateDone', null); + setCallback(avPlayer, 'timeUpdate', null); + setCallback(avPlayer, 'bufferingUpdate', null); + setCallback(avPlayer, 'durationUpdate', durationUpdateCnt); + setCallback(avPlayer, 'startRenderFrame', startRenderFrameCnt); + setCallback(avPlayer, 'videoSizeChange', videoSizeCnt); + setCallback(avPlayer, 'audioInterrupt', null); + setCallback(avPlayer, 'availableBitrates', null); + avPlayer.on('error', async (err) => { + console.error(`case error called, errMessage is ${err.message}`); + expect().assertFail(); + await avPlayer.release().then(() => { + avPlayer = null; + done(); + }); + }); +} + +export function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +function setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTime, done) { + let playPauseCount = 0; + let surfaceID = globalThis.value; + console.info(`case setAVPlayerPlayAndPauseWithCallBack in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('playPauseLoopWithCallBack play state is INITIALIZED') + // step 1: initialized -> prepared -> play + preparePromise(avPlayer); + await sleep(2000); + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + avPlayer.loop = true; + console.info('playPauseLoopWithCallBack play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + playPauseCount++; + await mediaTestBase.msleepAsync(playTime); + if(playPauseCount == 1001){ + // step 4: playing -> stop -> release + avPlayer.stop().then(() => { + console.info('playPauseLoopWithCallBack avPlayer from play to stop') + avPlayer.release().then(() => { + console.info('playPauseLoopWithCallBack avPlayer from stop to release') + offCallback(avPlayer, ['stateChange', 'error']); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + // step 2: playing -> pause loop + avPlayer.pause().then(() => { + console.info('playPauseLoopWithCallBack avPlayer from play to pause,time is :' + playPauseCount) + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('playPauseLoopWithCallBack play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + // step 3: pause -> playing loop + avPlayer.play().then(() => { + console.info('playPauseLoopWithCallBack avPlayer from pause to play,time is :' + playPauseCount) + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('error', async (err) => { + console.error(`case error called, errMessage is ${err.message}`); + expect().assertFail(); + await avPlayer.release().then(() => { + avPlayer = null; + done(); + }); + }); +} + +async function idle(src, avPlayer) { + console.info(`case media source: ${src}`) + await media.createAVPlayer().then((video) => { + if (typeof(video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + } else { + console.error('case createAVPlayer failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + return avPlayer; +} + +export async function avPlayerWithCallBack(src, avPlayer, playTime, done) { + avPlayer = await idle(src, avPlayer) + setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTime, done); + await setSource(avPlayer, src); +} + +async function playToPauseLoop(avPlayer){ + await avPlayer.play().then(() => { + console.info('playToPauseLoop play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('playToPauseLoop play filed,error message is :' + err.message) + }) + if(avPlayer.state == AV_PLAYER_STATE.PLAYING){ + avPlayer.loop = true; + await mediaTestBase.msleepAsync(2); + console.info('playToPauseLoop avPlayer from play to pause') + } + await avPlayer.pause().then(() => { + console.info('playToPauseLoop pause success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + }, (err) => { + console.error('playToPauseLoop pause filed,error message is :' + err.message) + }) +} + +export async function createToRelease(src, avPlayer, done) { + for(var i = 0;i < 1000; i++){ + let surfaceID = globalThis.value; + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('CreateToRelease setSource'); + if(avPlayer.state == AV_PLAYER_STATE.INITIALIZED) { + avPlayer.surfaceId = surfaceID; + await avPlayer.release().then(() => { + console.info('CreateToRelease avPlayer from stop to release') + console.info(`case CreateToRelease loop is ${i}`); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + } + done(); +} + +export async function playToCompleted(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + playToCompletedLoop(src, avPlayer, done); + await setSource(avPlayer, src); +} + +async function playToCompletedLoop(src, avPlayer, done) { + let playToCompletedCount = 0; + let surfaceID = globalThis.value; + console.info(`case playToCompletedLoop in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('playToCompletedLoop play state is INITIALIZED') + // step 1: initialized -> prepared -> play + preparePromise(avPlayer); + await sleep(2000); + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + avPlayer.loop = false; + console.info('playToCompletedLoop play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + playToCompletedCount++; + if(playToCompletedCount == 1001){ + // step 4: playing -> stop -> release + avPlayer.stop().then(() => { + console.info('playToCompletedLoop avPlayer from play to stop') + avPlayer.release().then(() => { + console.info('playToCompletedLoop avPlayer from stop to release') + offCallback(avPlayer, ['stateChange', 'error']); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + // step 2: playing -> seek loop + avPlayer.seek(10034, media.SeekMode.SEEK_NEXT_SYNC) + console.info('playToCompletedLoop avPlayer from play to seek,time is :' + playToCompletedCount) + } + break; + case AV_PLAYER_STATE.COMPLETED: + expect(avPlayer.currentTime).assertEqual(avPlayer.duration); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.COMPLETED); + console.info('playToCompletedLoop avPlayer from COMPLETED to play') + // step 3: COMPLETED -> play loop + avPlayer.play(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('error', async (err) => { + console.error(`case error called, errMessage is ${err.message}`); + expect().assertFail(); + await avPlayer.release().then(() => { + avPlayer = null; + done(); + }); + }); +} + +export async function seekLoop(src, avPlayer, done) { + let surfaceID = globalThis.value; + avPlayer = await idle(src, avPlayer) + seekLoopWithCallback(avPlayer); + await setSource(avPlayer, src); + if(avPlayer.state == AV_PLAYER_STATE.INITIALIZED) { + avPlayer.surfaceId = surfaceID; + console.info('seekLoop case prepare success'); + preparePromise(avPlayer); + await sleep(2000); + } + await avPlayer.play().then(() => { + console.info('seekLoop play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('seekLoop play filed,error message is :' + err.message) + }) + if(avPlayer.state == AV_PLAYER_STATE.PLAYING){ + console.info('seekLoop avPlayer from play to seek') + // play seek loop 1000 times + for(var loopTime = 0;loopTime < 1000; loopTime++){ + avPlayer.seek(loopTime) + console.info(`case seekLoopWithCallback loopTime is ${loopTime}`); + } + } + await avPlayer.stop().then(() => { + console.info('seekLoopWithCallback avPlayer from play to stop') + offCallback(avPlayer, ['stateChange', 'seekDone']); + avPlayer.release().then(() => { + console.info('seekLoopWithCallback avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +async function seekLoopWithCallback(avPlayer) { + avPlayer.on('seekDone', async (seekDoneTime) => { + console.info(`case seekDone called seekDoneTime is ${seekDoneTime}`); + }); +} + +export async function seekLoopWithoutCallback(src, avPlayer, done) { + let surfaceID = globalThis.value; + console.info(`case Initialized in, surfaceID is ${surfaceID}`); + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + if(avPlayer.state == AV_PLAYER_STATE.INITIALIZED) { + avPlayer.surfaceId = surfaceID; + preparePromise(avPlayer); + await sleep(2000); + } + await avPlayer.play().then(() => { + console.info('seekLoopWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('seekLoopWithoutCallback play filed,error message is :' + err.message) + }) + if(avPlayer.state == AV_PLAYER_STATE.PLAYING){ + console.info('seekLoopWithoutCallback avPlayer from play to seek') + // play seek loop 1000 times + for(var loopTime = 0;loopTime < 1000; loopTime++){ + avPlayer.seek(loopTime) + console.info(`case seekLoopWithoutCallback loopTime is ${loopTime}`); + } + } + await avPlayer.stop().then(() => { + console.info('seekLoopWithoutCallback avPlayer from play to stop') + avPlayer.release().then(() => { + console.info('seekLoopWithoutCallback avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +export async function prepareToStopLoop(src, avPlayer, done) { + let surfaceID = globalThis.value; + console.info(`case prepareToStopLoop Initialized in, surfaceID is ${surfaceID}`); + avPlayer = await idle(src, avPlayer) + setSource(avPlayer, src); + console.info('prepareToStopLoop setSource'); + if(avPlayer.state == AV_PLAYER_STATE.INITIALIZED) { + avPlayer.surfaceId = surfaceID; + } + // prepare to stop loop 1000 times + for(var i = 0;i < 1000; i++){ + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('prepareToStopLoop avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + console.info('prepareToStopLoop avPlayer from prepare to stop') + + await avPlayer.stop().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.STOPPED); + console.info('prepareToStopLoop avPlayer state is stop') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + console.info(`case PrepareToStopLoop is ${i}`); + } + await avPlayer.release().then(() => { + console.info('prepareToStopLoop avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +export async function prepareToResetLoop(src, avPlayer, done) { + let surfaceID = globalThis.value; + console.info(`case prepareToResetLoop Initialized in, surfaceID is ${surfaceID}`); + avPlayer = await idle(src, avPlayer) + // url -> prepare -> play -> reset loop 1000 times + for(var i = 0;i < 1000; i++){ + await setSource(avPlayer, src); + console.info('prepareToResetLoop setSource'); + console.info('prepareToResetLoop avPlayer state is :' + avPlayer.state) + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('prepareToResetLoop avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await avPlayer.play().then(() => { + console.info('prepareToResetLoop play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('prepareToResetLoop play filed,error message is :' + err.message) + }) + + await avPlayer.reset().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + console.info('prepareToResetLoop avPlayer state is reset') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + console.info(`case prepareToReset loop is ${i}`); + } + + await avPlayer.release().then(() => { + console.info('prepareToResetLoop avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +export async function createToReleaseLoop(src, avPlayer, done) { + for(var i = 0;i < 1000; i++){ + let surfaceID = globalThis.value; + console.info(`case createToReleaseLoop Initialized in, surfaceID is ${surfaceID}`); + avPlayer = await idle(src, avPlayer) + // url -> prepare -> play -> reset loop 1000 times + await setSource(avPlayer, src); + console.info('createToReleaseLoop setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('createToReleaseLoop avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await avPlayer.play().then(() => { + console.info('createToReleaseLoop play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('createToReleaseLoop play filed,error message is :' + err.message) + }) + await avPlayer.release().then(() => { + console.info('createToReleaseLoop avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + console.info(`case createToReleaseLoop loop is ${i}`); + } + await avPlayer.release().then(() => { + console.info('createToReleaseLoop avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +let createLoopTime = 0; +let createTotalTime = 0; +let createStart; +export async function createTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + createStart = Date.now(); + console.info(`createTimeWithCallback createStart time is : ${createStart}`) + createTimeWithCallback(src, avPlayer, done) +} + +function createTimeCallback(src, avPlayer, done){ + let end; + let execution; + avPlayer.on('stateChange', async (state, reason) => { + console.info(`createTimeCallback stateChange called, state is ${state}, reason is ${reason}`); + console.info(`createTimeCallback state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.IDLE: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + end = Date.now(); + console.info(`createTimeCallback end time is : ${end}`) + execution = parseInt(end - createStart) + createTotalTime = createTotalTime + execution; + console.info("createTimeCallback execution time is :" + execution) + createLoopTime++; + avPlayer.release() + case AV_PLAYER_STATE.RELEASED: + console.info('createTimeCallback play state is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + if(createLoopTime == 10){ + let avg = createTotalTime/10; + console.info("createTimeCallback avg time is :" + avg) + createLoopTime = 0; + createTotalTime = 0; + done(); + }else{ + avPlayer = null; + createTimeWithCallback(src, avPlayer, done) + } + break; + default: + break; + } + }); +} + +export async function createTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + for(var i = 0;i < 10;i++){ + let start = Date.now(); + console.info(`createTimeWithoutCallback start time is : ${start}`) + avPlayer = await idle(src, avPlayer) + let end = Date.now() + let execution = parseInt(end - start) + console.info("createTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('createTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("createTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function prepareTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('prepareTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + let start = Date.now(); + console.info(`prepareTimeWithoutCallback start time is : ${start}`) + let end; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('prepareTimeWithoutCallback avPlayer state is prepared') + end = Date.now() + console.info(`prepareTimeWithoutCallback end time is : ${end}`) + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let execution = parseInt(end - start) + console.info("prepareTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('prepareTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("prepareTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function prepareTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + prepareTimeCallback(src, avPlayer, done) + await setSource(avPlayer, src); +} + +async function prepareTimeCallback(src, avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.IDLE: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + if(loopTime == 10){ + avPlayer.release().then(() => { + console.info('prepareTimeWithCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("prepareTimeWithCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + setSource(avPlayer, src) + } + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('prepareTimeWithCallback play state is INITIALIZED') + // step 1: initialized -> prepared + start = Date.now(); + console.info(`prepareTimeWithCallback start time is : ${start}`) + avPlayer.prepare() + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('prepareTimeWithCallback avPlayer state is prepared') + end = Date.now(); + console.info(`prepareTimeWithCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("prepareTimeWithCallback execution time is :" + execution) + totalTime = totalTime + execution; + loopTime++; + avPlayer.reset() + break; + default: + break; + } + }); +} + +export async function playTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('playTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('playTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let start = Date.now(); + let end; + console.info(`playTimeWithoutCallback start time is : ${start}`) + await avPlayer.play().then(() => { + end = Date.now(); + console.info(`playTimeWithoutCallback end time is : ${end}`) + console.info('playTimeWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('playTimeWithoutCallback play filed,error message is :' + err.message) + }) + let execution = parseInt(end - start) + console.info("playTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('playTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("playTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function playTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + playTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +export function playTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('playTimeCallback play state is INITIALIZED') + // step 1: initialized -> prepared + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('playTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('playTimeCallback avPlayer state is prepared') + start = Date.now(); + console.info(`playTimeCallback start time is : ${start}`) + // step 2: prapared -> play + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('playTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + end = Date.now(); + console.info(`playTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("playTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + loopTime++; + if(loopTime == 10){ + avPlayer.release().then(() => { + console.info('playTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("playTimeWithCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + avPlayer.pause() + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('playTimeWithCallback play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + start = Date.now(); + console.info(`playTimeCallback start time is : ${start}`) + // step 3: pause -> playing loop + avPlayer.play().then(() => { + console.info('playTimeWithCallback avPlayer from pause to play') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); +} + +export async function pauseTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + let execution; + let end; + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('pauseTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('pauseTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await avPlayer.play().then(() => { + console.info('pauseTimeWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('pauseTimeWithoutCallback play filed,error message is :' + err.message) + }) + let start = Date.now(); + + console.info(`pauseTimeWithoutCallback start time is : ${start}`) + await avPlayer.pause().then(() => { + console.info('pauseTimeWithoutCallback pause success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + end = Date.now(); + console.info(`pauseTimeWithoutCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("pauseTimeWithoutCallback execution time is :" + execution) + }, (err) => { + console.error('pauseTimeWithoutCallback pause filed,error message is :' + err.message) + }) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('pauseTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("pauseTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function pauseTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + pauseTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +function pauseTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('pauseTimeCallback play state is INITIALIZED') + // step 1: initialized -> prepared + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('pauseTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('pauseTimeCallback avPlayer state is prepared') + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('pauseTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + start = Date.now(); + console.info(`pauseTimeCallback start time is : ${start}`) + avPlayer.pause(); + break; + case AV_PLAYER_STATE.PAUSED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + end = Date.now(); + console.info(`pauseTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("pauseTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + loopTime++; + if(loopTime == 10){ + avPlayer.release().then(() => { + console.info('pauseTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("pauseTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + avPlayer.play() + } + break; + default: + break; + } + }); +} + +export async function stopTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('stopTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('stopTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await avPlayer.play().then(() => { + console.info('stopTimeWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('stopTimeWithoutCallback play filed,error message is :' + err.message) + }) + let start = Date.now(); + console.info(`stopTimeWithoutCallback start time is : ${start}`) + let end; + await avPlayer.stop().then(() => { + end = Date.now(); + console.info(`stopTimeWithoutCallback end time is : ${end}`) + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.STOPPED); + console.info('stopTimeWithoutCallback avPlayer state is stop') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let execution = parseInt(end - start) + console.info("stopTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('stopTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("stopTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function stopTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + stopTimeCallback(src, avPlayer, done) + await setSource(avPlayer, src); +} + +function stopTimeCallback(src, avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.IDLE: + setSource(avPlayer, src); + break; + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('stopTimeCallback play state is INITIALIZED') + // step 1: initialized -> prepared + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('stopTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('stopTimeCallback avPlayer state is prepared') + start = Date.now(); + console.info(`stopTimeCallback start time is : ${start}`) + loopTime++; + avPlayer.stop() + break; + case AV_PLAYER_STATE.STOPPED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.STOPPED); + end = Date.now(); + console.info(`stopTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("stopTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + if(loopTime == 10){ + avPlayer.release().then(() => { + console.info('stopTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("stopTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + avPlayer.reset() + } + break; + default: + break; + } + }); +} + +export async function resetTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('resetTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('resetTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let end; + await avPlayer.play().then(() => { + console.info('resetTimeWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('resetTimeWithoutCallback play filed,error message is :' + err.message) + }) + let start = Date.now(); + console.info(`resetTimeWithoutCallback start time is : ${start}`) + await avPlayer.reset().then(() => { + end = Date.now(); + console.info(`resetTimeWithoutCallback end time is : ${end}`) + console.info('reset success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + }, (err) => { + console.error('reset filed,error message is :' + err.message) + }) + let execution = parseInt(end - start) + console.info("resetTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('resetTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("resetTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function resetTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + resetTimeCallback(src, avPlayer, done) + await setSource(avPlayer, src); +} + +function resetTimeCallback(src, avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.IDLE: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + end = Date.now(); + console.info(`resetTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("resetTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + loopTime++; + if(loopTime == 10){ + avPlayer.release().then(() => { + console.info('resetTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("resetTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + setSource(avPlayer, src) + } + break; + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('resetTimeCallback play state is INITIALIZED') + start = Date.now(); + console.info(`resetTimeCallback start time is : ${start}`) + avPlayer.reset().then(() => { + console.info('reset success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); +} + +export async function releaseTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('releaseTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + let start = Date.now(); + console.info(`releaseTimeWithoutCallback start time is : ${start}`) + let end; + await avPlayer.release().then(() => { + console.info('releaseTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + end = Date.now(); + console.info(`releaseTimeWithoutCallback end time is : ${end}`) + let execution = parseInt(end - start) + console.info("releaseTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + } + let avg = totalTime/10; + console.info("releaseTimeWithoutCallback avg time is :" + avg) + done(); +} + +let releaseTotalTime = 0; +let releaseLoop = 0; +export async function releaseTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + releaseTimeCallback(src, avPlayer, done) + await setSource(avPlayer, src); +} + +function releaseTimeCallback(src, avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('releaseTimeCallback play state is INITIALIZED') + start = Date.now(); + console.info(`releaseTimeCallback start time is : ${start}`) + avPlayer.release() + break; + case AV_PLAYER_STATE.RELEASED: + console.info('releaseTimeCallback play state is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + end = Date.now(); + console.info(`releaseTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("releaseTimeCallback execution time is :" + execution) + releaseTotalTime = releaseTotalTime + execution; + releaseLoop++; + if(releaseLoop == 10){ + let avg = releaseTotalTime/10; + console.info("createTimeCallback avg time is :" + avg) + releaseTotalTime = 0; + releaseLoop = 0; + done(); + }else{ + avPlayer = null; + releaseTimeWithCallback(src, avPlayer, done) + } + break; + default: + break; + } + }); +} + +export function getTotalTime(releaseTotalTime){ + return releaseTotalTime; +} + +export async function seekTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('seekTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('seekTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let end; + await avPlayer.play().then(() => { + console.info('seekTimeWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('seekTimeWithoutCallback play filed,error message is :' + err.message) + }) + let start = Date.now(); + console.info(`seekTimeWithoutCallback start time is : ${start}`) + await avPlayer.seek(100) + end = Date.now(); + console.info(`seekTimeWithoutCallback end time is : ${end}`) + let execution = parseInt(end - start) + console.info("seekTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('seekTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("seekTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function seekTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + seekTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +function seekTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('seekTimeCallback play state is INITIALIZED') + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('seekTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('seekTimeCallback avPlayer state is prepared') + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('seekTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + start = Date.now(); + console.info(`seekTimeCallback start time is : ${start}`) + loopTime+=20; + if(loopTime == 220){ + avPlayer.release().then(() => { + console.info('seekTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("seekTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + avPlayer.seek(loopTime) + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('seekTimeCallback play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + avPlayer.play().then(() => { + console.info('seekTimeCallback avPlayer from pause to play') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('seekDone', async (seekDoneTime) => { + end = Date.now(); + console.info(`seekTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("seekTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + console.info(`case seekDone called seekDoneTime is ${seekDoneTime}`); + avPlayer.pause() + }); +} + +export async function getTrackDescriptionTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('getTrackDescriptionTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('getTrackDescriptionTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await avPlayer.play().then(() => { + console.info('getTrackDescriptionTimeWithoutCallback play success'); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + }, (err) => { + console.error('getTrackDescriptionTimeWithoutCallback play filed,error message is :' + err.message) + }) + let arrayDescription; + let start = Date.now(); + console.info(`getTrackDescriptionTimeWithoutCallback start time is : ${start}`) + let end; + await avPlayer.getTrackDescription().then((arrList) => { + if (arrList != null) { + arrayDescription = arrList; + } else { + console.log('video getTrackDescription fail'); + } + }).catch((error) => { + console.info(`video catchCallback, error:${error}`); + }); + end = Date.now(); + console.info(`getTrackDescriptionTimeWithoutCallback end time is : ${end}`) + let execution = parseInt(end - start) + console.info("getTrackDescriptionTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('getTrackDescriptionTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("getTrackDescriptionTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function getTrackDescriptionTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + getTrackDescriptionTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +function getTrackDescriptionTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + let arrayDescription; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('getTrackDescriptionTimeCallback play state is INITIALIZED') + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('getTrackDescriptionTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('getTrackDescriptionTimeCallback avPlayer state is prepared') + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('getTrackDescriptionTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + start = Date.now(); + console.info(`getTrackDescriptionTimeCallback start time is : ${start}`) + if(loopTime == 10){ + avPlayer.release().then(() => { + console.info('getTrackDescriptionTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + let avg = totalTime/10; + console.info("getTrackDescriptionTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + loopTime++; + avPlayer.getTrackDescription().then((arrList) => { + if (arrList != null) { + arrayDescription = arrList; + end = Date.now(); + console.info(`getTrackDescriptionTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("getTrackDescriptionTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + + } else { + console.log('video getTrackDescription fail'); + } + }).catch((error) => { + console.info(`video catchCallback, error:${error}`); + }); + avPlayer.pause() + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('getTrackDescriptionTimeCallback play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + avPlayer.play().then(() => { + console.info('getTrackDescriptionTimeCallback avPlayer from pause to play') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); +} + +export async function setSpeedTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('setSpeedTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('setSpeedTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let start = Date.now(); + console.info(`setSpeedTimeWithoutCallback start time is : ${start}`) + await avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X); + let end = Date.now(); + console.info(`setSpeedTimeWithoutCallback end time is : ${end}`) + let execution = parseInt(end - start) + console.info("setSpeedTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('setSpeedTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("setSpeedTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function setSpeedTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + setSpeedTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +function setSpeedTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('setSpeedTimeCallback play state is INITIALIZED') + // step 1: initialized -> prepared + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('setSpeedTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('setSpeedTimeCallback avPlayer state is prepared') + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('setSpeedTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + if(loopTime == 10){ + avPlayer.release().then(() => { + offCallback(avPlayer, ['stateChange', 'error']); + console.info('setSpeedTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + let avg = totalTime/10; + console.info("setSpeedTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + start = Date.now(); + console.info(`setSpeedTimeCallback start time is : ${start}`) + loopTime++ + avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X); + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('setSpeedTimeCallback play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + avPlayer.play().then(() => { + console.info('setSpeedTimeCallback avPlayer from pause to play') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('speedDone', (speed) => { + end = Date.now(); + console.info(`setSpeedTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("setSpeedTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + console.info('speedDone success,and speed value is:' + speed) + avPlayer.pause() + }); +} + +export async function setBitrateTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('setBitrateTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('setBitrateTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let start = Date.now(); + console.info(`setBitrateTimeWithoutCallback start time is : ${start}`) + let bitrate = 96000 + await avPlayer.setBitrate(bitrate) + let end = Date.now(); + console.info(`setBitrateTimeWithoutCallback end time is : ${end}`) + let execution = parseInt(end - start) + console.info("setBitrateTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('setBitrateTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("setBitrateTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function setBitrateTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + playTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +function setBitrateTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('setBitrateTimeCallback play state is INITIALIZED') + // step 1: initialized -> prepared + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('setBitrateTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('setBitrateTimeCallback avPlayer state is prepared') + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('setBitrateTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + if(loopTime == 10){ + avPlayer.release().then(() => { + offCallback(avPlayer, ['stateChange', 'error']); + console.info('setBitrateTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + let avg = totalTime/10; + console.info("setBitrateTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + start = Date.now(); + console.info(`setBitrateTimeCallback start time is : ${start}`) + loopTime++ + let bitrate = 96000 + avPlayer.setBitrate(bitrate) + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('setBitrateTimeCallback play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + avPlayer.play().then(() => { + console.info('setBitrateTimeCallback avPlayer from pause to play') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('bitrateDone', (bitrate) => { + end = Date.now(); + console.info(`setBitrateTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("setBitrateTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + console.info('bitrate success,and speed value is:' + bitrate) + avPlayer.pause() + }); +} + +export async function setVolumeTimeWithoutCallback(src, avPlayer, done) { + let totalTime = 0; + let surfaceID = globalThis.value; + for(var i = 0;i < 10;i++){ + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('setVolumeTimeWithoutCallback setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('setVolumeTimeWithoutCallback avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let start = Date.now(); + console.info(`setVolumeTimeWithoutCallback start time is : ${start}`) + let volume = 1.0 + avPlayer.setVolume(volume) + let end = Date.now(); + console.info(`setVolumeTimeWithoutCallback end time is : ${end}`) + let execution = parseInt(end - start) + console.info("setVolumeTimeWithoutCallback execution time is :" + execution) + totalTime = totalTime + execution; + await avPlayer.release().then(() => { + console.info('setVolumeTimeWithoutCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + let avg = totalTime/10; + console.info("setVolumeTimeWithoutCallback avg time is :" + avg) + done(); +} + +export async function setVolumeTimeWithCallback(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + playTimeCallback(avPlayer, done) + await setSource(avPlayer, src); +} + +function setVolumeTimeCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let start; + let end; + let execution; + let loopTime = 0; + let totalTime = 0; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('setVolumeTimeCallback play state is INITIALIZED') + // step 1: initialized -> prepared + avPlayer.prepare((err) => { + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('setVolumeTimeCallback play state is prepared') + } + }); + await sleep(2000); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('setVolumeTimeCallback avPlayer state is prepared') + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('setVolumeTimeCallback play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + if(loopTime == 10){ + avPlayer.release().then(() => { + offCallback(avPlayer, ['stateChange', 'error']); + console.info('setVolumeTimeCallback avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + let avg = totalTime/10; + console.info("setVolumeTimeCallback avg time is :" + avg) + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }else{ + start = Date.now(); + console.info(`setVolumeTimeCallback start time is : ${start}`) + loopTime++ + let volume = 1.0 + avPlayer.setVolume(volume) + } + break; + case AV_PLAYER_STATE.PAUSED: + console.info('setVolumeTimeCallback play state is PAUSED') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED); + avPlayer.play().then(() => { + console.info('setVolumeTimeCallback avPlayer from pause to play') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('volumeChange', (vol) => { + end = Date.now(); + console.info(`setVolumeTimeCallback end time is : ${end}`) + execution = parseInt(end - start) + console.info("setVolumeTimeCallback execution time is :" + execution) + totalTime = totalTime + execution; + console.info('volumeChange success,and new volume is :' + vol) + avPlayer.pause() + }); +} + +export async function firstFrameTime(src, avPlayer, done) { + let surfaceID = globalThis.value; + let start; + avPlayer = await idle(src, avPlayer) + await setSource(avPlayer, src); + console.info('firstFrameTime setSource'); + await sleep(20) + avPlayer.surfaceId = surfaceID; + await avPlayer.prepare().then(() => { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + console.info('firstFrameTime avPlayer state is prepared') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await avPlayer.on('startRenderFrame', () => { + console.info('startRenderFrame success') + let end = Date.now(); + console.info(`firstFrameTime end time is : ${end}`) + let execution = parseInt(end - start) + console.info("firstFrameTime execution time is :" + execution) + sleep(100) + avPlayer.release().then(() => { + offCallback(avPlayer, ['stateChange','startRenderFrame']); + console.info('firstFrameTime avPlayer is release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + avPlayer = null; + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }) + start = Date.now(); + console.info(`firstFrameTime start time is : ${start}`) + await avPlayer.play().then(() => { + console.info('firstFrameTime play success'); + }, (err) => { + console.error('firstFrameTime play filed,error message is :' + err.message) + }) +} + +export async function avPlayerWithoutCallBack(src, avPlayer, done) { + let surfaceID = globalThis.value; + console.info(`case avPlayerWithoutCallBack Initialized in, surfaceID is ${surfaceID}`); + avPlayer = await idle(src, avPlayer) + setSource(avPlayer, src); + console.info('avPlayerWithoutCallBack setSource'); + if(avPlayer.state == AV_PLAYER_STATE.INITIALIZED) { + avPlayer.surfaceId = surfaceID; + preparePromise(avPlayer); + await sleep(2000); + } + if(avPlayer.state == AV_PLAYER_STATE.PREPARED){ + console.info('avPlayerWithoutCallBack avPlayer from PREPARED to play') + // play to pause loop 1000 times + for(var i = 0;i < 1000; i++){ + await playToPauseLoop(avPlayer) + console.info(`case avPlayerWithoutCallBack playToPauseLoop is ${i}`); + } + } + await avPlayer.stop().then(() => { + console.info('avPlayerWithoutCallBack avPlayer from play to stop') + avPlayer.release().then(() => { + console.info('avPlayerWithoutCallBack avPlayer from stop to release') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); +} + +function setAVPlayerPlay(src, avPlayer, done) { + let surfaceID = globalThis.value; + console.info(`case setAVPlayerPlay in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + console.info(`case state is ${state}`); + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + avPlayer.surfaceId = surfaceID; + console.info('setAVPlayerPlay play state is INITIALIZED') + // step 1: initialized -> prepared -> play + preparePromise(avPlayer) + await sleep(3000); + avPlayer.play() + break; + case AV_PLAYER_STATE.PLAYING: + console.info('setAVPlayerPlay play state is PLAYING') + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + break; + case AV_PLAYER_STATE.COMPLETED: + expect(avPlayer.currentTime).assertEqual(avPlayer.duration); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.COMPLETED); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case AV_PLAYER_STATE.RELEASED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + offCallback(avPlayer, ['stateChange', 'error']); + avPlayer = null; + done(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('error', async (err) => { + console.error(`case error called, errMessage is ${err.message}`); + expect().assertFail(); + await avPlayer.release().then(() => { + avPlayer = null; + done(); + }); + }); +} + +export async function avPlayerPlay(src, avPlayer, done) { + avPlayer = await idle(src, avPlayer) + setAVPlayerPlay(src, avPlayer, done); + await setSource(avPlayer, src); +} + +export async function testAVPlayerFun(src, avPlayer, playTest, playTime, done) { + console.info(`case media source: ${src}`) + await media.createAVPlayer().then((video) => { + if (typeof(video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + } else { + console.error('case createAVPlayer failed'); + expect().assertFail(); + done(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + setAVPlayerFunCb(src, avPlayer, playTest, playTime, done); + setSource(avPlayer, src); +} + +export function setAVPlayerSeekCb(src, avPlayer, playTest, playTime, done) { + let volumeCnt = [0]; + let endOfStreamCnt = 0; + let seekDoneCnt = 0; + let speedDoneCnt = [0]; + let playCnt = 0; + let surfaceID = globalThis.value; + console.info(`case setCallback in, surfaceID is ${surfaceID}`); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + if (reason == media.StateChangeReason.BACKGROUND) { + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + avPlayer.surfaceId = surfaceID; + console.info('case initialized -> prepared'); + // step 1,10: initialized -> prepared + avPlayer.prepare((err) => { + avPlayer.loop = true; + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + checkPlayTest(avPlayer, playTest); + } + }); + break; + case AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + checkPlayTest(avPlayer, playTest); + expect(avPlayer.currentTime).assertEqual(0); + offCallback(avPlayer, ['volumeChange']); + // step 2,11: prepared -> seek 0 + avPlayer.seek(0, 2); // 2: CLOSEST SYNC + break; + case AV_PLAYER_STATE.PLAYING: + playCnt++; + if (playCnt == 1) { + // step 4: seek + pause + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); + avPlayer.seek(avPlayer.duration / 2, media.SeekMode.SEEK_PREV_SYNC); + // avPlayer.pause(); + avPlayer.pause((err) => { + if (err != null) { + mediaTestBase.assertErr('pause', err, done); + } + }); + } else if (playCnt == 3) { + // step 12: seek duration + avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_PREV_SYNC); + avPlayer.stop((err) => { + if (err == null) { + avPlayer.release((err) => { + if (err != null) { + mediaTestBase.assertErr('release', err, done); + } + }) + } else { + mediaTestBase.assertErr('stop', err, done); + } + }); + } + break; + case AV_PLAYER_STATE.RELEASED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); + // step 18: release -> done + avPlayer = null; + expect(volumeCnt[0]).assertEqual(0); + expect(endOfStreamCnt).assertLarger(0); + done(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + + avPlayer.on('endOfStream', () => { + console.info(`case endOfStream called`); + endOfStreamCnt++; + // step 9: seek + reset + avPlayer.seek(avPlayer.duration / 2, 3); // 3: CLOSEST + avPlayer.reset((err) => { + if (err == null) { + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.IDLE); + console.info('case reset success!!'); + setSource(avPlayer, src); + } else { + mediaTestBase.assertErr('reset', err, done); + } + }); + }); + avPlayer.on('seekDone', async (seekDoneTime) => { + seekDoneCnt++; + console.info(`case seekDone called, seekDoneCnt is ${seekDoneCnt}, seekDoneTime is ${seekDoneTime}`); + switch (seekDoneCnt) { + case 1: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED); + // step 3: seek(prepared) -> play + avPlayer.play((err) => { + if (err != null) { + mediaTestBase.assertErr('play', err, done); + } + }); + break; + case 2: + // step 5: seek + play + avPlayer.seek(avPlayer.duration / 2, media.SeekMode.SEEK_NEXT_SYNC); + avPlayer.play(); + break; + case 3: + // step 6: seek + setVolume + avPlayer.setVolume(0.5); + avPlayer.seek(avPlayer.duration / 2, media.SeekMode.SEEK_CLOSEST_SYNC); + avPlayer.play(); + break; + case 4: + // step 7: seek + seek + avPlayer.seek(avPlayer.duration / 2); + avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC); + avPlayer.play(); + break; + case 5: + // step 8: seek duration + avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_PREV_SYNC); + break; + default: + avPlayer.play(); + break; + } + }); + setCallback(avPlayer, 'volumeChange', volumeCnt); + setCallback(avPlayer, 'speedDone', speedDoneCnt); + setCallback(avPlayer, 'bitrateDone', null); + setCallback(avPlayer, 'timeUpdate', null); + setCallback(avPlayer, 'bufferingUpdate', null); + setCallback(avPlayer, 'durationUpdate', null); + setCallback(avPlayer, 'startRenderFrame', null); + setCallback(avPlayer, 'videoSizeChange', null); + setCallback(avPlayer, 'audioInterrupt', null); + setCallback(avPlayer, 'availableBitrates', null); + avPlayer.on('error', async (err) => { + console.error(`case error called, errMessage is ${err.message}`); + }); +} + +export async function testAVPlayerSeek(src, avPlayer, playTest, playTime, done) { + console.info(`case media source: ${src}`) + media.createAVPlayer((err, video) => { + console.info(`case media err: ${err}`) + if (typeof(video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + setAVPlayerSeekCb(src, avPlayer, playTest, playTime, done); + setSource(avPlayer, src); + } + if (err != null) { + console.error(`case createAVPlayer error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } + }); +} diff --git a/multimedia/media/media_js_standard/avPlayer/AppScope/app.json b/multimedia/media/media_js_standard/avPlayer/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..f2ea03357b6a08a0b611933b280b8e6ee5a2f4c7 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"ohos.acts.multimedia.avplayer", + "vendor":"huawei", + "versionCode":1000000, + "versionName":"1.0.0", + "debug":false, + "icon":"$media:icon", + "label":"$string:app_name", + "description":"$string:description_application", + "distributedNotificationEnabled":true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":8, + "targetAPIVersion":8, + "car":{ + "apiCompatibleVersion":8, + "singleUser":false + } + } +} diff --git a/multimedia/media/media_js_standard/avPlayer/AppScope/resources/base/element/string.json b/multimedia/media/media_js_standard/avPlayer/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/AppScope/resources/base/media/app_icon.png b/multimedia/media/media_js_standard/avPlayer/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/multimedia/media/media_js_standard/avPlayer/AppScope/resources/base/media/app_icon.png differ diff --git a/multimedia/media/media_js_standard/avPlayer/BUILD.gn b/multimedia/media/media_js_standard/avPlayer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c74a600ea7238c8e7af7623e81cfdf21555520a9 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/BUILD.gn @@ -0,0 +1,43 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("avplayer_js_hap") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ActsAVPlayerTest_js_assets", + ":ActsAVPlayerTest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAVPlayerTest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("ActsAVPlayerTest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ActsAVPlayerTest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("ActsAVPlayerTest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":ActsAVPlayerTest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/multimedia/media/media_js_standard/avPlayer/Test.json b/multimedia/media/media_js_standard/avPlayer/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..7d452df46b09bc0a02817ff377c07e45d33cc298 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/Test.json @@ -0,0 +1,88 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.avplayer", + "module-name": "phone", + "shell-timeout": "5000000", + "testcase-timeout": 800000 + }, + "kits": [ + { + "test-file-name": [ + "ActsAVPlayerTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test", + "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files", + "chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAVPlayerTest.hap->/data/test/ActsAVPlayerTest.hap", + "./resource/audio/H264_AAC.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mp4/h264_mp3_128x96_30r.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/h263_aac.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/h263_mp3.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2_AAC.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2_MP3.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/h264_1280x720_30.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/H263.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mpeg_ts/h264_aac_480p_25r.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mpeg_ts/h264_mp3_480p_25r.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/H263_AAC.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/H263_MP3.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mpeg_ts/mpeg2_aac_720p_30r.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mpeg_ts/mpeg2_mp3_480p_25r.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mpeg_ts/mpeg4_aac_720p_30r.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mpeg_ts/mpeg4_mp3_480p_25r.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/h264_320x240_60.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/h263_1408x1152_30.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/mpeg4_320x240_60.ts -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/webm/vp8_vorbis_480p_25r.webm -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/vp8_720x480_60.webm -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/H264_AAC.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/H264_MP3.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mkv/h263_aac_640x480_30r.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mkv/h263_mp3_176x144_25r.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2_AAC.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2_MP3.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/videoplayer/mkv/mpeg4_aac_720p_30r.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG4_MP3.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/h264_320x240_30.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/h263_1408x1152_60.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/MPEG2.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/mpeg4_320x240_60.mkv -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AAC_48000_32_1.aac -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/audio/01.mp3 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/audio/56.m4a -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/OGG_48000_1.ogg -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/vorbis_48000_32_1.wav -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/audioplayer/flac/flac_48ksr_16kbr_1ch.flac -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/hevc_320x240_60.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/H264_MP3_1s.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/", + "./resource/media/AVPlayer/h264_aac_3840_2160.mp4 -> /data/app/el2/100/base/ohos.acts.multimedia.avplayer/haps/phone/files/" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap", + "scanner", + "param set persist.ace.testmode.enabled 1", + "setenforce 0" + ] + } + ] +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f88567ba87bf100b2d5227c15ff4987484074c6 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * 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 AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..f38c165f135a4d9b2077da44b8c11a03adc01dd8 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,52 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.context = this.context; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ac93347da054844963bd54fc81ac249164d183d --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,51 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from "../../../test/List.test.ets" + +var mXComponentController: XComponentController = new XComponentController() +var surfaceId: any + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!"); + } + build() { + Flex() { + XComponent({ + id: 'xcomponent', + type: 'surface', + libraryname: '', + controller: mXComponentController + }) + .onLoad(() => { + console.info('CameraModuleTest: OnLoad() is called!') + mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 1920, surfaceHeight: 1080 }); + surfaceId = mXComponentController.getXComponentSurfaceId() + globalThis.value = surfaceId + console.info('CameraModuleTest: XComponent onLoad surfaceId: ' + globalThis.value) + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }) + .width('1920px') + .height('1080px') + } + } +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/second/second.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..89a84730505783ba229175ab4b55d37f91a16266 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.application.Ability' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ef52ba7e49117cebef7a7b9ff64c4c63399acfe --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ohos.acts.multimedia.avplayer.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ca6cb1b7ccbbc94fdc5a9521cc6c0a4b592e0f8f --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js @@ -0,0 +1,227 @@ +/* + * 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'; +import * as AVPlayerTestBase from '../../../../../../AVPlayerTestBase.js'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function AVPlayerHlsFuncTest() { + describe('AVPlayerHlsFuncTest', function () { + const HTTP_PATH = 'http://xxx.xx.xx.xx:xxxx/'; + const PLAY_TIME = 3000; + let avPlayer = null; + let expectBitrateArray = []; + let videoSizeArray = []; + let videoSizeId = -1; + let bitrateArray = []; + let setBitrateState = ''; + let surfaceID = globalThis.value; + beforeAll(async function() { + console.info('beforeAll case'); + }) + + beforeEach(async function() { + console.info('beforeEach case'); + }) + + afterEach(async function() { + console.info('afterEach case'); + }) + + afterAll(async function() { + console.info('afterAll case'); + if (avPlayer != null) { + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + }) + + function checkArray(realArray, expectArray) { + expect(realArray.length).assertEqual(expectArray.length); + for (let i = 0; i < expectArray.length; i++) { + console.info('case expect ' + expectArray[i]); + expect(realArray[i]).assertEqual(expectArray[i]); + } + } + + async function initAVPlayer(src, done) { + let availableBitratesCnt = 0; + let bitrateDoneCnt = 0; + await media.createAVPlayer().then((video) => { + if (typeof (video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + } else { + console.error('case createAVPlayer failed'); + expect().assertFail(); + done(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + avPlayer.on('stateChange', async (state, reason) => { + console.info(`case stateChange called, state is ${state}, reason is ${reason}`); + if (reason == media.StateChangeReason.BACKGROUND && state != AVPlayerTestBase.AV_PLAYER_STATE.COMPLETED) { + console.info(`case media.StateChangeReason.BACKGROUND`); + await avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + console.info(`case state is ${state}`); + if (setBitrateState == state) { + avPlayer.setBitrate(expectBitrateArray[videoSizeId]); + } + switch (state) { + case AVPlayerTestBase.AV_PLAYER_STATE.IDLE: + break; + case AVPlayerTestBase.AV_PLAYER_STATE.INITIALIZED: + console.info(`case AVPlayerTestBase.AV_PLAYER_STATE.INITIALIZED`); + expect(avPlayer.state).assertEqual(AVPlayerTestBase.AV_PLAYER_STATE.INITIALIZED); + avPlayer.surfaceId = surfaceID; + avPlayer.prepare().then(() => { + console.info('case prepare called'); + expect(avPlayer.state).assertEqual(AVPlayerTestBase.AV_PLAYER_STATE.PREPARED); + expect(avPlayer.currentTime).assertEqual(0); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case AVPlayerTestBase.AV_PLAYER_STATE.PREPARED: + expect(avPlayer.state).assertEqual(AVPlayerTestBase.AV_PLAYER_STATE.PREPARED); + expect(avPlayer.currentTime).assertEqual(0) + avPlayer.loop = true; + avPlayer.play(); + break; + case AVPlayerTestBase.AV_PLAYER_STATE.PAUSED: + avPlayer.play(); + break; + case AVPlayerTestBase.AV_PLAYER_STATE.COMPLETED: + avPlayer.play(); + break; + case AVPlayerTestBase.AV_PLAYER_STATE.RELEASED: + expect(availableBitratesCnt).assertLarger(0); + avPlayer = null; + done(); + break; + case AVPlayerTestBase.AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }); + avPlayer.on('bitrateDone', (bitrate) => { + console.info(`case bitrateDone called, bitrate is ${bitrate}`); + expect(bitrate).assertEqual(expectBitrateArray[videoSizeId]); + bitrateDoneCnt++; + }); + avPlayer.on('videoSizeChange', (w, h) => { + console.info('case videoSizeChange width: ' + w + ' height: ' + h + 'videoSizeId: ' + videoSizeId); + if (w == videoSizeArray[videoSizeId][0] && h == videoSizeArray[videoSizeId][1]) { + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + }); + avPlayer.on('availableBitrates', (bitrates) => { + bitrateArray = bitrates; + checkArray(bitrateArray, expectBitrateArray); + availableBitratesCnt++; + }); + console.info(`case src is ${src}`); + avPlayer.url = src; + } + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0100 + * @tc.name : 001.test hls + * @tc.desc : HLS setBitrate test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0100', 0, async function (done) { + await initAVPlayer(HTTP_PATH + '05.hls/hls_variant/index.m3u8', done); + expectBitrateArray = [165340, 344388, 387360, 765178, 1676816]; + setBitrateState = AVPlayerTestBase.AV_PLAYER_STATE.PREPARED; + videoSizeId = 1; + videoSizeArray = [ [256, 144], [426, 240], [640, 360], [854, 480], [1280, 720] ]; + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0200 + * @tc.name : 001.test hls + * @tc.desc : HLS setBitrate test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0200', 0, async function (done) { + await initAVPlayer(HTTP_PATH + '05.hls/hls_variant/index.m3u8', done); + expectBitrateArray = [165340, 344388, 387360, 765178, 1676816]; + setBitrateState = AVPlayerTestBase.AV_PLAYER_STATE.PLAYING; + videoSizeId = 1; + videoSizeArray = [ [256, 144], [426, 240], [640, 360], [854, 480], [1280, 720] ]; + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0300 + * @tc.name : 001.test hls + * @tc.desc : HLS setBitrate test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0300', 0, async function (done) { + await initAVPlayer(HTTP_PATH + '05.hls/hls_variant/index.m3u8', done); + expectBitrateArray = [165340, 344388, 387360, 765178, 1676816]; + setBitrateState = AVPlayerTestBase.AV_PLAYER_STATE.PAUSED; + videoSizeId = 1; + videoSizeArray = [ [256, 144], [426, 240], [640, 360], [854, 480], [1280, 720] ]; + await mediaTestBase.msleepAsync(PLAY_TIME); + avPlayer.pause(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0400 + * @tc.name : 001.test hls + * @tc.desc : HLS setBitrate test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0400', 0, async function (done) { + await initAVPlayer(HTTP_PATH + '05.hls/hls_variant/index.m3u8', done); + expectBitrateArray = [165340, 344388, 387360, 765178, 1676816]; + setBitrateState = AVPlayerTestBase.AV_PLAYER_STATE.COMPLETED; + videoSizeId = 1; + videoSizeArray = [ [256, 144], [426, 240], [640, 360], [854, 480], [1280, 720] ]; + await mediaTestBase.msleepAsync(PLAY_TIME); + avPlayer.loop = false; + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0500 + * @tc.name : 001.test hls + * @tc.desc : HLS setBitrate test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HLS_setBitrate_0500', 0, async function (done) { + await initAVPlayer(HTTP_PATH + '05.hls/hls_variant/index.m3u8', done); + expectBitrateArray = [165340, 344388, 387360, 765178, 1676816]; + setBitrateState = AVPlayerTestBase.AV_PLAYER_STATE.PREPARED; + videoSizeId = 3; + videoSizeArray = [ [256, 144], [426, 240], [640, 360], [854, 480], [1280, 720] ]; + }) + }); +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..65d3b573c6766d94cae3a8cdbc174b33ef94f4ee --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets @@ -0,0 +1,124 @@ +/* + * 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 {testAVPlayerFun} from '../../../../../../AVPlayerTestBase.js'; +import * as mediaTestBase from '../../../../../../MediaTestBase'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function AVPlayerHttpCompatibilityTest() { + describe('AVPlayerHttpCompatibilityTest', function () { + const HTTP_PATH = 'http://xxx.xx.xx.xx:xxxx/'; + const VIDEO_PATH = HTTP_PATH + '01.video/'; + const AUDIO_PATH = HTTP_PATH + '02.audio/'; + const VIDEOPLAYER_PATH = HTTP_PATH + '03.videoplayer/'; + const AUDIOPLAYER_PATH = HTTP_PATH + '04.audioplayer/'; + const PLAY_TIME = 3000; + let avPlayer = null; + let avPlayTest = { + width: 0, + height: 0, + duration: -1, + } + beforeAll(async function() { + console.info('beforeAll case'); + }) + + beforeEach(async function() { + console.info('beforeEach case'); + }) + + afterEach(async function() { + console.info('afterEach case'); + }) + + afterAll(async function() { + console.info('afterAll case'); + if (avPlayer != null) { + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_MP4_0100 + * @tc.name : 001.H264_AAC + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_MP4_0100', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mp4/h264_aac_640x320_30r.mp4'; + avPlayTest = { width: 640, height: 320, duration: 10100 }; + testAVPlayerFun(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_MP4_0200 + * @tc.name : 002.H264_MP3 + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_MP4_0200', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mp4/h264_mp3_640x480_25r.mp4'; + avPlayTest = { width: 640, height: 480, duration: 10080 }; + testAVPlayerFun(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_TS_0100 + * @tc.name : 001.H264_AAC + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_TS_0100', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mpeg_ts/h264_aac_640x480_30r.ts'; + avPlayTest = { width: 640, height: 480, duration: 10161 }; + testAVPlayerFun(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_TS_0200 + * @tc.name : 002.H264_MP3 + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_TS_0200', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mpeg_ts/h264_mp3_640x480_25r.ts'; + avPlayTest = { width: 640, height: 480, duration: 10169 }; + testAVPlayerFun(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_MKV_0100 + * @tc.name : 001.H264_AAC + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_FORMAT_MKV_0100', 0, async function (done) { + let path = VIDEO_PATH + 'H264_AAC.mkv'; + avPlayTest = { width: 720, height: 480, duration: 10057 }; + testAVPlayerFun(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + }); +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6dbf9008a08db781c8083597d6247bc7c45c3c79 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets @@ -0,0 +1,124 @@ +/* + * 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 {testAVPlayerSeek} from '../../../../../../AVPlayerTestBase.js'; +import * as mediaTestBase from '../../../../../../MediaTestBase'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function AVPlayerHttpSeekTest() { + describe('AVPlayerHttpSeekTest', function () { + const HTTP_PATH = 'http://xxx.xx.xx.xx:xxxx/'; + const VIDEO_PATH = HTTP_PATH + '01.video/'; + const AUDIO_PATH = HTTP_PATH + '02.audio/'; + const VIDEOPLAYER_PATH = HTTP_PATH + '03.videoplayer/'; + const AUDIOPLAYER_PATH = HTTP_PATH + '04.audioplayer/'; + const PLAY_TIME = 3000; + let avPlayer = null; + let avPlayTest = { + width: 0, + height: 0, + duration: -1, + } + beforeAll(async function() { + console.info('beforeAll case'); + }) + + beforeEach(async function() { + console.info('beforeEach case'); + }) + + afterEach(async function() { + console.info('afterEach case'); + }) + + afterAll(async function() { + console.info('afterAll case'); + if (avPlayer != null) { + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_MP4_0100 + * @tc.name : 001.H264_AAC + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_MP4_0100', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mp4/h264_aac_640x320_30r.mp4'; + avPlayTest = { width: 640, height: 320, duration: 10100 }; + testAVPlayerSeek(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_MP4_0200 + * @tc.name : 002.H264_MP3 + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_MP4_0200', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mp4/h264_mp3_640x480_25r.mp4'; + avPlayTest = { width: 640, height: 480, duration: 10080 }; + testAVPlayerSeek(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_TS_0100 + * @tc.name : 001.H264_AAC + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_TS_0100', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mpeg_ts/h264_aac_640x480_30r.ts'; + avPlayTest = { width: 640, height: 480, duration: 10161 }; + testAVPlayerSeek(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_TS_0200 + * @tc.name : 002.H264_MP3 + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_TS_0200', 0, async function (done) { + let path = VIDEOPLAYER_PATH + 'mpeg_ts/h264_mp3_640x480_25r.ts'; + avPlayTest = { width: 640, height: 480, duration: 10169 }; + testAVPlayerSeek(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_MKV_0100 + * @tc.name : 001.H264_AAC + * @tc.desc : Http playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_HTTP_SEEK_FORMAT_MKV_0100', 0, async function (done) { + let path = VIDEO_PATH + 'H264_AAC.mkv'; + avPlayTest = { width: 720, height: 480, duration: 10057 }; + testAVPlayerSeek(path, avPlayer, avPlayTest, PLAY_TIME, done); + }) + }); +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8ec9d5634e9a81d5665da1af4f833667c8a773cb --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js @@ -0,0 +1,548 @@ +/* + * 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 * as mediaTestBase from '../../../../../../MediaTestBase'; +import media from '@ohos.multimedia.media' +import audio from '@ohos.multimedia.audio'; +import { testAVPlayerFun, AV_PLAYER_STATE, setSource } from '../../../../../../AVPlayerTestBase.js'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function AVPlayerLocalTest() { + describe('AVPlayerLocalTest', function () { + const VIDEO_SOURCE = 'H264_AAC.mp4'; + const AUDIO_SOURCE = '01.mp3'; + const VIDEO_NOAUDIO = 'H264_NONE.mp4' + const PLAY_TIME = 3000; + const TAG = 'AVPlayerLocalTest:'; + let fileDescriptor = null; + let fileDescriptor2 = null; + let fileDescriptor3 = null; + let avPlayer = null; + let avPlayTest = { + width: 0, + height: 0, + duration: -1, + } + let fdPath = ''; + let fdNumber = 0; + + beforeAll(async function() { + console.info('beforeAll case'); + await mediaTestBase.getStageFileDescriptor(VIDEO_SOURCE).then((res) => { + fileDescriptor = res; + }); + await mediaTestBase.getStageFileDescriptor(AUDIO_SOURCE).then((res) => { + fileDescriptor2 = res; + }); + await mediaTestBase.getStageFileDescriptor(VIDEO_NOAUDIO).then((res) => { + fileDescriptor3 = res; + }); + }) + + beforeEach(async function() { + console.info('beforeEach case'); + }) + + afterEach(async function() { + if (avPlayer != null) { + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + console.info('afterEach case'); + }) + + afterAll(async function() { + console.info('afterAll case'); + await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE); + await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE); + await mediaTestBase.closeFileDescriptor(VIDEO_NOAUDIO); + }) + + function setAVPlayerTrackCb(avPlayer, descriptionKey, descriptionValue, done) { + let arrayDescription; + let surfaceID = globalThis.value; + avPlayer.on('stateChange', async (state, reason) => { + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + console.info(`case AV_PLAYER_STATE.INITIALIZED`); + avPlayer.surfaceId = surfaceID; + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + avPlayer.prepare((err) => { + console.info('case prepare called' + err); + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + avPlayer.duration); + } + }); + break; + case AV_PLAYER_STATE.PREPARED: + await avPlayer.getTrackDescription().then((arrayList) => { + console.info('case getTrackDescription called!!'); + if (typeof (arrayList) != 'undefined') { + arrayDescription = arrayList; + } else { + console.info('case getTrackDescription is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + expect(descriptionKey.length).assertEqual(arrayDescription.length); + for (let i = 0; i < arrayDescription.length; i++) { + mediaTestBase.checkDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]); + } + avPlayer.getTrackDescription((error, arrayList) => { + if (error == null) { + for (let i = 0; i < arrayList.length; i++) { + mediaTestBase.checkDescription(arrayList[i], descriptionKey[i], descriptionValue[i]); + } + } else { + console.info('getTrackDescription failed, message is:' + error.message); + } + avPlayer.release(); + }) + break; + case AV_PLAYER_STATE.RELEASED: + avPlayer = null; + done(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + avPlayer = null; + break; + default: + break; + } + }) + } + + async function testCheckTrackDescription(src, avPlayer, descriptionKey, descriptionValue, done) { + console.info(`case media source: ${src}`) + media.createAVPlayer((err, video) => { + console.info(`case media err: ${err}`) + if (typeof (video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + setAVPlayerTrackCb(avPlayer, descriptionKey, descriptionValue, done) + setSource(avPlayer, src); + } + if (err != null) { + console.error(`case createAVPlayer error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } + }); + } + + async function setAVPlayerScaleCb(avPlayer, done) { + let surfaceID = globalThis.value; + let count = 0; + avPlayer.on('stateChange', async (state, reason) => { + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + console.info(`case AV_PLAYER_STATE.INITIALIZED`); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + avPlayer.surfaceId = surfaceID; + avPlayer.prepare((err) => { + console.info('case prepare called' + err); + avPlayer.loop = true; + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + avPlayer.duration); + } + }); + break; + case AV_PLAYER_STATE.PREPARED: + console.info('case prepare called'); + avPlayer.play((err) => { + console.info('case play called' + err); + if (err != null) { + console.error(`case play error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + avPlayer.duration); + } + }); + break; + case AV_PLAYER_STATE.PLAYING: + console.info('case playing called'); + for (let i = 0; i < 20; i++) { + if (count == 0) { + console.info('case set videoScaleType : 1'); + avPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP; + count = 1; + } else { + console.info('case set videoScaleType : 0'); + avPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT; + count = 0; + } + await mediaTestBase.msleepAsync(500); + } + avPlayer.loop = false; + break; + case AV_PLAYER_STATE.COMPLETED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.COMPLETED); + expect(avPlayer.currentTime).assertEqual(avPlayer.duration); + avPlayer.release(); + break; + case AV_PLAYER_STATE.RELEASED: + avPlayer = null; + done(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + avPlayer = null; + break; + default: + break; + } + }) + } + + async function testVideoScaleType(src, avPlayer, done) { + console.info(`case media source: ${src}`) + media.createAVPlayer((err, video) => { + console.info(`case media err: ${err}`) + if (typeof (video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + setAVPlayerScaleCb(avPlayer, done) + setSource(avPlayer, src); + } + if (err != null) { + console.error(`case createAVPlayer error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } + }); + } + + async function testAudioInterruptMode(audioSource, videoSource, done) { + let testAVPlayer01 = await media.createAVPlayer(); + let testAVPlayer02 = await media.createAVPlayer(); + let surfaceID = globalThis.value; + testAVPlayer01.on('stateChange', async (state, reason) => { + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + console.info(`case AV_PLAYER_STATE.INITIALIZED`); + expect(testAVPlayer01.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + testAVPlayer01.prepare((err) => { + console.info('case prepare called' + err); + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + testAVPlayer01.duration); + } + }); + break; + case AV_PLAYER_STATE.PREPARED: + testAVPlayer01.audioInterruptMode = audio.InterruptMode.INDEPENDENT_MODE; + testAVPlayer01.play(); + break; + case AV_PLAYER_STATE.PLAYING: + testAVPlayer02.fdSrc = videoSource; + break; + case AV_PLAYER_STATE.RELEASED: + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + testAVPlayer01.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }) + + testAVPlayer01.on('audioInterrupt', async (info) => { + console.info('case audioInterrupt1 is called, info is :' + JSON.stringify(info)); + await testAVPlayer02.release(); + await testAVPlayer01.release().then(() => { + console.info('case release called!!'); + done(); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + }); + + testAVPlayer02.on('stateChange', async (state, reason) => { + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + console.info(`case AV_PLAYER_STATE.INITIALIZED`); + expect(testAVPlayer02.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + testAVPlayer02.surfaceId = surfaceID; + testAVPlayer02.prepare((err) => { + console.info('case prepare called' + err); + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + testAVPlayer02.duration); + } + }); + break; + case AV_PLAYER_STATE.PREPARED: + testAVPlayer02.play(); + break; + case AV_PLAYER_STATE.PLAYING: + break; + case AV_PLAYER_STATE.RELEASED: + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + testAVPlayer02.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + default: + break; + } + }) + testAVPlayer01.fdSrc = audioSource; + } + + async function setOnCallback(avPlayer, done) { + let surfaceID = globalThis.value; + let count = 0; + let playCount = 0; + avPlayer.on('endOfStream', () => { + count++; + console.info(TAG + 'endOfStream success') + avPlayer.off('endOfStream') + }) + avPlayer.on('stateChange', async (state, reason) => { + switch (state) { + case AV_PLAYER_STATE.INITIALIZED: + console.info(`case AV_PLAYER_STATE.INITIALIZED`); + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.INITIALIZED); + avPlayer.surfaceId = surfaceID; + avPlayer.prepare((err) => { + console.info('case prepare called' + err); + if (err != null) { + console.error(`case prepare error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + avPlayer.duration); + } + }); + break; + case AV_PLAYER_STATE.PREPARED: + console.info('case prepare called'); + avPlayer.play().then(() => { + console.info('play called success') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case AV_PLAYER_STATE.PLAYING: + if (playCount == 0) { + playCount++; + avPlayer.pause().then(() => { + console.info('play called success') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + console.info('case playing called'); + break; + case AV_PLAYER_STATE.PAUSED: + avPlayer.play((err) => { + console.info('case play called'); + if (err != null) { + console.error(`case play error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } else { + console.info('case avPlayer.duration: ' + avPlayer.duration); + } + }); + console.info('case pause called'); + break; + case AV_PLAYER_STATE.STOPPED: + expect(count).assertEqual(1); + console.info('case stop called'); + avPlayer.release().then(() => { + console.info('play stop success') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + break; + case AV_PLAYER_STATE.COMPLETED: + expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.COMPLETED); + expect(avPlayer.currentTime).assertEqual(avPlayer.duration); + if (playCount == 1) { + playCount++ + avPlayer.play().then(() => { + console.info('play called success') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } else { + avPlayer.stop().then(() => { + console.info('play stop success') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + break; + case AV_PLAYER_STATE.RELEASED: + avPlayer = null; + done(); + break; + case AV_PLAYER_STATE.ERROR: + expect().assertFail(); + avPlayer.release().then(() => { + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + avPlayer = null; + break; + default: + break; + } + }) + } + async function testOffCallback(src, avPlayer, done) { + console.info(`case media source: ${src}`) + media.createAVPlayer((err, video) => { + console.info(`case media err: ${err}`) + if (typeof (video) != 'undefined') { + console.info('case createAVPlayer success'); + avPlayer = video; + setOnCallback(avPlayer, done) + setSource(avPlayer, src); + } + if (err != null) { + console.error(`case createAVPlayer error, errMessage is ${err.message}`); + expect().assertFail(); + done(); + } + }); + } + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_FDSRC_0100 + * @tc.name : 001.test fdsrc + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_FDSRC_0100', 0, async function (done) { + avPlayTest = { width: 720, height: 480, duration: 10100 }; + testAVPlayerFun(fileDescriptor, avPlayer, avPlayTest, PLAY_TIME, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0100 + * @tc.name : 001.test getTrackDescription + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0100', 0, async function (done) { + let videoTrackKey = new Array('bitrate', 'codec_mime', 'frame_rate', 'height', + 'track_index', 'track_type', 'width'); + let audioTrackKey = new Array('bitrate', 'channel_count', 'codec_mime', 'sample_rate', + 'track_index', 'track_type'); + let videoTrackValue = new Array(1366541, 0, 6000, 480, 0, 1, 720); + let audioTrackValue = new Array(129207, 2, 1, 44100, 1, 0); + let descriptionKey = new Array(videoTrackKey, audioTrackKey); + let descriptionValue = new Array(videoTrackValue, audioTrackValue); + testCheckTrackDescription(fileDescriptor, avPlayer, descriptionKey, descriptionValue, done) + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0200 + * @tc.name : 002.test getTrackDescription + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0200', 0, async function (done) { + let audioTrackKey = new Array('channel_count', 'codec_mime', 'sample_rate', 'track_index', + 'track_type'); + let audioTrackValue = new Array(1, 2, 48000, 0, 0); + let descriptionKey = new Array(audioTrackKey); + let descriptionValue = new Array(audioTrackValue); + testCheckTrackDescription(fileDescriptor2, avPlayer, descriptionKey, descriptionValue, done) + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0300 + * @tc.name : 003.test getTrackDescription + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0300', 0, async function (done) { + let videoTrackKey = new Array('bitrate', 'codec_mime', 'frame_rate', 'height', + 'track_index', 'track_type', 'width'); + let videoTrackValue = new Array(1506121, 0, 6000, 480, 0, 1, 720); + let descriptionKey = new Array(videoTrackKey); + let descriptionValue = new Array(videoTrackValue); + testCheckTrackDescription(fileDescriptor3, avPlayer, descriptionKey, descriptionValue, done) + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_VIDEOSCALETYPE_0100 + * @tc.name : 001.test video player videoScaleTpe + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_VIDEOSCALETYPE_0100', 0, async function (done) { + testVideoScaleType(fileDescriptor, avPlayer, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_AUDIOINTERRUPTMODE_0100 + * @tc.name : 001.test audioInterruptMode Function + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_AUDIOINTERRUPTMODE_0100', 0, async function (done) { + testAudioInterruptMode(fileDescriptor2, fileDescriptor, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_AUDIOINTERRUPTMODE_0200 + * @tc.name : 002.test audioInterruptMode Function + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_AUDIOINTERRUPTMODE_0200', 0, async function (done) { + testAudioInterruptMode(fileDescriptor, fileDescriptor2, done); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_OFF_CALLBACK_0100 + * @tc.name : 001.test off callback Function + * @tc.desc : Local Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_OFF_CALLBACK_0100', 0, async function (done) { + testOffCallback(fileDescriptor, avPlayer, done); + }) + }) +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerStabilityTest.test.js b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerStabilityTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d7921c202f34b1ee91920900372716359901ece9 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerStabilityTest.test.js @@ -0,0 +1,1241 @@ +/** + * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 fileio from '@ohos.fileio' +import * as mediaTestBase from '../../../../../../MediaTestBase'; +import * as AVPlayerTestBase from '../../../../../../AVPlayerTestBase.js'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function AVPlayerStabilityTest() { + describe('AVPlayerStabilityTest', function () { + + const VIDEO_SOURCES = [ + 'H264_AAC.mp4', + 'h264_mp3_128x96_30r.mp4', + 'h263_aac.mp4', + 'h263_mp3.mp4', + 'MPEG2_AAC.mp4', + 'MPEG2_MP3.mp4', + 'h264_1280x720_30.mp4', + 'H263.mp4', + 'MPEG2.mp4', + 'h264_aac_480p_25r.ts', + 'h264_mp3_480p_25r.ts', + 'H263_AAC.ts', + 'H263_MP3.ts', + 'mpeg2_aac_720p_30r.ts', + 'mpeg2_mp3_480p_25r.ts', + 'mpeg4_aac_720p_30r.ts', + 'mpeg4_mp3_480p_25r.ts', + 'h264_320x240_60.ts', + 'h263_1408x1152_30.ts', + 'MPEG2.ts', + 'mpeg4_320x240_60.ts', + 'vp8_vorbis_480p_25r.webm', + 'vp8_720x480_60.webm', + 'H264_AAC.mkv', + 'H264_MP3.mkv', + 'h263_aac_640x480_30r.mkv', + 'h263_mp3_176x144_25r.mkv', + 'MPEG2_AAC.mkv', + 'MPEG2_MP3.mkv', + 'mpeg4_aac_720p_30r.mkv', + 'MPEG4_MP3.mkv', + 'h264_320x240_30.mkv', + 'h263_1408x1152_60.mkv', + 'MPEG2.mkv', + 'mpeg4_320x240_60.mkv', + 'AAC_48000_32_1.aac', + '01.mp3', + '56.m4a', + 'OGG_48000_1.ogg', + 'vorbis_48000_32_1.wav', + 'flac_48ksr_16kbr_1ch.flac', + 'hevc_320x240_60.mp4', + 'H264_MP3_1s.mp4', + 'h264_aac_3840_2160.mp4' + ] + let videos = []; + let TAG = "[AVPlayerStabilityTest] "; + let callBackSet = 0; + let avPlayer = null; + let fileDescriptor = null; + let fdHead = 'fd://'; + let fdPath = ''; + let fdNumber = 0; + let fdNumbers = [] + const PLAY_TIME = 2; + + beforeAll(async function () { + console.info('beforeAll case'); + for(var i = 0;i < VIDEO_SOURCES.length; i++){ + await getStageFdRead(VIDEO_SOURCES[i]).then((testNumber) => { + fdNumber = testNumber; + console.info(TAG + 'this fdNumber is :' + fdNumber) + fdPath = fdHead + '' + fdNumber; + fdNumbers.push(fdNumber) + videos.push(fdPath) + }) + } + }) + + async function getStageFdRead(pathName) { + let fdReturn; + let contextStage = globalThis.context; + let fileDir = contextStage.filesDir + console.info("case file dir is" + JSON.stringify(fileDir)); + pathName = fileDir + '/' + pathName; + console.info("case pathName is" + pathName); + await fileio.open(pathName).then((fdNumber) => { + fdReturn = fdNumber; + console.info('[fileio]case open fd success, fd is ' + fdReturn); + }) + return fdReturn; + } + + + beforeEach(async function() { + console.info('beforeEach case'); + await AVPlayerTestBase.sleep(1000); + }) + + afterEach(async function() { + if (avPlayer != null) { + avPlayer.release().then(() => { + console.info(TAG + 'this testCase execution completed') + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + } + console.info('afterEach case'); + await AVPlayerTestBase.sleep(1000); + }) + + afterAll(async function() { + console.info('afterAll case'); + for(var i = 0;i < fdNumbers.length; i++){ + await mediaTestBase.closeFdNumber(fdNumbers[i]); + } + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100 + * @tc.name : 001.test play pause loop 1000 (waiting for callback) + * @tc.desc : Local Video play to pause 1000 times (waiting for callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100 start') + AVPlayerTestBase.avPlayerWithCallBack(videos[0], avPlayer, PLAY_TIME, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200 + * @tc.name : 001.test play pause loop 1000 (do not wait for callback) + * @tc.desc : Local Video play to pause 1000 times (do not wait for callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200 start') + AVPlayerTestBase.avPlayerWithoutCallBack(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0100 + * @tc.name : 001.test play source mp4(H264_AAC) + * @tc.desc : Local Video play source (H264_AAC) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0200 + * @tc.name : 001.test play source (H264_MP3) + * @tc.desc : Local Video play source (H264_MP3) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0200 start') + AVPlayerTestBase.avPlayerPlay(videos[1], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0300 + * @tc.name : 001.test play source mp4 (H263_AAC) + * @tc.desc : Local Video play source (H263_AAC) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0300', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0300 start') + AVPlayerTestBase.avPlayerPlay(videos[2], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0300 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0400 + * @tc.name : 001.test play source (H263_MP3) + * @tc.desc : Local Video play source (H263_MP3) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0400', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0400 start') + AVPlayerTestBase.avPlayerPlay(videos[3], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0400 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500 + * @tc.name : 001.test play source (MPEG2_AAC) + * @tc.desc : Local Video play source (MPEG2_AAC) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500 start') + AVPlayerTestBase.avPlayerPlay(videos[4], avPlayer,done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0600 + * @tc.name : 001.test play source (MPEG2_MP3) + * @tc.desc : Local Video play source (MPEG2_MP3) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0600', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0600 start') + AVPlayerTestBase.avPlayerPlay(videos[5], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0600 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0700 + * @tc.name : 001.test play source (MPEG2_MP3) + * @tc.desc : Local Video play source (MPEG2_MP3) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0700', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0700 start') + AVPlayerTestBase.avPlayerPlay(videos[6], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0700 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0800 + * @tc.name : 001.test play source (h263.mov) + * @tc.desc : Local Video play source (h263.mov) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0800', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0800 start') + AVPlayerTestBase.avPlayerPlay(videos[7], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0800 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0900 + * @tc.name : 001.test play source (mpeg2.mkv) + * @tc.desc : Local Video play source (mpeg2.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0900', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0900 start') + AVPlayerTestBase.avPlayerPlay(videos[8], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0900 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0100 + * @tc.name : 001.test play source (h264_aac.ts) + * @tc.desc : Local Video play source (h264_aac.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[9], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0200 + * @tc.name : 001.test play source (h264_mp3.ts) + * @tc.desc : Local Video play source (h264_mp3.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0200 start') + AVPlayerTestBase.avPlayerPlay(videos[10], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0300 + * @tc.name : 001.test play source (h263_aac.ts) + * @tc.desc : Local Video play source (h263_aac.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0300', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0300 start') + AVPlayerTestBase.avPlayerPlay(videos[11], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0300 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0400 + * @tc.name : 001.test play source (h263_mp3.ts) + * @tc.desc : Local Video play source (h263_mp3.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0400', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0400 start') + AVPlayerTestBase.avPlayerPlay(videos[12], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0400 end') + }) + + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0500 + * @tc.name : 001.test play source (mpeg2_aac.ts) + * @tc.desc : Local Video play source (mpeg2_aac.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0500', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0500 start') + AVPlayerTestBase.avPlayerPlay(videos[13], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0500 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0600 + * @tc.name : 001.test play source (mpeg2_mp3.ts) + * @tc.desc : Local Video play source (mpeg2_mp3.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0600', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0600 start') + AVPlayerTestBase.avPlayerPlay(videos[14], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0600 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0700 + * @tc.name : 001.test play source (mpeg4_aac.ts) + * @tc.desc : Local Video play source (mpeg4_aac.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0700', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0700 start') + AVPlayerTestBase.avPlayerPlay(videos[15], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0700 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0800 + * @tc.name : 001.test play source (mpeg4_mp3.ts) + * @tc.desc : Local Video play source (mpeg4_mp3.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0800', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0800 start') + AVPlayerTestBase.avPlayerPlay(videos[16], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0800 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0900 + * @tc.name : 001.test play source (h264.ts) + * @tc.desc : Local Video play source (h264.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0900', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0900 start') + AVPlayerTestBase.avPlayerPlay(videos[17], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_0900 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1000 + * @tc.name : 001.test play source (h263.ts) + * @tc.desc : Local Video play source (h263.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1000', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1000 start') + AVPlayerTestBase.avPlayerPlay(videos[18], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1000 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1100 + * @tc.name : 001.test play source (mpeg2.ts) + * @tc.desc : Local Video play source (mpeg2.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1100 start') + AVPlayerTestBase.avPlayerPlay(videos[19], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1200 + * @tc.name : 001.test play source (mpeg4.ts) + * @tc.desc : Local Video play source (mpeg4.ts) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1200 start') + AVPlayerTestBase.avPlayerPlay(videos[20], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_TS_1200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0100 + * @tc.name : 001.test play source (vp8_vorbis.webm) + * @tc.desc : Local Video play source (vp8_vorbis.webm) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[21], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0200 + * @tc.name : 001.test play source (vp8.webm) + * @tc.desc : Local Video play source (vp8.webm) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0200 start') + AVPlayerTestBase.avPlayerPlay(videos[22], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WEBM_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0100 + * @tc.name : 001.test play source (H264_AAC.mkv) + * @tc.desc : Local Video play source (H264_AAC.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[23], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0200 + * @tc.name : 001.test play source (H264_MP3.mkv) + * @tc.desc : Local Video play source (H264_MP3.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0200 start') + AVPlayerTestBase.avPlayerPlay(videos[24], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0300 + * @tc.name : 001.test play source (H263_AAC.mkv) + * @tc.desc : Local Video play source (H263_AAC.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0300', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0300 start') + AVPlayerTestBase.avPlayerPlay(videos[25], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0300 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0400 + * @tc.name : 001.test play source (H263_MP3.mkv) + * @tc.desc : Local Video play source (H263_MP3.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0400', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0400 start') + AVPlayerTestBase.avPlayerPlay(videos[26], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0400 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0500 + * @tc.name : 001.test play source (MPEG2_AAC.mkv) + * @tc.desc : Local Video play source (MPEG2_AAC.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0500', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0500 start') + AVPlayerTestBase.avPlayerPlay(videos[27], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0500 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0600 + * @tc.name : 001.test play source (mpeg2_mp3.mkv) + * @tc.desc : Local Video play source (mpeg2_mp3.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0600', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0600 start') + AVPlayerTestBase.avPlayerPlay(videos[28], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0600 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0700 + * @tc.name : 001.test play source (mpeg4_aac.mkv) + * @tc.desc : Local Video play source (mpeg4_aac.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0700', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0700 start') + AVPlayerTestBase.avPlayerPlay(videos[29], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0700 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0800 + * @tc.name : 001.test play source (MPEG4_MP3.mkv) + * @tc.desc : Local Video play source (MPEG4_MP3.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0800', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0800 start') + AVPlayerTestBase.avPlayerPlay(videos[30], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0800 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0900 + * @tc.name : 001.test play source (h264.mkv) + * @tc.desc : Local Video play source (h264.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0900', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0900 start') + AVPlayerTestBase.avPlayerPlay(videos[31], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_0900 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1000 + * @tc.name : 001.test play source (h263.mkv) + * @tc.desc : Local Video play source (h263.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1000', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1000 start') + AVPlayerTestBase.avPlayerPlay(videos[32], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1000 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1100 + * @tc.name : 001.test play source (MPEG2.mkv) + * @tc.desc : Local Video play source (MPEG2.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1100 start') + AVPlayerTestBase.avPlayerPlay(videos[33], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1200 + * @tc.name : 001.test play source (mpeg4.mkv) + * @tc.desc : Local Video play source (mpeg4.mkv) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1200 start') + AVPlayerTestBase.avPlayerPlay(videos[34], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MKV_1200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_AAC_0100 + * @tc.name : 001.test play source (aac_audio.aac) + * @tc.desc : Local Video play source (aac_audio.aac) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_AAC_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_AAC_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[35], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_AAC_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP3_0100 + * @tc.name : 001.test play source (MP3_AUDIO.mp3) + * @tc.desc : Local Video play source (MP3_AUDIO.mp3) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP3_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP3_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[36], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP3_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_M4A_0100 + * @tc.name : 001.test play source (m4a_audio.m4a) + * @tc.desc : Local Video play source (m4a_audio.m4a) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_M4A_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_M4A_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[37], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_M4A_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_OGG_0100 + * @tc.name : 001.test play source (ogg_audio.ogg) + * @tc.desc : Local Video play source (ogg_audio.ogg) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_OGG_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_OGG_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[38], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_OGG_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WAV_0100 + * @tc.name : 001.test play source (wav_audio.wav) + * @tc.desc : Local Video play source (wav_audio.wav) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WAV_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WAV_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[39], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_WAV_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_FLAC_0100 + * @tc.name : 001.test play source (flac_audio.flac) + * @tc.desc : Local Video play source (flac_audio.flac) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_FLAC_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_FLAC_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[40], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_FLAC_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0100 + * @tc.name : 001.test play source 60fps + * @tc.desc : Local Video play source + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0100 start') + AVPlayerTestBase.avPlayerPlay(videos[41], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0200 + * @tc.name : 001.test play short source 1s + * @tc.desc : Local Video play short source + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0200 start') + AVPlayerTestBase.avPlayerPlay(videos[42], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0200 end') + }) + + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 + * @tc.name : 001.test play source 4k + * @tc.desc : Local Video play source + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level2 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 start') + AVPlayerTestBase.avPlayerPlay(videos[43], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0100 + * @tc.name : 001.test create->release (1000 times) + * @tc.desc : Local Video play create->release (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0100 start') + AVPlayerTestBase.createToRelease(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0200 + * @tc.name : 001.test play pause loop 1000 + * @tc.desc : Local Video play to pause 1000 times + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0200 start') + AVPlayerTestBase.avPlayerWithCallBack(videos[0], avPlayer, PLAY_TIME, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 + * @tc.name : 001.test complete->play->seek duration (1000 times) + * @tc.desc : Local Video complete->play->seek duration (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 start') + AVPlayerTestBase.playToCompleted(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0300 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0400 + * @tc.name : 001.test play->seek (1000 times wait callBack) + * @tc.desc : Local Video play->seek (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0400', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0400 start') + AVPlayerTestBase.seekLoop(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0400 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0500 + * @tc.name : 001.test play->seek (1000 times do not wait callBack) + * @tc.desc : Local Video play->seek (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0500', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0500 start') + AVPlayerTestBase.seekLoopWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0500 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0600 + * @tc.name : 001.test stop -> prepare (1000 times) + * @tc.desc : Local Video test stop -> prepare (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0600', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0600 start') + AVPlayerTestBase.prepareToStopLoop(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0600 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0700 + * @tc.name : 001.test reset -> url -> preapre -> play -> reset (1000 times) + * @tc.desc : Local Video test reset -> url -> preapre -> play -> reset (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0700', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0700 start') + AVPlayerTestBase.prepareToResetLoop(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0700 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0800 + * @tc.name : 001.test release -> create-> url -> prepare -> play -> release (1000 times) + * @tc.desc : Local Video test release -> create-> url -> prepare -> play -> release (1000 times) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0800', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0800 start') + AVPlayerTestBase.createToReleaseLoop(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0800 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 + * @tc.name : 001.test create time (wait callback) + * @tc.desc : Local Video test create time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ +// it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100', 0, async function (done) { +// console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 start') +// AVPlayerTestBase.createTimeWithCallback(videos[0], avPlayer, done); +// console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 end') +// }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0110 + * @tc.name : 001.test create time (not wait callback) + * @tc.desc : Local Video test create time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0110', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0110 start') + AVPlayerTestBase.createTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0110 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0200 + * @tc.name : 001.test prepare time (not wait callback) + * @tc.desc : Local Video test prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0200 start') + AVPlayerTestBase.prepareTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0210 + * @tc.name : 001.test prepare time (not wait callback) + * @tc.desc : Local Video test prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0210', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0210 start') + AVPlayerTestBase.prepareTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0210 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0300 + * @tc.name : 001.test play time (wait callback) + * @tc.desc : Local Video test play time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0300', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0300 start') + AVPlayerTestBase.playTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0300 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0310 + * @tc.name : 001.test play time (not wait callback) + * @tc.desc : Local Video play prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0310', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0310 start') + AVPlayerTestBase.playTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0310 end') + }) + + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0300 + * @tc.name : 001.test pause time (wait callback) + * @tc.desc : Local Video test pause time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0400', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0400 start') + AVPlayerTestBase.pauseTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0400 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0410 + * @tc.name : 001.test pause time (not wait callback) + * @tc.desc : Local Video pause prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0410', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0410 start') + AVPlayerTestBase.pauseTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0410 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0500 + * @tc.name : 001.test stop time (wait callback) + * @tc.desc : Local Video test stop time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0500', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0500 start') + AVPlayerTestBase.stopTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0500 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0510 + * @tc.name : 001.test stop time (not wait callback) + * @tc.desc : Local Video stop prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0510', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0510 start') + AVPlayerTestBase.stopTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0510 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0600 + * @tc.name : 001.test reset time (wait callback) + * @tc.desc : Local Video test reset time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0600', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0600 start') + AVPlayerTestBase.resetTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0600 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0610 + * @tc.name : 001.test reset time (not wait callback) + * @tc.desc : Local Video reset prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0610', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0610 start') + AVPlayerTestBase.resetTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0610 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0700 + * @tc.name : 001.test release time (wait callback) + * @tc.desc : Local Video test release time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0700', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0700 start') + AVPlayerTestBase.releaseTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0700 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0710 + * @tc.name : 001.test release time (not wait callback) + * @tc.desc : Local Video release prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0710', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0710 start') + AVPlayerTestBase.releaseTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0710 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0800 + * @tc.name : 001.test seek time (wait callback) + * @tc.desc : Local Video test seek time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0800', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0800 start') + AVPlayerTestBase.seekTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0800 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0810 + * @tc.name : 001.test seek time (not wait callback) + * @tc.desc : Local Video seek prepare time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0810', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0810 start') + AVPlayerTestBase.seekTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0810 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0900 + * @tc.name : 001.test getTrackDescription time (wait callback) + * @tc.desc : Local Video test getTrackDescription time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0900', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0900 start') + AVPlayerTestBase.getTrackDescriptionTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0900 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0910 + * @tc.name : 001.test getTrackDescription time (not wait callback) + * @tc.desc : Local Video test getTrackDescription time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0910', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0910 start') + AVPlayerTestBase.getTrackDescriptionTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0910 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1000 + * @tc.name : 001.test setSpeed time (wait callback) + * @tc.desc : Local Video test setSpeed time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1000', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1000 start') + AVPlayerTestBase.setSpeedTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1000 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1010 + * @tc.name : 001.test setSpeed time (not wait callback) + * @tc.desc : Local Video test setSpeed time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1010', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1010 start') + AVPlayerTestBase.setSpeedTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1010 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1100 + * @tc.name : 001.test setBitrate time (wait callback) + * @tc.desc : Local Video test setBitrate time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1100 start') + AVPlayerTestBase.setBitrateTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1100 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1110 + * @tc.name : 001.test setBitrate time (not wait callback) + * @tc.desc : Local Video test setBitrate time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1110', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1110 start') + AVPlayerTestBase.setBitrateTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1110 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1200 + * @tc.name : 001.test setVolume time (wait callback) + * @tc.desc : Local Video test setVolume time (wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1200', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1200 start') + AVPlayerTestBase.setVolumeTimeWithCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1200 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1210 + * @tc.name : 001.test setVolume time (not wait callback) + * @tc.desc : Local Video test setVolume time (not wait callback) + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1210', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1210 start') + AVPlayerTestBase.setVolumeTimeWithoutCallback(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_1210 end') + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_02_0100 + * @tc.name : 001.test firstFrame time + * @tc.desc : Local Video test firstFrame time + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level3 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_02_0100', 0, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_02_0100 start') + AVPlayerTestBase.firstFrameTime(videos[0], avPlayer, done); + console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_02_0100 end') + }) + }) +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AvPlayerEnumTest.test.js b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AvPlayerEnumTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..fb2be449d0a6485e4cafb0dd9d7bfa23dc1753ba --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AvPlayerEnumTest.test.js @@ -0,0 +1,106 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +export default function AvPlayerEnumTest() { + describe('AvPlayerEnumTest', function () { + beforeAll(function () { + console.info('beforeAll case'); + }) + + beforeEach(function () { + console.info('beforeEach case'); + }) + + afterEach(function () { + console.info('afterEach case'); + }) + + afterAll(function () { + console.info('afterAll case'); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AUDIO_RECORDER_ENUM_AUDIO_OUTPUT_FORMAT_0100 + * @tc.name : AVPlayer + * @tc.desc : AVPlayer Enumeration test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0100', 0, async function (done) { + expect(media.StateChangeReason.USER).assertEqual(1); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0200 + * @tc.name : AVPlayer + * @tc.desc : AVPlayer Enumeration test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0200', 0, async function (done) { + expect(media.AVErrorCode.AVERR_OK).assertEqual(0); + expect(media.AVErrorCode.AVERR_NO_PERMISSION).assertEqual(201); + expect(media.AVErrorCode.AVERR_INVALID_PARAMETER).assertEqual(401); + expect(media.AVErrorCode.AVERR_UNSUPPORT_CAPABILITY).assertEqual(801); + expect(media.AVErrorCode.AVERR_NO_MEMORY).assertEqual(5400101); + expect(media.AVErrorCode.AVERR_OPERATE_NOT_PERMIT).assertEqual(5400102); + expect(media.AVErrorCode.AVERR_IO).assertEqual(5400103); + expect(media.AVErrorCode.AVERR_TIMEOUT).assertEqual(5400104); + expect(media.AVErrorCode.AVERR_SERVICE_DIED).assertEqual(5400105); + expect(media.AVErrorCode.AVERR_UNSUPPORT_FORMAT).assertEqual(5400106); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0300 + * @tc.name : AVPlayer + * @tc.desc : AVPlayer Enumeration test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0300', 0, async function (done) { + expect(media.CodecMimeType.VIDEO_H263).assertEqual('video/h263'); + expect(media.CodecMimeType.VIDEO_AVC).assertEqual('video/avc'); + expect(media.CodecMimeType.VIDEO_MPEG2).assertEqual('video/mpeg2'); + expect(media.CodecMimeType.VIDEO_MPEG4).assertEqual('video/mp4v-es'); + expect(media.CodecMimeType.VIDEO_VP8).assertEqual('video/x-vnd.on2.vp8'); + expect(media.CodecMimeType.AUDIO_AAC).assertEqual('audio/mp4a-latm'); + expect(media.CodecMimeType.AUDIO_VORBIS).assertEqual('audio/vorbis'); + expect(media.CodecMimeType.AUDIO_FLAC).assertEqual('audio/flac'); + done(); + }) + + /* * + * @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0400 + * @tc.name : AVPlayer + * @tc.desc : AVPlayer Enumeration test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0400', 0, async function (done) { + expect(media.AudioSourceType.AUDIO_SOURCE_TYPE_DEFAULT).assertEqual(0); + done(); + }) + }) +} + diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/List.test.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e185b64cc29745f0cbef8411ac94144a2a38ff55 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,29 @@ +/* + * 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 AVPlayerHlsFuncTest from './AVPlayerHlsFuncTest.test.js' +import AVPlayerHttpCompatibilityTest from './AVPlayerHttpCompatibilityTest.test.ets' +import AVPlayerHttpSeekTest from './AVPlayerHttpSeekTest.test.ets' +import AVPlayerLocalTest from './AVPlayerLocalTest.test.js' +import AVPlayerStabilityTest from './AVPlayerStabilityTest.test.js' +import AvPlayerEnumTest from './AvPlayerEnumTest.test.js' + +export default function testsuite() { + // AVPlayerHlsFuncTest() + // AVPlayerHttpCompatibilityTest(); + // AVPlayerHttpSeekTest(); + AvPlayerEnumTest(); + AVPlayerLocalTest(); + AVPlayerStabilityTest(); +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/module.json b/multimedia/media/media_js_standard/avPlayer/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..cf58a5a22439b1b0886f5bcecd791ee658c608d4 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/module.json @@ -0,0 +1,56 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ohos.acts.multimedia.avplayer.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "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" + } + ] + } +} diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/element/string.json b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/media/icon.png b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/media/icon.png differ diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/profile/main_pages.json b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..02221db61d317863114ff0ca4dd2b33586abff12 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" + ] +} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/01.mp3 b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/01.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..85573aabb4945760a979388540f9374db46a968c Binary files /dev/null and b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/01.mp3 differ diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/H264_AAC.mp4 b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/H264_AAC.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b1e20e73501523f801a942f84f91ed6334161fa --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/H264_AAC.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7277b0e4910c52a8614d4f2162af3c03ad8589100f32e80dc36a9c96ba797ecd +size 1894335 diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/H264_NONE.mp4 b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/H264_NONE.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..cf471bac3096e4260c871e1691ddf88eb4f2d750 --- /dev/null +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/resources/rawfile/H264_NONE.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1ddbd12485f5ce4edb82100caef9fa118151bc0ac291799c9339737542d0449 +size 1897169 diff --git a/multimedia/media/media_js_standard/avPlayer/signature/openharmony_sx.p7b b/multimedia/media/media_js_standard/avPlayer/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..d2e97ce85cf501a0281d77da4dc608a7dda3b8fc Binary files /dev/null and b/multimedia/media/media_js_standard/avPlayer/signature/openharmony_sx.p7b differ