diff --git a/multimedia/media/media_js_standard/MediaTestBase.js b/multimedia/media/media_js_standard/MediaTestBase.js index 1b78ecb585d4cf621345a3552a296de937f51853..dda5fb3f021bcfd0f880994c52851d84330aa3e2 100644 --- a/multimedia/media/media_js_standard/MediaTestBase.js +++ b/multimedia/media/media_js_standard/MediaTestBase.js @@ -71,6 +71,10 @@ export async function getFdRead(pathName, done) { return fdReturn; } +export async function closeFdNumber(fdNumber) { + await fileio.close(fdNumber); +} + // wait synchronously export function msleep(time) { for(let t = Date.now();Date.now() - t <= time;); @@ -159,7 +163,7 @@ export async function getFd(pathName) { } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); fdObject.fileAsset = await fetchFileResult.getAllObject(); - fdObject.fdNumber = await fdObject.fileAsset[0].open('Rw'); + fdObject.fdNumber = await fdObject.fileAsset[0].open('rw'); console.info('case getFd number is: ' + fdObject.fdNumber); } return fdObject; diff --git a/multimedia/media/media_js_standard/audioPlayer/Test.json b/multimedia/media/media_js_standard/audioPlayer/Test.json index 1a7e3fe2def3b56c8dc3baf754f7de82de0cbc2f..2e8f8a80182c5d03124f699dbec4dcc72d25e2a7 100644 --- a/multimedia/media/media_js_standard/audioPlayer/Test.json +++ b/multimedia/media/media_js_standard/audioPlayer/Test.json @@ -17,7 +17,7 @@ { "type": "ShellKit", "run-command": [ - "mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" + "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" ], "teardown-command":[ ] @@ -27,30 +27,30 @@ "pre-push": [ ], "push": [ - "./resource/audio/01.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/02.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/03.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/04.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/47.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/49.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/50.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/51.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/54.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/55.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/57.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/58.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/59.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/62.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/64.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/65.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/66.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/67.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/92.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/93.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/94.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/96.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/97.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", - "./resource/audio/98.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/" + "./resource/audio/01.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/02.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/03.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/04.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/47.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/49.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/50.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/51.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/54.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/55.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/57.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/58.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/59.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/62.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/64.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/65.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/66.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/67.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/92.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/93.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/94.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/96.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/97.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/", + "./resource/audio/98.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/" ] } ] diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/config.json b/multimedia/media/media_js_standard/audioPlayer/src/main/config.json index 42108b2fadc747ecedb18731e58c5277da672b72..97ec41fbfbba6c920950e5b7c53644b6d2937502 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/config.json +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/config.json @@ -40,7 +40,7 @@ "label": "$string:entry_MainAbility", "type": "page", "homeAbility": true, - "launchType": "standard" + "launchType": "singleton" } ], "deviceType": [ diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js index 627e87c1e35500ef82d9bc456df5141bdb2b7a12..7dc30e00a32084baca401f2bd24bff4acc7916c1 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js @@ -42,7 +42,8 @@ describe('PlayerLocalTestAudioAPI', function () { const VOLUME_VALUE = 0.5; let fdHead = 'fd://'; let fileDescriptor = undefined; - + let fdPath = ''; + let fdNumber = 0; beforeAll(async function() { console.info('beforeAll case'); }) @@ -52,10 +53,15 @@ describe('PlayerLocalTestAudioAPI', function () { await mediaTestBase.getFileDescriptor(AUDIO_SOURCE).then((res) => { fileDescriptor = res; }); + await mediaTestBase.getFdRead(AUDIO_SOURCE, openFileFailed).then((testNumber) => { + fdNumber = testNumber; + fdPath = fdHead + '' + fdNumber; + }) console.info('beforeEach case'); }) afterEach(async function() { + await mediaTestBase.closeFdNumber(fdNumber); await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE); console.info('afterEach case'); }) @@ -64,6 +70,10 @@ describe('PlayerLocalTestAudioAPI', function () { console.info('afterAll case'); }) + function openFileFailed() { + console.info('case file fail'); + } + function initAudioPlayer() { if (typeof (audioPlayer) != 'undefined') { audioPlayer.release(); @@ -85,7 +95,7 @@ describe('PlayerLocalTestAudioAPI', function () { switch (mySteps[0]) { case SRC_STATE: console.info(`case to prepare`); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; break; case PLAY_STATE: console.info(`case to play`); @@ -320,7 +330,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -336,7 +346,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PLAY_STATE, ERROR_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -352,7 +362,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, PLAY_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -368,7 +378,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, RESET_STATE, PLAY_STATE, ERROR_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -400,7 +410,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -416,7 +426,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -432,7 +442,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, PAUSE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -448,7 +458,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -464,7 +474,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -480,7 +490,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -496,7 +506,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -512,7 +522,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -528,7 +538,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -544,7 +554,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -560,7 +570,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -592,7 +602,7 @@ describe('PlayerLocalTestAudioAPI', function () { var mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -608,7 +618,7 @@ describe('PlayerLocalTestAudioAPI', function () { var mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -624,7 +634,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -640,7 +650,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -656,7 +666,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -672,7 +682,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -688,7 +698,7 @@ describe('PlayerLocalTestAudioAPI', function () { let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js index 010b1af261487d2c23a2f18108dafa067d1ba755..9dd16ce377276ccdc56d0ebd4adea53ce0ee1211 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js @@ -14,6 +14,7 @@ */ import media from '@ohos.multimedia.media' +import audio from '@ohos.multimedia.audio' import {playAudioSource} from '../../../../../AudioPlayerTestBase.js'; import * as mediaTestBase from '../../../../../MediaTestBase.js'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' @@ -44,6 +45,8 @@ describe('PlayerLocalTestAudioFUNC', function () { let bufferFlag = false; let fdHead = 'fd://'; let fileDescriptor = undefined; + let fdPath = ''; + let fdNumber = 0; let audioTrackKey = new Array('channel_count', 'codec_mime', 'sample_rate', 'track_index', 'track_type'); let audioTrackValue = new Array(1, 'audio/mpeg', 48000, 0, 0); @@ -53,6 +56,10 @@ describe('PlayerLocalTestAudioFUNC', function () { await mediaTestBase.getFileDescriptor(AUDIO_SOURCE).then((res) => { fileDescriptor = res; }); + await mediaTestBase.getFdRead(AUDIO_SOURCE, openFileFailed).then((testNumber) => { + fdNumber = testNumber; + fdPath = fdHead + '' + fdNumber; + }) console.info('beforeAll case'); }) @@ -67,9 +74,14 @@ describe('PlayerLocalTestAudioFUNC', function () { afterAll(async function() { await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE); + await mediaTestBase.closeFdNumber(fdNumber); console.info('afterAll case'); }) + function openFileFailed() { + console.info('case file fail'); + } + function initAudioPlayer() { if (typeof (audioPlayer) != 'undefined') { audioPlayer.release(); @@ -299,12 +311,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_SETVOLUME', 0, async function (done) { - mediaTestBase.isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, 0, VOLUME_STATE, 0.5, VOLUME_STATE, MAX_VOLUME, RESET_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdHead + fileDescriptor.fd; + audioPlayer.src = fdPath; }) /* * @@ -392,7 +403,7 @@ describe('PlayerLocalTestAudioFUNC', function () { testAudioPlayer.release(); done(); }); - testAudioPlayer.src = fdHead + fileDescriptor.fd; + testAudioPlayer.src = fdPath; }) /* * @@ -405,7 +416,7 @@ describe('PlayerLocalTestAudioFUNC', function () { */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_BASE_0100', 0, async function (done) { mediaTestBase.isFileOpen(fileDescriptor, done); - playAudioSource(fdHead + fileDescriptor.fd, DURATION_TIME, PLAY_TIME, true, done); + playAudioSource(fdPath, DURATION_TIME, PLAY_TIME, true, done); }) /* * @@ -434,8 +445,8 @@ describe('PlayerLocalTestAudioFUNC', function () { function waitForDone() { console.info('case wait for next player'); } - playAudioSource(fdHead + fileDescriptor.fd, DURATION_TIME, PLAY_TIME, true, waitForDone); + playAudioSource(fdPath, DURATION_TIME, PLAY_TIME, true, waitForDone); mediaTestBase.msleep(1000); - playAudioSource(fdHead + fileDescriptor.fd, DURATION_TIME, PLAY_TIME, true, done); + playAudioSource(fdPath, DURATION_TIME, PLAY_TIME, true, done); }) }) diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js index 5fbe665ff9046b9c692a479726580b97b66d1d32..857a46e3735f8666efb6bb86fb26297064861cdb 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js @@ -18,14 +18,12 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('PlayerLocalTestAudioFormat', function () { - let audioSource = '01.mp3'; const MAX_VOLUME = 1; const PLAY_TIME = 3000; const SEEK_TIME = 10000; // 10s let isToSeek = false; let isToDuration = false; - let fileDescriptor = undefined; - + let fdNumber = 0; beforeAll(function() { console.info('beforeAll case'); }) @@ -36,23 +34,20 @@ describe('PlayerLocalTestAudioFormat', function () { console.info('beforeEach case'); }) - afterEach(function() { + afterEach(async function() { + await mediaTestBase.closeFdNumber(fdNumber); console.info('afterEach case'); }) - afterAll(async function() { - await mediaTestBase.closeFileDescriptor(audioSource); + afterAll(function() { console.info('afterAll case'); }) async function playSource(audioFile, done) { let audioPlayer = media.createAudioPlayer(); - audioSource = audioFile; - await mediaTestBase.getFileDescriptor(audioSource).then((res) => { - fileDescriptor = res; - }); - mediaTestBase.isFileOpen(fileDescriptor, done); - audioPlayer.src = 'fd://' + fileDescriptor.fd; + await mediaTestBase.getFdRead(audioFile, done).then((testNumber) => { + fdNumber = testNumber; + }) audioPlayer.on('dataLoad', () => { console.info('case set source success'); expect(audioPlayer.state).assertEqual('paused'); @@ -122,6 +117,7 @@ describe('PlayerLocalTestAudioFormat', function () { expect().assertFail(); done(); }); + audioPlayer.src = 'fd://' + fdNumber; } /* * diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/resources/rawfile/01.mp3 b/multimedia/media/media_js_standard/audioPlayer/src/main/resources/rawfile/01.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..85573aabb4945760a979388540f9374db46a968c Binary files /dev/null and b/multimedia/media/media_js_standard/audioPlayer/src/main/resources/rawfile/01.mp3 differ diff --git a/multimedia/media/media_js_standard/videoPlayer/Test.json b/multimedia/media/media_js_standard/videoPlayer/Test.json index e318313eb3cb42f7f9c8a0ca8a28d72a16eebc26..fb46fd1626d9e14cdb6c3b295ff074676ee7854a 100644 --- a/multimedia/media/media_js_standard/videoPlayer/Test.json +++ b/multimedia/media/media_js_standard/videoPlayer/Test.json @@ -17,7 +17,7 @@ { "type": "ShellKit", "run-command": [ - "mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" + "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.video.videoplayer/haps/entry/files" ], "teardown-command":[ ] @@ -27,7 +27,8 @@ "pre-push": [ ], "push": [ - "./resource/audio/H264_AAC.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/" + "./resource/audio/H264_AAC.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.video.videoplayer/haps/entry/files/", + "./resource/audio/01.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.video.videoplayer/haps/entry/files/" ] } ] diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/config.json b/multimedia/media/media_js_standard/videoPlayer/src/main/config.json index 4ce9b1cbe11bd5a006a2e7bc15b4f8b6484f97d6..0c5132a0009bdeb594c9ad7aaab5bb98d9ee5c49 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/config.json +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/config.json @@ -40,7 +40,7 @@ "label": "$string:entry_MainAbility", "type": "page", "homeAbility": true, - "launchType": "standard" + "launchType": "singleton" } ], "deviceType": [ diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js index 990f1a76256325f722eb44d2692dde75e9325498..96dd7cc6ec2f6f27d5b51a4ee2b8982d3e9e00f3 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js @@ -52,10 +52,16 @@ describe('VideoPlayerAPICallbackTest', function () { const pagePath2 = 'pages/surfaceTest2/surfaceTest2'; let pageId = 0; let fdHead = 'fd://'; + let fdPath = ''; + let fdNumber = 0; let events = require('events'); let eventEmitter = new events.EventEmitter(); beforeAll(async function() { + await mediaTestBase.getFdRead(VIDEO_SOURCE, openFileFailed).then((testNumber) => { + fdNumber = testNumber; + fdPath = fdHead + '' + fdNumber; + }) console.info('beforeAll case'); }) @@ -79,9 +85,14 @@ describe('VideoPlayerAPICallbackTest', function () { }) afterAll(async function() { + await mediaTestBase.closeFdNumber(fdNumber); console.info('afterAll case'); }) + function openFileFailed() { + console.info('case file fail'); + } + function toNextStep(videoPlayer, steps, done) { if (steps[0] == END_EVENT) { console.info('case success!!'); @@ -138,7 +149,7 @@ describe('VideoPlayerAPICallbackTest', function () { }); eventEmitter.on(SETURL_EVENT, (videoPlayer, steps, done) => { steps.shift(); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.url = fdPath; toNextStep(videoPlayer, steps, done); }); eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => { diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerEnumTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerEnumTest.test.js index 41d2c346912fe28e356d650ea441db04bf5e2f25..c44a769aad068636d4a07b8f64c543594f2cd81f 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerEnumTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerEnumTest.test.js @@ -167,4 +167,18 @@ describe('VideoPlayerEnumTest', function () { expect(media.MediaDescriptionKey.MD_KEY_AUD_SAMPLE_RATE).assertEqual("sample_rate"); done(); }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_ENUM_MEDIA_SCALE_TYPE_00_0100 + * @tc.name : MediaType + * @tc.desc : MediaType Enumeration test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_ENUM_MEDIA_TYPE_00_0100', 0, async function (done) { + expect(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT).assertEqual(0); + expect(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP).assertEqual(1); + done(); + }) }) \ No newline at end of file diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js index de1c3ef2a29fde9d8756c4fe6f152520b26fa895..bd1adfc2cf3b7e4cbd756b29c6587057401ef89d 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js @@ -54,6 +54,8 @@ describe('VideoPlayerFuncCallbackTest', function () { const pagePath1 = 'pages/surfaceTest/surfaceTest'; const pagePath2 = 'pages/surfaceTest2/surfaceTest2'; let pageId = 0; + let fdPath = ''; + let fdNumber = 0; let events = require('events'); let eventEmitter = new events.EventEmitter(); @@ -62,6 +64,10 @@ describe('VideoPlayerFuncCallbackTest', function () { await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => { fileDescriptor = res; }); + await mediaTestBase.getFdRead(VIDEO_SOURCE, openFileFailed).then((testNumber) => { + fdNumber = testNumber; + fdPath = fdHead + '' + fdNumber; + }) }) beforeEach(async function() { @@ -81,9 +87,14 @@ describe('VideoPlayerFuncCallbackTest', function () { afterAll(async function() { await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE); + await mediaTestBase.closeFdNumber(fdNumber); console.info('afterAll case'); }) + function openFileFailed() { + console.info('case file fail'); + } + function toNextStep(videoPlayer, steps, done) { if (steps[0] == END_EVENT) { console.info('case success!!'); @@ -469,8 +480,7 @@ describe('VideoPlayerFuncCallbackTest', function () { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SETSOURCE', 0, async function (done) { mediaTestBase.isFileOpen(fileDescriptor, done); let videoPlayer = null; - let fdPath = ''; - let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, fdPath, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, '', ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -485,7 +495,7 @@ describe('VideoPlayerFuncCallbackTest', function () { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETVOLUME', 0, async function (done) { mediaTestBase.isFileOpen(fileDescriptor, done); let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, fdPath, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.5, SETVOLUME_EVENT, 1, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -522,7 +532,7 @@ describe('VideoPlayerFuncCallbackTest', function () { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK', 0, async function (done) { mediaTestBase.isFileOpen(fileDescriptor, done); let videoPlayer = null; - let frameCount = -1; + let frameCount = false; let completedCount = 0; let widthValue = -1; let heightValue = -1; @@ -547,6 +557,7 @@ describe('VideoPlayerFuncCallbackTest', function () { expect(widthValue).assertEqual(WIDTH_VALUE); expect(heightValue).assertEqual(HEIGHT_VALUE); expect(completedCount).assertEqual(1); + expect(frameCount).assertEqual(true); videoPlayer.release((err) => { if (typeof (err) == 'undefined') { console.info('case release success!!'); @@ -564,6 +575,7 @@ describe('VideoPlayerFuncCallbackTest', function () { videoPlayer.on('startRenderFrame', () => { console.info('case startRenderFrame success'); + frameCount = true; }); videoPlayer.on('videoSizeChanged', (width, height) => { diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js index 0e36ba2a4c06b5634e338d3142a4359d62ae89bc..43a332a744b456366b5bbee51aaf286ffbeb0dc2 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js @@ -14,11 +14,13 @@ */ import media from '@ohos.multimedia.media' +import audio from '@ohos.multimedia.audio' import * as mediaTestBase from '../../../../../MediaTestBase.js'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('VideoPlayerFuncPromiseTest', function () { const VIDEO_SOURCE = 'H264_AAC.mp4'; + const AUDIO_SOURCE = '01.mp3'; const PLAY_TIME = 3000; const SEEK_TIME = 5000; const WIDTH_VALUE = 720; @@ -34,12 +36,18 @@ describe('VideoPlayerFuncPromiseTest', function () { const pagePath1 = 'pages/surfaceTest/surfaceTest'; const pagePath2 = 'pages/surfaceTest2/surfaceTest2'; let pageId = 0; + let fdPath = ''; + let fdNumber = 0; beforeAll(async function() { console.info('beforeAll case'); await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => { fileDescriptor = res; }); + await mediaTestBase.getFdRead(VIDEO_SOURCE, openFileFailed).then((testNumber) => { + fdNumber = testNumber; + fdPath = fdHead + '' + fdNumber; + }) }) beforeEach(async function() { @@ -59,9 +67,14 @@ describe('VideoPlayerFuncPromiseTest', function () { afterAll(async function() { await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE); + await mediaTestBase.closeFdNumber(fdNumber); console.info('afterAll case'); }) + function openFileFailed() { + console.info('case file fail'); + } + function checkSpeedTime(videoPlayer, speedValue, startTime) { let newTime = videoPlayer.currentTime; if (videoPlayer.state == 'playing') { @@ -140,7 +153,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.url = fdPath; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -197,7 +210,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.url = fdPath; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -282,7 +295,7 @@ describe('VideoPlayerFuncPromiseTest', function () { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Callback', 0, async function (done) { mediaTestBase.isFileOpen(fileDescriptor, done); let videoPlayer = null; - let frameCount = -1; + let frameCount = false; let completedCount = 0; let widthValue = -1; let heightValue = -1; @@ -304,7 +317,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); expect(widthValue).assertEqual(WIDTH_VALUE); expect(heightValue).assertEqual(HEIGHT_VALUE); - //expect(frameCount).assertEqual(1); + expect(frameCount).assertEqual(true); expect(completedCount).assertEqual(1); done(); }); @@ -316,7 +329,7 @@ describe('VideoPlayerFuncPromiseTest', function () { videoPlayer.on('startRenderFrame', () => { console.info('case startRenderFrame success'); - //frameCount++; + frameCount = true; }); videoPlayer.on('videoSizeChanged', (width, height) => { @@ -325,7 +338,7 @@ describe('VideoPlayerFuncPromiseTest', function () { heightValue = height; }); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.url = fdPath; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -390,7 +403,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case bufferingUpdate bufferCount value is ' + bufferCount); }); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.fdSrc = fileDescriptor; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -457,7 +470,7 @@ describe('VideoPlayerFuncPromiseTest', function () { done(); }); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.url = fdPath; await videoPlayer.setDisplaySurface(surfaceID).then(() => { console.info('case setDisplaySurface success'); expect(videoPlayer.state).assertEqual('idle'); @@ -501,7 +514,7 @@ describe('VideoPlayerFuncPromiseTest', function () { expect(videoPlayer.state).assertEqual('idle'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); - videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.url = fdPath; await videoPlayer.prepare().then(() => { console.info('case prepare called!!'); expect(videoPlayer.state).assertEqual('prepared'); @@ -538,4 +551,260 @@ describe('VideoPlayerFuncPromiseTest', function () { }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); videoPlayer.loop = false; }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0100 + * @tc.name : 001.test video player videoScaleTpe (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0100', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + console.info('case createVideoPlayer success'); + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + videoPlayer.on('error', (error) => { + expect().assertFail(); + console.info('case error happened :' + error.message); + }); + + videoPlayer.on('playbackCompleted', async () => { + console.info('case playbackCompleted success'); + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + }); + + videoPlayer.url = fdPath; + console.info('case set videoScaleType : 1'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + console.info('case setDisplaySurface success'); + expect(videoPlayer.state).assertEqual('idle'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.prepare().then(() => { + console.info('case prepare called!!'); + expect(videoPlayer.state).assertEqual('prepared'); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP); + let startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let endTime = videoPlayer.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + console.info('case set videoScaleType : 0'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT; + await videoPlayer.pause().then(() => { + expect(videoPlayer.state).assertEqual('paused'); + console.info('case pause called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT); + await videoPlayer.play().then(() => { + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.stop().then(() => { + console.info('case stop called!!'); + expect(videoPlayer.state).assertEqual('stopped'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + console.info('case set videoScaleType : 1'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP; + await videoPlayer.reset().then(() => { + console.info('case reset called!!'); + expect(videoPlayer.state).assertEqual('idle'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + videoPlayer.url = fdPath; + console.info('case set videoScaleType : 1'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP; + await videoPlayer.prepare().then(() => { + console.info('case prepare called!!'); + expect(videoPlayer.state).assertEqual('prepared'); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP); + videoPlayer.loop = true; + startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + endTime = videoPlayer.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + console.info('case set videoScaleType : 0'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT; + await videoPlayer.seek(videoPlayer.duration / 2).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT); + mediaTestBase.msleep(PLAY_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + console.info('case set videoScaleType : 1'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP; + await videoPlayer.seek(0).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP); + mediaTestBase.msleep(PLAY_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + console.info('case set videoScaleType : 0'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT; + await videoPlayer.seek(videoPlayer.duration).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT); + mediaTestBase.msleep(PLAY_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + videoPlayer.loop = false; + }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0200 + * @tc.name : 002.set videoScaleTpe 100 times in playing (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0200', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let bufferCount = false; + let count = 0; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + videoPlayer.on('playbackCompleted', async () => { + console.info('case playbackCompleted success'); + await videoPlayer.play().then(() => { + expect(videoPlayer.loop).assertEqual(false); + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + expect(bufferCount).assertEqual(true); + done(); + }); + + videoPlayer.on('bufferingUpdate', (infoType, value) => { + console.info('case bufferingUpdate success infoType is ' + infoType); + console.info('case bufferingUpdate success value is ' + value); + bufferCount = true; + }); + + videoPlayer.url = fdPath; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.prepare().then(() => { + videoPlayer.loop = true; + expect(videoPlayer.state).assertEqual('prepared'); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + console.info('case prepare called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + let startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + expect(videoPlayer.loop).assertEqual(true); + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let endTime = videoPlayer.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + + for (let i = 0; i < 20; i++) { + if (count == 0) { + console.info('case set videoScaleType : 1'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP; + count = 1; + } else { + console.info('case set videoScaleType : 0'); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT; + count = 0; + } + mediaTestBase.msleep(500); + } + + videoPlayer.loop = false; + }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0300 + * @tc.name : 003.set error value to videoScaleTpe (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let errorCount = 0; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + + videoPlayer.on('error', async (error) => { + errorCount++; + console.info('case error happened :' + error.message); + if (errorCount == 3) { + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + } + }); + videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT; + videoPlayer.url = fdPath; + videoPlayer.videoScaleType = 2; + videoPlayer.videoScaleType = -1; + }) + }) diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/resources/rawfile/01.mp3 b/multimedia/media/media_js_standard/videoPlayer/src/main/resources/rawfile/01.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..85573aabb4945760a979388540f9374db46a968c Binary files /dev/null and b/multimedia/media/media_js_standard/videoPlayer/src/main/resources/rawfile/01.mp3 differ diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/resources/rawfile/H264_AAC.mp4 b/multimedia/media/media_js_standard/videoPlayer/src/main/resources/rawfile/H264_AAC.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b1e20e73501523f801a942f84f91ed6334161fa --- /dev/null +++ b/multimedia/media/media_js_standard/videoPlayer/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/videoRecorder/src/main/config.json b/multimedia/media/media_js_standard/videoRecorder/src/main/config.json index 750e81eec5a4e8745a86510d88c8c9f4c61bcf8f..bb6d00e0c5e6bc3224c62aa3118a8ced097fddc6 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/config.json +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/config.json @@ -40,7 +40,7 @@ "label": "$string:entry_MainAbility", "type": "page", "homeAbility": true, - "launchType": "standard" + "launchType": "singleton" } ], "deviceType": [