ohos_media_sys/avplayer/avplayer_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(deprecated)]
7#[cfg(feature = "api-20")]
8#[allow(unused_imports)]
9use crate::avcodec_base::OH_AVDataSourceExt;
10#[allow(unused_imports)]
11use crate::averrors::OH_AVErrCode;
12use crate::avplayer_base::{
13 AVPlaybackSpeed, AVPlayerCallback, AVPlayerSeekMode, AVPlayerState, OH_AVPlayer,
14};
15#[cfg(feature = "api-12")]
16use crate::avplayer_base::{OH_AVPlayerOnErrorCallback, OH_AVPlayerOnInfoCallback};
17use ohos_sys_opaque_types::OHNativeWindow;
18
19/// MediaKeySession field.
20///
21/// Available since API-level: 12
22///
23/// Version: 1.0
24#[cfg(feature = "api-12")]
25#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
26#[repr(C)]
27pub struct MediaKeySession {
28 _unused: [u8; 0],
29}
30/// DRM_MediaKeySystemInfo field.
31///
32/// Available since API-level: 12
33///
34/// Version: 1.0
35#[cfg(feature = "api-12")]
36#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
37#[repr(C)]
38pub struct DRM_MediaKeySystemInfo {
39 _unused: [u8; 0],
40}
41/// Call back will be invoked when updating DRM information.
42/// # Arguments
43///
44/// * `player` - Player instance.
45///
46/// * `mediaKeySystemInfo` - DRM information.
47///
48/// # Returns
49///
50/// * void
51///
52/// Available since API-level: 12
53///
54/// Version: 1.0
55#[cfg(feature = "api-12")]
56#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
57pub type Player_MediaKeySystemInfoCallback = ::core::option::Option<
58 unsafe extern "C" fn(player: *mut OH_AVPlayer, mediaKeySystemInfo: *mut DRM_MediaKeySystemInfo),
59>;
60extern "C" {
61 /// Create a player
62 ///
63 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
64 ///
65 /// # Returns
66 ///
67 /// * Returns a pointer to an OH_AVPlayer instance for success, nullptr for failure
68 /// Possible failure causes: 1. failed to PlayerFactory::CreatePlayer. 2. failed to new PlayerObject.
69 ///
70 /// Available since API-level: 11
71 ///
72 /// Version: 1.0
73 #[cfg(feature = "api-11")]
74 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
75 pub fn OH_AVPlayer_Create() -> *mut OH_AVPlayer;
76 /// Sets the playback source for the player. The corresponding source can be http url
77 ///
78 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
79 /// # Arguments
80 ///
81 /// * `player` - Pointer to an OH_AVPlayer instance
82 ///
83 /// * `url` - Indicates the playback source.
84 ///
85 /// # Returns
86 ///
87 /// * Function result code.
88 /// [`AV_ERR_OK`] if the execution is successful.
89 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr, url is null or player setUrlSource failed.
90 ///
91 /// Available since API-level: 11
92 ///
93 /// Version: 1.0
94 #[cfg(feature = "api-11")]
95 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
96 pub fn OH_AVPlayer_SetURLSource(
97 player: *mut OH_AVPlayer,
98 url: *const ::core::ffi::c_char,
99 ) -> OH_AVErrCode;
100 /// Sets the playback media file descriptor source for the player.
101 ///
102 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
103 /// # Arguments
104 ///
105 /// * `player` - Pointer to an OH_AVPlayer instance
106 ///
107 /// * `fd` - Indicates the file descriptor of media source.
108 ///
109 /// * `offset` - Indicates the offset of media source in file descriptor.
110 ///
111 /// * `size` - Indicates the size of media source.
112 ///
113 /// # Returns
114 ///
115 /// * Function result code.
116 /// [`AV_ERR_OK`] if the execution is successful.
117 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player setFdSource failed.
118 ///
119 /// Available since API-level: 11
120 ///
121 /// Version: 1.0
122 #[cfg(feature = "api-11")]
123 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
124 pub fn OH_AVPlayer_SetFDSource(
125 player: *mut OH_AVPlayer,
126 fd: i32,
127 offset: i64,
128 size: i64,
129 ) -> OH_AVErrCode;
130 /// Prepares the playback environment and buffers media data asynchronous.
131 ///
132 /// This function must be called after [`SetSource`].
133 ///
134 ///
135 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
136 /// # Arguments
137 ///
138 /// * `player` - Pointer to an OH_AVPlayer instance
139 ///
140 /// # Returns
141 ///
142 /// * Function result code.
143 /// [`AV_ERR_OK`] if the execution is successful.
144 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Prepare failed.
145 ///
146 /// Available since API-level: 11
147 ///
148 /// Version: 1.0
149 #[cfg(feature = "api-11")]
150 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
151 pub fn OH_AVPlayer_Prepare(player: *mut OH_AVPlayer) -> OH_AVErrCode;
152 /// Start playback.
153 ///
154 /// This function must be called after [`Prepare`]. If the player state is <b>Prepared</b>,
155 /// this function is called to start playback.
156 ///
157 ///
158 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
159 /// # Arguments
160 ///
161 /// * `player` - Pointer to an OH_AVPlayer instance
162 ///
163 /// # Returns
164 ///
165 /// * Function result code.
166 /// [`AV_ERR_OK`] if the execution is successful.
167 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Play failed.
168 ///
169 /// Available since API-level: 11
170 ///
171 /// Version: 1.0
172 #[cfg(feature = "api-11")]
173 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
174 pub fn OH_AVPlayer_Play(player: *mut OH_AVPlayer) -> OH_AVErrCode;
175 /// Pauses playback.
176 ///
177 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
178 /// # Arguments
179 ///
180 /// * `player` - Pointer to an OH_AVPlayer instance
181 ///
182 /// # Returns
183 ///
184 /// * Function result code.
185 /// [`AV_ERR_OK`] if the execution is successful.
186 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Pause failed.
187 ///
188 /// Available since API-level: 11
189 ///
190 /// Version: 1.0
191 #[cfg(feature = "api-11")]
192 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
193 pub fn OH_AVPlayer_Pause(player: *mut OH_AVPlayer) -> OH_AVErrCode;
194 /// Stop playback.
195 ///
196 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
197 /// # Arguments
198 ///
199 /// * `player` - Pointer to an OH_AVPlayer instance
200 ///
201 /// # Returns
202 ///
203 /// * Function result code.
204 /// [`AV_ERR_OK`] if the execution is successful.
205 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Stop failed.
206 ///
207 /// Available since API-level: 11
208 ///
209 /// Version: 1.0
210 #[cfg(feature = "api-11")]
211 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
212 pub fn OH_AVPlayer_Stop(player: *mut OH_AVPlayer) -> OH_AVErrCode;
213 /// Restores the player to the initial state.
214 ///
215 /// After the function is called, add a playback source by calling [`SetSource`],
216 /// call [`Play`] to start playback again after [`Prepare`] is called.
217 ///
218 ///
219 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
220 /// # Arguments
221 ///
222 /// * `player` - Pointer to an OH_AVPlayer instance
223 ///
224 /// # Returns
225 ///
226 /// * Function result code.
227 /// [`AV_ERR_OK`] if the execution is successful.
228 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Reset failed.
229 ///
230 /// Available since API-level: 11
231 ///
232 /// Version: 1.0
233 #[cfg(feature = "api-11")]
234 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
235 pub fn OH_AVPlayer_Reset(player: *mut OH_AVPlayer) -> OH_AVErrCode;
236 /// Releases player resources async
237 ///
238 /// Asynchronous release guarantees the performance
239 /// but cannot ensure whether the surfacebuffer is released.
240 /// The caller needs to ensure the life cycle security of the surface
241 ///
242 ///
243 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
244 /// # Arguments
245 ///
246 /// * `player` - Pointer to an OH_AVPlayer instance
247 ///
248 /// # Returns
249 ///
250 /// * Function result code.
251 /// [`AV_ERR_OK`] if the execution is successful.
252 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Release failed.
253 ///
254 /// Available since API-level: 11
255 ///
256 /// Version: 1.0
257 #[cfg(feature = "api-11")]
258 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
259 pub fn OH_AVPlayer_Release(player: *mut OH_AVPlayer) -> OH_AVErrCode;
260 /// Releases player resources sync
261 ///
262 /// Synchronous release ensures effective release of surfacebuffer
263 /// but this interface will take a long time (when the engine is not idle state)
264 /// requiring the caller to design an asynchronous mechanism by itself
265 ///
266 ///
267 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
268 /// # Arguments
269 ///
270 /// * `player` - Pointer to an OH_AVPlayer instance
271 ///
272 /// # Returns
273 ///
274 /// * Function result code.
275 /// [`AV_ERR_OK`] if the execution is successful.
276 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player ReleaseSync failed.
277 ///
278 /// Available since API-level: 11
279 ///
280 /// Version: 1.0
281 #[cfg(feature = "api-11")]
282 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
283 pub fn OH_AVPlayer_ReleaseSync(player: *mut OH_AVPlayer) -> OH_AVErrCode;
284 /// Sets the volume of the player.
285 ///
286 /// This function can be used during playback or pause. The value <b>0</b> indicates no sound,
287 /// and <b>1</b> indicates the original volume. If no audio device is started or no audio
288 /// stream exists, the value <b>-1</b> is returned.
289 ///
290 ///
291 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
292 /// # Arguments
293 ///
294 /// * `player` - Pointer to an OH_AVPlayer instance
295 ///
296 /// * `leftVolume` - Indicates the target volume of the left audio channel to set,
297 /// ranging from 0 to 1. each step is 0.01.
298 ///
299 /// * `rightVolume` - Indicates the target volume of the right audio channel to set,
300 /// ranging from 0 to 1. each step is 0.01.
301 ///
302 /// # Returns
303 ///
304 /// * Function result code.
305 /// [`AV_ERR_OK`] if the execution is successful.
306 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player SetVolume failed.
307 ///
308 /// Available since API-level: 11
309 ///
310 /// Version: 1.0
311 #[cfg(feature = "api-11")]
312 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
313 pub fn OH_AVPlayer_SetVolume(
314 player: *mut OH_AVPlayer,
315 leftVolume: f32,
316 rightVolume: f32,
317 ) -> OH_AVErrCode;
318 /// Changes the playback position.
319 ///
320 /// This function can be used during play or pause.
321 ///
322 ///
323 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
324 /// # Arguments
325 ///
326 /// * `player` - Pointer to an OH_AVPlayer instance
327 ///
328 /// * `mSeconds` - Indicates the target playback position, accurate to milliseconds.
329 ///
330 /// * `mode` - Indicates the player seek mode. For details, see [`AVPlayerSeekMode`].
331 ///
332 /// # Returns
333 ///
334 /// * Function result code.
335 /// [`AV_ERR_OK`] if the execution is successful.
336 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player Seek failed.
337 ///
338 /// Available since API-level: 11
339 ///
340 /// Version: 1.0
341 #[cfg(feature = "api-11")]
342 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
343 pub fn OH_AVPlayer_Seek(
344 player: *mut OH_AVPlayer,
345 mSeconds: i32,
346 mode: AVPlayerSeekMode,
347 ) -> OH_AVErrCode;
348 /// Obtains the playback position, accurate to millisecond.
349 ///
350 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
351 /// # Arguments
352 ///
353 /// * `player` - Pointer to an OH_AVPlayer instance
354 ///
355 /// * `currentTime` - Indicates the playback position.
356 ///
357 /// # Returns
358 ///
359 /// * Function result code.
360 /// [`AV_ERR_OK`] if the execution is successful.
361 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player GetCurrentTime failed.
362 ///
363 /// Available since API-level: 11
364 ///
365 /// Version: 1.0
366 #[cfg(feature = "api-11")]
367 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
368 pub fn OH_AVPlayer_GetCurrentTime(
369 player: *mut OH_AVPlayer,
370 currentTime: *mut i32,
371 ) -> OH_AVErrCode;
372 /// get the video width.
373 ///
374 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
375 /// # Arguments
376 ///
377 /// * `player` - Pointer to an OH_AVPlayer instance
378 ///
379 /// * `videoWidth` - The video width
380 ///
381 /// # Returns
382 ///
383 /// * Function result code.
384 /// [`AV_ERR_OK`] if the execution is successful.
385 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr.
386 ///
387 /// Available since API-level: 11
388 ///
389 /// Version: 1.0
390 #[cfg(feature = "api-11")]
391 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
392 pub fn OH_AVPlayer_GetVideoWidth(
393 player: *mut OH_AVPlayer,
394 videoWidth: *mut i32,
395 ) -> OH_AVErrCode;
396 /// get the video height.
397 ///
398 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
399 /// # Arguments
400 ///
401 /// * `player` - Pointer to an OH_AVPlayer instance
402 ///
403 /// * `videoHeight` - The video height
404 ///
405 /// # Returns
406 ///
407 /// * Function result code.
408 /// [`AV_ERR_OK`] if the execution is successful.
409 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr.
410 ///
411 /// Available since API-level: 11
412 ///
413 /// Version: 1.0
414 #[cfg(feature = "api-11")]
415 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
416 pub fn OH_AVPlayer_GetVideoHeight(
417 player: *mut OH_AVPlayer,
418 videoHeight: *mut i32,
419 ) -> OH_AVErrCode;
420 /// set the player playback rate
421 ///
422 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
423 /// # Arguments
424 ///
425 /// * `player` - Pointer to an OH_AVPlayer instance
426 ///
427 /// * `speed` - the rate mode [`AVPlaybackSpeed`] which can set.
428 ///
429 /// # Returns
430 ///
431 /// * Function result code.
432 /// [`AV_ERR_OK`] if the execution is successful.
433 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player SetPlaybackSpeed failed.
434 ///
435 /// Available since API-level: 11
436 ///
437 /// Version: 1.0
438 #[cfg(feature = "api-11")]
439 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
440 pub fn OH_AVPlayer_SetPlaybackSpeed(
441 player: *mut OH_AVPlayer,
442 speed: AVPlaybackSpeed,
443 ) -> OH_AVErrCode;
444 /// Sets playback rate.
445 /// Supported states: prepared/playing/paused/completed.
446 ///
447 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
448 /// # Arguments
449 ///
450 /// * `player` - Pointer to OH_AVPlayer instance
451 ///
452 /// * `rate` - Playback rate, valid range is 0.125 ~ 4.
453 ///
454 /// # Returns
455 ///
456 /// * OH_AVErrCode Operation result code
457 /// [`AV_ERR_OK`] if the execution is successful.
458 /// [`AV_ERR_OPERATE_NOT_PERMIT`] if called in unsupported state or during live streaming.
459 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr, or rate is out of range.
460 ///
461 /// Available since API-level: 20
462 #[cfg(feature = "api-20")]
463 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
464 pub fn OH_AVPlayer_SetPlaybackRate(player: *mut OH_AVPlayer, rate: f32) -> OH_AVErrCode;
465 /// get the current player playback rate
466 ///
467 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
468 /// # Arguments
469 ///
470 /// * `player` - Pointer to an OH_AVPlayer instance
471 ///
472 /// * `speed` - the rate mode [`AVPlaybackSpeed`] which can get.
473 ///
474 /// # Returns
475 ///
476 /// * Function result code.
477 /// [`AV_ERR_OK`] if the execution is successful.
478 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player GetPlaybackSpeed failed.
479 ///
480 /// Available since API-level: 11
481 ///
482 /// Version: 1.0
483 #[cfg(feature = "api-11")]
484 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
485 pub fn OH_AVPlayer_GetPlaybackSpeed(
486 player: *mut OH_AVPlayer,
487 speed: *mut AVPlaybackSpeed,
488 ) -> OH_AVErrCode;
489 /// set the bit rate use for hls player
490 ///
491 /// the playback bitrate expressed in bits per second, expressed in bits per second,
492 /// which is only valid for HLS protocol network flow. By default,
493 /// the player will select the appropriate bit rate and speed according to the network connection.
494 /// report the effective bit rate linked list by "INFO_TYPE_BITRATE_COLLECT"
495 /// set and select the specified bit rate, and select the bit rate that is less than and closest
496 /// to the specified bit rate for playback. When ready, read it to query the currently selected bit rate.
497 ///
498 ///
499 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
500 /// # Arguments
501 ///
502 /// * `player` - Pointer to an OH_AVPlayer instance
503 ///
504 /// * `bitRate` - the bit rate, The unit is bps.
505 ///
506 /// # Returns
507 ///
508 /// * Function result code.
509 /// [`AV_ERR_OK`] if the execution is successful.
510 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player SelectBitRate failed.
511 ///
512 /// Available since API-level: 11
513 ///
514 /// Version: 1.0
515 #[cfg(feature = "api-11")]
516 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
517 pub fn OH_AVPlayer_SelectBitRate(player: *mut OH_AVPlayer, bitRate: u32) -> OH_AVErrCode;
518 /// Method to set the surface.
519 ///
520 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
521 /// # Arguments
522 ///
523 /// * `player` - Pointer to an OH_AVPlayer instance
524 ///
525 /// * `window` - A pointer to a OHNativeWindow instance, see [`OHNativeWindow`]
526 ///
527 /// # Returns
528 ///
529 /// * Function result code.
530 /// [`AV_ERR_OK`] if the execution is successful.
531 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr, input window is nullptr,
532 /// or player SetVideoSurface failed.
533 ///
534 /// Available since API-level: 11
535 ///
536 /// Version: 1.0
537 #[cfg(feature = "api-11")]
538 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
539 pub fn OH_AVPlayer_SetVideoSurface(
540 player: *mut OH_AVPlayer,
541 window: *mut OHNativeWindow,
542 ) -> OH_AVErrCode;
543 /// Obtains the total duration of media files, accurate to milliseconds.
544 ///
545 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
546 /// # Arguments
547 ///
548 /// * `player` - Pointer to an OH_AVPlayer instance
549 ///
550 /// * `duration` - Indicates the total duration of media files.
551 ///
552 /// # Returns
553 ///
554 /// * Function result code.
555 /// [`AV_ERR_OK`] if the execution is successful.
556 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player GetDuration failed.
557 ///
558 /// Available since API-level: 11
559 ///
560 /// Version: 1.0
561 #[cfg(feature = "api-11")]
562 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
563 pub fn OH_AVPlayer_GetDuration(player: *mut OH_AVPlayer, duration: *mut i32) -> OH_AVErrCode;
564 /// get current playback state.
565 ///
566 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
567 /// # Arguments
568 ///
569 /// * `player` - Pointer to an OH_AVPlayer instance
570 ///
571 /// * `state` - the current playback state
572 ///
573 /// # Returns
574 ///
575 /// * Function result code.
576 /// [`AV_ERR_OK`] if the execution is successful.
577 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr.
578 ///
579 /// Available since API-level: 11
580 ///
581 /// Version: 1.0
582 #[cfg(feature = "api-11")]
583 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
584 pub fn OH_AVPlayer_GetState(
585 player: *mut OH_AVPlayer,
586 state: *mut AVPlayerState,
587 ) -> OH_AVErrCode;
588 /// Checks whether the player is playing.
589 ///
590 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
591 /// # Arguments
592 ///
593 /// * `player` - Pointer to an OH_AVPlayer instance
594 ///
595 /// # Returns
596 ///
597 /// * Returns true if the playback is playing; Return false if not or input player is nullptr.
598 ///
599 /// Available since API-level: 11
600 ///
601 /// Version: 1.0
602 #[cfg(feature = "api-11")]
603 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
604 pub fn OH_AVPlayer_IsPlaying(player: *mut OH_AVPlayer) -> bool;
605 /// Returns the value whether single looping is enabled or not .
606 ///
607 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
608 /// # Arguments
609 ///
610 /// * `player` - Pointer to an OH_AVPlayer instance
611 ///
612 /// # Returns
613 ///
614 /// * Returns true if the playback is single looping; Return false if not or input player is nullptr.
615 ///
616 /// Available since API-level: 11
617 ///
618 /// Version: 1.0
619 #[cfg(feature = "api-11")]
620 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
621 pub fn OH_AVPlayer_IsLooping(player: *mut OH_AVPlayer) -> bool;
622 /// Enables single looping of the media playback.
623 ///
624 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
625 /// # Arguments
626 ///
627 /// * `player` - Pointer to an OH_AVPlayer instance
628 ///
629 /// * `loop` - The switch to set loop
630 ///
631 /// # Returns
632 ///
633 /// * Function result code.
634 /// [`AV_ERR_OK`] if the execution is successful.
635 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player SetLooping failed.
636 ///
637 /// Available since API-level: 11
638 ///
639 /// Version: 1.0
640 #[cfg(feature = "api-11")]
641 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
642 pub fn OH_AVPlayer_SetLooping(player: *mut OH_AVPlayer, loop_: bool) -> OH_AVErrCode;
643 /// Method to set player callback.
644 ///
645 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
646 /// # Arguments
647 ///
648 /// * `player` - Pointer to an OH_AVPlayer instance
649 ///
650 /// * `callback` - object pointer.
651 ///
652 /// # Returns
653 ///
654 /// * Function result code.
655 /// [`AV_ERR_OK`] if the execution is successful.
656 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr, callback.onInfo or callback.onError is null,
657 /// or player SetPlayerCallback failed.
658 ///
659 /// Available since API-level: 11
660 ///
661 /// **Deprecated** since 12
662 /// [`OH_AVPlayer_SetPlayerOnInfoCallback`] [`OH_AVPlayer_SetPlayerOnErrorCallback`]
663 ///
664 /// Version: 1.0
665 #[cfg(feature = "api-11")]
666 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
667 #[deprecated(since = "12")]
668 pub fn OH_AVPlayer_SetPlayerCallback(
669 player: *mut OH_AVPlayer,
670 callback: AVPlayerCallback,
671 ) -> OH_AVErrCode;
672 /// Select audio or subtitle track.
673 ///
674 /// By default, the first audio stream with data is played, and the subtitle track is not played.
675 /// After the settings take effect, the original track will become invalid. Please set subtitles
676 /// in prepared/playing/paused/completed state and set audio tracks in prepared state.
677 ///
678 ///
679 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
680 /// # Arguments
681 ///
682 /// * `player` - Pointer to an OH_AVPlayer instance
683 ///
684 /// * `index` - Track index
685 ///
686 /// # Returns
687 ///
688 /// * Function result code.
689 /// [`AV_ERR_OK`] if the execution is successful.
690 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player SelectTrack failed.
691 ///
692 /// Available since API-level: 11
693 ///
694 /// Version: 1.0
695 #[cfg(feature = "api-11")]
696 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
697 pub fn OH_AVPlayer_SelectTrack(player: *mut OH_AVPlayer, index: i32) -> OH_AVErrCode;
698 /// Deselect the current audio or subtitle track.
699 ///
700 /// After audio is deselected, the default track will be played, and after subtitles are deselected,
701 /// they will not be played. Please set subtitles in prepared/playing/paused/completed state and set
702 /// audio tracks in prepared state.
703 ///
704 ///
705 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
706 /// # Arguments
707 ///
708 /// * `player` - Pointer to an OH_AVPlayer instance
709 ///
710 /// * `index` - Track index
711 ///
712 /// # Returns
713 ///
714 /// * Function result code.
715 /// [`AV_ERR_OK`] if the execution is successful.
716 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player DeselectTrack failed.
717 ///
718 /// Available since API-level: 11
719 ///
720 /// Version: 1.0
721 #[cfg(feature = "api-11")]
722 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
723 pub fn OH_AVPlayer_DeselectTrack(player: *mut OH_AVPlayer, index: i32) -> OH_AVErrCode;
724 /// Obtain the currently effective track index.
725 ///
726 /// Please get it in the prepared/playing/paused/completed state.
727 ///
728 ///
729 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
730 /// # Arguments
731 ///
732 /// * `player` - Pointer to an OH_AVPlayer instance
733 ///
734 /// * `trackType` - Media type.
735 ///
736 /// * `index` - Track index
737 ///
738 /// # Returns
739 ///
740 /// * Function result code.
741 /// [`AV_ERR_OK`] if the execution is successful.
742 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player GetCurrentTrack failed.
743 ///
744 /// Available since API-level: 11
745 ///
746 /// Version: 1.0
747 #[cfg(feature = "api-11")]
748 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
749 pub fn OH_AVPlayer_GetCurrentTrack(
750 player: *mut OH_AVPlayer,
751 trackType: i32,
752 index: *mut i32,
753 ) -> OH_AVErrCode;
754 /// Method to set player media key system info callback.
755 ///
756 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
757 /// # Arguments
758 ///
759 /// * `player` - Pointer to an OH_AVPlayer instance
760 ///
761 /// * `callback` - object pointer.
762 ///
763 /// # Returns
764 ///
765 /// * Function result code.
766 /// [`AV_ERR_OK`] if the execution is successful.
767 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr, MediaKeySystemInfoCallback is null
768 /// player SetDrmSystemInfoCallback failed, SetDrmSystemInfoCallback failed or SetDrmSystemInfoCallback failed.
769 ///
770 /// Available since API-level: 12
771 ///
772 /// Version: 1.0
773 #[cfg(feature = "api-12")]
774 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
775 pub fn OH_AVPlayer_SetMediaKeySystemInfoCallback(
776 player: *mut OH_AVPlayer,
777 callback: Player_MediaKeySystemInfoCallback,
778 ) -> OH_AVErrCode;
779 /// Obtains media key system info to create media key session.
780 ///
781 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
782 /// # Arguments
783 ///
784 /// * `player` - Pointer to an OH_AVPlayer instance
785 ///
786 /// * `mediaKeySystemInfo` - Media key system info.
787 ///
788 /// # Returns
789 ///
790 /// * Function result code.
791 /// [`AV_ERR_OK`] if the execution is successful.
792 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or no memory.
793 ///
794 /// Available since API-level: 12
795 ///
796 /// Version: 1.0
797 #[cfg(feature = "api-12")]
798 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
799 pub fn OH_AVPlayer_GetMediaKeySystemInfo(
800 player: *mut OH_AVPlayer,
801 mediaKeySystemInfo: *mut DRM_MediaKeySystemInfo,
802 ) -> OH_AVErrCode;
803 /// Set decryption info.
804 ///
805 ///
806 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
807 /// # Arguments
808 ///
809 /// * `player` - Pointer to an OH_AVPlayer instance
810 ///
811 /// * `mediaKeySession` - A media key session instance with decryption function.
812 ///
813 /// * `secureVideoPath` - Require secure decoder or not.
814 ///
815 /// # Returns
816 ///
817 /// * Function result code.
818 /// [`AV_ERR_OK`] if the execution is successful.
819 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or player SetDecryptConfig failed.
820 ///
821 /// Available since API-level: 12
822 ///
823 /// Version: 1.0
824 #[cfg(feature = "api-12")]
825 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
826 pub fn OH_AVPlayer_SetDecryptionConfig(
827 player: *mut OH_AVPlayer,
828 mediaKeySession: *mut MediaKeySession,
829 secureVideoPath: bool,
830 ) -> OH_AVErrCode;
831 /// Method to set player information notify callback.
832 ///
833 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
834 /// # Arguments
835 ///
836 /// * `player` - Pointer to an OH_AVPlayer instance.
837 ///
838 /// * `callback` - Pointer to callback function, nullptr indicates unregister callback.
839 ///
840 /// * `userData` - Pointer to user specific data.
841 ///
842 /// # Returns
843 ///
844 /// * Function result code.
845 /// [`AV_ERR_OK`] if the execution is successful.
846 /// [`AV_ERR_INVALID_VAL`] if input player is null or player SetOnInfoCallback failed.
847 ///
848 /// Available since API-level: 12
849 #[cfg(feature = "api-12")]
850 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
851 pub fn OH_AVPlayer_SetOnInfoCallback(
852 player: *mut OH_AVPlayer,
853 callback: OH_AVPlayerOnInfoCallback,
854 userData: *mut ::core::ffi::c_void,
855 ) -> OH_AVErrCode;
856 /// Method to set player error callback.
857 ///
858 /// Required System Capabilities: SystemCapability.Multimedia.Media.AVPlayer
859 /// # Arguments
860 ///
861 /// * `player` - Pointer to an OH_AVPlayer instance.
862 ///
863 /// * `callback` - Pointer to callback function, nullptr indicates unregister callback.
864 ///
865 /// * `userData` - Pointer to user specific data.
866 ///
867 /// # Returns
868 ///
869 /// * Function result code.
870 /// [`AV_ERR_OK`] if the execution is successful.
871 /// [`AV_ERR_INVALID_VAL`] if input player is null or player SetOnErrorCallback failed.
872 ///
873 /// Available since API-level: 12
874 #[cfg(feature = "api-12")]
875 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
876 pub fn OH_AVPlayer_SetOnErrorCallback(
877 player: *mut OH_AVPlayer,
878 callback: OH_AVPlayerOnErrorCallback,
879 userData: *mut ::core::ffi::c_void,
880 ) -> OH_AVErrCode;
881 /// Sets the loudness gain of current media. The default gain is 0.0 dB.
882 /// This API can be called only when the AVPlayer is in the prepared, playing, paused completed or stopped state.
883 /// The default loudness gain is 0.0dB. The stream usage of the player must be
884 /// [`OH_AudioStream_Usage#AUDIOSTREAM_USAGE_MUSIC`], [`OH_AudioStream_Usage#AUDIOSTREAM_USAGE_MOVIE`]
885 /// or [`OH_AudioStream_Usage#AUDIOSTREAM_USAGE_AUDIOBOOK`].
886 /// The latency mode of the audio renderer must be [`OH_AudioStream_LatencyMode#AUDIOSTREAM_LATENCY_MODE_NORMAL`].
887 /// If AudioRenderer is played through the high-resolution pipe, this operation is not supported.
888 ///
889 /// # Arguments
890 ///
891 /// * `player` - Pointer to an <b>OH_AVPlayer</b> instance.
892 ///
893 /// * `loudnessGain` - Loudness gain to set which changes from -90.0 to 24.0, expressing in dB.
894 ///
895 /// # Returns
896 ///
897 /// * Function result code:
898 /// [`AV_ERR_OK`] If the execution is successful.
899 /// [`AV_ERR_INVALID_VAL`]:The value of <b>player</b> is a null pointer or
900 /// the value of <b>loudnessGain</b> is invalid.
901 /// [`AV_ERR_INVALID_STATE`]: The function is called in an incorrect state. or the stream usage of
902 /// audioRendererInfo is not one of [`StreamUsage#STREAM_USAGE_MUSIC`],
903 /// [`StreamUsage#STREAM_USAGE_MOVIE`] or [`StreamUsage#STREAM_USAGE_AUDIOBOOK`].
904 /// [`AV_ERR_SERVICE_DIED`]: System errors such as media service breakdown.
905 ///
906 /// Available since API-level: 21
907 #[cfg(feature = "api-21")]
908 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
909 pub fn OH_AVPlayer_SetLoudnessGain(player: *mut OH_AVPlayer, loudnessGain: f32)
910 -> OH_AVErrCode;
911 /// Set the media source of the player. The data of this media source is provided by the application.
912 /// # Arguments
913 ///
914 /// {OH_AVPlayer*} player Pointer to an OH_AVPlayer instance
915 ///
916 /// {OH_AVDataSourceExt*} datasrc Pointer to an OH_AVDataSourceExt instance
917 ///
918 /// {void*} userData The handle passed in by the user is used to pass in the callback
919 ///
920 /// # Returns
921 ///
922 /// * Function result code.
923 /// [`AV_ERR_OK`] if the execution is successful.
924 /// [`AV_ERR_INVALID_VAL`] if input player is nullptr or datasrc is nullptr.
925 ///
926 /// Available since API-level: 21
927 #[cfg(feature = "api-21")]
928 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
929 pub fn OH_AVPlayer_SetDataSource(
930 player: *mut OH_AVPlayer,
931 datasrc: *mut OH_AVDataSourceExt,
932 userData: *mut ::core::ffi::c_void,
933 ) -> OH_AVErrCode;
934}