1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci
16f6603c60Sopenharmony_ciimport media from '@ohos.multimedia.media'
17f6603c60Sopenharmony_ciimport * as mediaTestBase from './MediaTestBase.js';
18f6603c60Sopenharmony_ci
19f6603c60Sopenharmony_ciexport async function playVideoSource(url, width, height, duration, playTime, done) {
20f6603c60Sopenharmony_ci    console.info(`case media source url: ${url}`)
21f6603c60Sopenharmony_ci    let videoPlayer = null;
22f6603c60Sopenharmony_ci    let surfaceID = globalThis.value;
23f6603c60Sopenharmony_ci    await media.createVideoPlayer().then((video) => {
24f6603c60Sopenharmony_ci        if (typeof (video) != 'undefined') {
25f6603c60Sopenharmony_ci            console.info('case createVideoPlayer success');
26f6603c60Sopenharmony_ci            videoPlayer = video;
27f6603c60Sopenharmony_ci        } else {
28f6603c60Sopenharmony_ci            console.error('case createVideoPlayer failed');
29f6603c60Sopenharmony_ci            expect().assertFail();
30f6603c60Sopenharmony_ci            done();
31f6603c60Sopenharmony_ci        }
32f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
33f6603c60Sopenharmony_ci
34f6603c60Sopenharmony_ci    videoPlayer.on('videoSizeChanged', (w, h) => {
35f6603c60Sopenharmony_ci        console.info('case videoSizeChanged  width: ' + w + ' height: ' + h);
36f6603c60Sopenharmony_ci    });
37f6603c60Sopenharmony_ci
38f6603c60Sopenharmony_ci    videoPlayer.on('error', (err) => {
39f6603c60Sopenharmony_ci        console.error(`case error called, errMessage is ${err.message}`);
40f6603c60Sopenharmony_ci        expect().assertFail();
41f6603c60Sopenharmony_ci        videoPlayer.release();
42f6603c60Sopenharmony_ci        done();
43f6603c60Sopenharmony_ci    });
44f6603c60Sopenharmony_ci    videoPlayer.url = url;
45f6603c60Sopenharmony_ci    await videoPlayer.setDisplaySurface(surfaceID).then(() => {
46f6603c60Sopenharmony_ci        console.info('case setDisplaySurface success, surfaceID: ' + surfaceID);
47f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
48f6603c60Sopenharmony_ci
49f6603c60Sopenharmony_ci
50f6603c60Sopenharmony_ci    await videoPlayer.prepare().then(() => {
51f6603c60Sopenharmony_ci        console.info('case prepare called');
52f6603c60Sopenharmony_ci        expect(Math.abs(videoPlayer.duration - duration)).assertLess(500);
53f6603c60Sopenharmony_ci        if (width != null & height != null) {
54f6603c60Sopenharmony_ci            expect(videoPlayer.width).assertEqual(width);
55f6603c60Sopenharmony_ci            expect(videoPlayer.height).assertEqual(height);
56f6603c60Sopenharmony_ci        }
57f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
58f6603c60Sopenharmony_ci
59f6603c60Sopenharmony_ci    await videoPlayer.getTrackDescription().then((arrayList) => {
60f6603c60Sopenharmony_ci        console.info('case getTrackDescription called');
61f6603c60Sopenharmony_ci        if (typeof (arrayList) != 'undefined') {
62f6603c60Sopenharmony_ci            for (let i = 0; i < arrayList.length; i++) {
63f6603c60Sopenharmony_ci                mediaTestBase.printDescription(arrayList[i]);
64f6603c60Sopenharmony_ci            }
65f6603c60Sopenharmony_ci        } else {
66f6603c60Sopenharmony_ci            console.error('case getTrackDescription failed');
67f6603c60Sopenharmony_ci            expect().assertFail();
68f6603c60Sopenharmony_ci        }
69f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
70f6603c60Sopenharmony_ci
71f6603c60Sopenharmony_ci    let startTime = videoPlayer.currentTime;
72f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
73f6603c60Sopenharmony_ci        console.info('case play called');
74f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
75f6603c60Sopenharmony_ci        mediaTestBase.msleep(playTime);
76f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
77f6603c60Sopenharmony_ci    let endTime = videoPlayer.currentTime;
78f6603c60Sopenharmony_ci    expect(Math.abs(endTime - startTime - playTime)).assertLess(1000);
79f6603c60Sopenharmony_ci
80f6603c60Sopenharmony_ci    await videoPlayer.seek(videoPlayer.duration / 3).then((seekDoneTime) => {
81f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
82f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
83f6603c60Sopenharmony_ci        mediaTestBase.msleep(playTime);
84f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
85f6603c60Sopenharmony_ci
86f6603c60Sopenharmony_ci    await videoPlayer.pause().then(() => {
87f6603c60Sopenharmony_ci        console.info('case pause called');
88f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('paused');
89f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
90f6603c60Sopenharmony_ci
91f6603c60Sopenharmony_ci    videoPlayer.loop = true;
92f6603c60Sopenharmony_ci    await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
93f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('paused');
94f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
95f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
96f6603c60Sopenharmony_ci
97f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
98f6603c60Sopenharmony_ci        console.info('case play called');
99f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
100f6603c60Sopenharmony_ci        mediaTestBase.msleep(playTime);
101f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
102f6603c60Sopenharmony_ci
103f6603c60Sopenharmony_ci    await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
104f6603c60Sopenharmony_ci        console.info('case setSpeed called and speedMode is ' + speedMode);
105f6603c60Sopenharmony_ci        mediaTestBase.msleep(playTime);
106f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
107f6603c60Sopenharmony_ci
108f6603c60Sopenharmony_ci    await videoPlayer.setVolume(0.5).then(() => {
109f6603c60Sopenharmony_ci        console.info('case setVolume called');
110f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
111f6603c60Sopenharmony_ci
112f6603c60Sopenharmony_ci    await videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
113f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
114f6603c60Sopenharmony_ci        mediaTestBase.msleep(videoPlayer.duration - seekDoneTime);
115f6603c60Sopenharmony_ci        videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X);
116f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
117f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
118f6603c60Sopenharmony_ci
119f6603c60Sopenharmony_ci    videoPlayer.loop = false;
120f6603c60Sopenharmony_ci    await videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
121f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
122f6603c60Sopenharmony_ci        if (seekDoneTime != 0){
123f6603c60Sopenharmony_ci            mediaTestBase.msleep((videoPlayer.duration - seekDoneTime) + playTime);
124f6603c60Sopenharmony_ci            expect(videoPlayer.state).assertEqual('stopped');
125f6603c60Sopenharmony_ci        }
126f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
127f6603c60Sopenharmony_ci
128f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
129f6603c60Sopenharmony_ci        console.info('case play called');
130f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
131f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
132f6603c60Sopenharmony_ci
133f6603c60Sopenharmony_ci    await videoPlayer.stop().then(() => {
134f6603c60Sopenharmony_ci        console.info('case stop called');
135f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('stopped');
136f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
137f6603c60Sopenharmony_ci
138f6603c60Sopenharmony_ci    await videoPlayer.reset().then(() => {
139f6603c60Sopenharmony_ci        console.info('case reset called');
140f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
141f6603c60Sopenharmony_ci
142f6603c60Sopenharmony_ci    videoPlayer.url = url;
143f6603c60Sopenharmony_ci
144f6603c60Sopenharmony_ci    await videoPlayer.prepare().then(() => {
145f6603c60Sopenharmony_ci        console.info('case prepare called');
146f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
147f6603c60Sopenharmony_ci
148f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
149f6603c60Sopenharmony_ci        console.info('case play called');
150f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
151f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
152f6603c60Sopenharmony_ci
153f6603c60Sopenharmony_ci    await videoPlayer.pause().then(() => {
154f6603c60Sopenharmony_ci        console.info('case pause called');
155f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('paused');
156f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
157f6603c60Sopenharmony_ci
158f6603c60Sopenharmony_ci    await videoPlayer.stop().then(() => {
159f6603c60Sopenharmony_ci        console.info('case stop called');
160f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('stopped');
161f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
162f6603c60Sopenharmony_ci
163f6603c60Sopenharmony_ci    await videoPlayer.release().then(() => {
164f6603c60Sopenharmony_ci        console.info('case release called');
165f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
166f6603c60Sopenharmony_ci}
167f6603c60Sopenharmony_ci
168f6603c60Sopenharmony_ciexport async function testVideoSeek(url, duration, playTime, done) {
169f6603c60Sopenharmony_ci    console.info(`case media source url: ${url}`)
170f6603c60Sopenharmony_ci    let videoPlayer = null;
171f6603c60Sopenharmony_ci    let surfaceID = globalThis.value;
172f6603c60Sopenharmony_ci    await media.createVideoPlayer().then((video) => {
173f6603c60Sopenharmony_ci        if (typeof (video) != 'undefined') {
174f6603c60Sopenharmony_ci            console.info('case createVideoPlayer success');
175f6603c60Sopenharmony_ci            videoPlayer = video;
176f6603c60Sopenharmony_ci        } else {
177f6603c60Sopenharmony_ci            console.error('case createVideoPlayer failed');
178f6603c60Sopenharmony_ci            expect().assertFail();
179f6603c60Sopenharmony_ci            done();
180f6603c60Sopenharmony_ci        }
181f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
182f6603c60Sopenharmony_ci
183f6603c60Sopenharmony_ci    videoPlayer.on('videoSizeChanged', (w, h) => {
184f6603c60Sopenharmony_ci        console.info('case videoSizeChanged  width: ' + w + ' height: ' + h);
185f6603c60Sopenharmony_ci    });
186f6603c60Sopenharmony_ci
187f6603c60Sopenharmony_ci    videoPlayer.on('error', (err) => {
188f6603c60Sopenharmony_ci        console.error(`case error called, errMessage is ${err.message}`);
189f6603c60Sopenharmony_ci        expect().assertFail();
190f6603c60Sopenharmony_ci        videoPlayer.release();
191f6603c60Sopenharmony_ci        done();
192f6603c60Sopenharmony_ci    });
193f6603c60Sopenharmony_ci    videoPlayer.url = url;
194f6603c60Sopenharmony_ci    await videoPlayer.setDisplaySurface(surfaceID).then(() => {
195f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
196f6603c60Sopenharmony_ci    await videoPlayer.prepare().then(() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
197f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
198f6603c60Sopenharmony_ci        console.info('case play called');
199f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
200f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
201f6603c60Sopenharmony_ci
202f6603c60Sopenharmony_ci    // pause when seeking
203f6603c60Sopenharmony_ci    videoPlayer.seek(videoPlayer.duration / 3).then((seekDoneTime) => {
204f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
205f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
206f6603c60Sopenharmony_ci    expect(Math.abs(videoPlayer.duration - duration)).assertLess(500);
207f6603c60Sopenharmony_ci    await videoPlayer.pause().then(() => {
208f6603c60Sopenharmony_ci        console.info('case pause called');
209f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('paused');
210f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
211f6603c60Sopenharmony_ci
212f6603c60Sopenharmony_ci    // play when seeking
213f6603c60Sopenharmony_ci    videoPlayer.seek(0).then((seekDoneTime) => {
214f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
215f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
216f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
217f6603c60Sopenharmony_ci        console.info('case play called');
218f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
219f6603c60Sopenharmony_ci        mediaTestBase.msleep(playTime);
220f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
221f6603c60Sopenharmony_ci
222f6603c60Sopenharmony_ci    // setVolume when setSpeeding
223f6603c60Sopenharmony_ci    videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
224f6603c60Sopenharmony_ci        console.info('case setSpeed called and speedMode is ' + speedMode);
225f6603c60Sopenharmony_ci        expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
226f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
227f6603c60Sopenharmony_ci    expect(Math.abs(videoPlayer.duration - duration)).assertLess(500);
228f6603c60Sopenharmony_ci    await videoPlayer.setVolume(0.5).then(() => {
229f6603c60Sopenharmony_ci        console.info('case setVolume called');
230f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
231f6603c60Sopenharmony_ci
232f6603c60Sopenharmony_ci    // setSpeed when seeking
233f6603c60Sopenharmony_ci    videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
234f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
235f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
236f6603c60Sopenharmony_ci    await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X).then((speedMode) => {
237f6603c60Sopenharmony_ci        console.info('case setSpeed called and speedMode is ' + speedMode);
238f6603c60Sopenharmony_ci        expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_00_X);
239f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
240f6603c60Sopenharmony_ci
241f6603c60Sopenharmony_ci    // seek when pausing
242f6603c60Sopenharmony_ci    videoPlayer.pause().then(() => {
243f6603c60Sopenharmony_ci        console.info('case pause called');
244f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('paused');
245f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
246f6603c60Sopenharmony_ci    await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
247f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
248f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
249f6603c60Sopenharmony_ci
250f6603c60Sopenharmony_ci    // seek when playing
251f6603c60Sopenharmony_ci    videoPlayer.play().then(() => {
252f6603c60Sopenharmony_ci        console.info('case pause called');
253f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
254f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
255f6603c60Sopenharmony_ci    await videoPlayer.seek(videoPlayer.duration / 3, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
256f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
257f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
258f6603c60Sopenharmony_ci
259f6603c60Sopenharmony_ci    // seek when seeking
260f6603c60Sopenharmony_ci    videoPlayer.seek(videoPlayer.duration / 3, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
261f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
262f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
263f6603c60Sopenharmony_ci    await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
264f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
265f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
266f6603c60Sopenharmony_ci
267f6603c60Sopenharmony_ci    // stop when seeking
268f6603c60Sopenharmony_ci    videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
269f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
270f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
271f6603c60Sopenharmony_ci    await videoPlayer.stop().then(() => {
272f6603c60Sopenharmony_ci        console.info('case stop called');
273f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('stopped');
274f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
275f6603c60Sopenharmony_ci    await videoPlayer.reset().then(() => {
276f6603c60Sopenharmony_ci        console.info('case reset called');
277f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
278f6603c60Sopenharmony_ci
279f6603c60Sopenharmony_ci    videoPlayer.url = url;
280f6603c60Sopenharmony_ci    await videoPlayer.prepare().then(() => {
281f6603c60Sopenharmony_ci        console.info('case prepare called');
282f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
283f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
284f6603c60Sopenharmony_ci        console.info('case play called');
285f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
286f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
287f6603c60Sopenharmony_ci
288f6603c60Sopenharmony_ci    // reset when seeking
289f6603c60Sopenharmony_ci    videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
290f6603c60Sopenharmony_ci        console.info('case seek called and seekDoneTime is ' + seekDoneTime);
291f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
292f6603c60Sopenharmony_ci    await videoPlayer.reset().then(() => {
293f6603c60Sopenharmony_ci        console.info('case reset called');
294f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
295f6603c60Sopenharmony_ci
296f6603c60Sopenharmony_ci    videoPlayer.url = url;
297f6603c60Sopenharmony_ci    await videoPlayer.prepare().then(() => {
298f6603c60Sopenharmony_ci        console.info('case prepare called');
299f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
300f6603c60Sopenharmony_ci    await videoPlayer.play().then(() => {
301f6603c60Sopenharmony_ci        console.info('case play called');
302f6603c60Sopenharmony_ci        expect(videoPlayer.state).assertEqual('playing');
303f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
304f6603c60Sopenharmony_ci
305f6603c60Sopenharmony_ci    // release when seeking
306f6603c60Sopenharmony_ci    videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_PREV_SYNC);
307f6603c60Sopenharmony_ci    await videoPlayer.release().then(() => {
308f6603c60Sopenharmony_ci        console.info('case release called');
309f6603c60Sopenharmony_ci    }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
310f6603c60Sopenharmony_ci}