Skip to content

Commit

Permalink
More on av::Player
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed May 5, 2023
1 parent c6160b4 commit d4bb1d3
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cidre/src/av/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ extern "C" {
static AV_PLAYER: &'static objc::Class<Player>;
}

impl ns::NotificationName {
pub fn av_player_rate_did_change() -> &'static ns::NotificationName {
unsafe { AVPlayerRateDidChangeNotification }
}
}

#[link(name = "AVFoundation", kind = "framework")]
extern "C" {
static AVPlayerRateDidChangeNotification: &'static ns::NotificationName;
}

#[cfg(test)]
mod tests {
use crate::{av, ns};
Expand Down
85 changes: 85 additions & 0 deletions cidre/src/av/player/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,88 @@ pub enum Status {
}

define_obj_type!(Item(ns::Id));

impl ns::NotificationName {
/// A notification the system posts when a player item’s time changes discontinuously.
///
/// The notification’s object is the player item.
///
/// The system may post this notification on a thread other than the one you use to register the observer.
pub fn av_player_item_time_jumped() -> &'static Self {
unsafe { AVPlayerItemTimeJumpedNotification }
}

/// A notification the system posts when a player item plays to its end time.
///
/// The notification’s object is the item that finished playing.
///
/// The system may post this notification on a thread other than the one you use to register the observer.
pub fn av_player_item_did_play_to_end_time() -> &'static Self {
unsafe { AVPlayerItemDidPlayToEndTimeNotification }
}

/// A notification that the system posts when a player item fails to play to its end time.
///
/// The notification’s object is the player item that finished playing.
///
/// The system may post this notification on a thread other than the one you use to register the observer.
pub fn av_player_item_failed_play_to_end_time() -> &'static Self {
unsafe { AVPlayerItemFailedToPlayToEndTimeNotification }
}

/// A notification the system posts when a player item media doesn’t arrive in time to continue playback.
///
/// The notification’s object is the player item whose playback is unable to continue due to network delays.
/// Streaming-media playback continues after the player item retrieves a sufficient amount of data.
/// File-based playback doesn’t continue.
///
/// # Important
/// The system may post this notification on a thread other than the one you use to register the observer.
pub fn av_player_item_playback_stalled() -> &'static Self {
unsafe { AVPlayerItemPlaybackStalledNotification }
}

/// A notification the system posts when a player item adds a new entry to its access log.
///
/// The notification’s object is the player item.
///
/// # Important
/// The system may post this notification on a thread other than the one you use to register the observer.
pub fn av_player_item_new_access_log_entry() -> &'static Self {
unsafe { AVPlayerItemNewAccessLogEntryNotification }
}

/// A notification the system posts when a player item adds a new entry to its error log.
///
/// The notification’s object is the player item
///
/// The system may post this notification on a thread other than the one you use to register the observer.
pub fn av_player_item_error_access_log_entry() -> &'static Self {
unsafe { AVPlayerItemNewErrorLogEntryNotification }
}

/// A notification the player item posts when its offset from the live time changes.
///
/// Register to observe notifications of this type to observe changes to the value of the recommended_time_offset_from_live property
pub fn av_player_item_recommended_time_offset_from_live_did_change() -> &'static Self {
unsafe { AVPlayerItemRecommendedTimeOffsetFromLiveDidChangeNotification }
}

/// A notification the player item posts when its media selection changes.
pub fn av_player_item_media_selection_did_change() -> &'static Self {
unsafe { AVPlayerItemMediaSelectionDidChangeNotification }
}
}

#[link(name = "AVFoundation", kind = "framework")]
extern "C" {
static AVPlayerItemTimeJumpedNotification: &'static ns::NotificationName;
static AVPlayerItemDidPlayToEndTimeNotification: &'static ns::NotificationName;
static AVPlayerItemFailedToPlayToEndTimeNotification: &'static ns::NotificationName;
static AVPlayerItemPlaybackStalledNotification: &'static ns::NotificationName;
static AVPlayerItemNewAccessLogEntryNotification: &'static ns::NotificationName;
static AVPlayerItemNewErrorLogEntryNotification: &'static ns::NotificationName;
static AVPlayerItemRecommendedTimeOffsetFromLiveDidChangeNotification:
&'static ns::NotificationName;
static AVPlayerItemMediaSelectionDidChangeNotification: &'static ns::NotificationName;
}

0 comments on commit d4bb1d3

Please sign in to comment.