AVPlayerInterstitialEvent

Struct AVPlayerInterstitialEvent 

Source
pub struct AVPlayerInterstitialEvent { /* private fields */ }
Available on crate feature AVPlayerInterstitialEventController only.
Expand description

An AVPlayerInterstitialEvent provides instructions for temporarily suspending the playback of primary content in order to play alternative interstitial content instead, resuming playback of the primary content when playback of the interstitial content is complete or is canceled.

The primary content is specified as an instance of AVPlayerItem, designated as the primary item of the interstitial event.

The timing of interstitial playback is specified as a date within the date range of the primary item. Interstitial events are currently possible only for items with an intrinsic mapping from their timeline to real-time dates.

The alternative interstitial content is specified as an array of one or more AVPlayerItems that will be used as templates for the creation of items for interstitial playback. In other words, these template items are not the actual items that will be played during interstitial playback; instead they are used to generate the items that are to be played, with property values that match the configuration of your template items.

If you wish to observe the scheduling and progress of interstitial events, use an AVPlayerInterstitialEventMonitor. If you wish to specify your own schedule of interstitial events, use an AVPlayerInterstitialEventController.

Note that while previously AVPlayerInterstitialEvent was an immutable object, it is now mutable. This allows it to be created and customized before being set on an AVPlayerInterstitialEventController.

See also Apple’s documentation

Implementations§

Source§

impl AVPlayerInterstitialEvent

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

Source

pub unsafe fn new() -> Retained<Self>

Source

pub unsafe fn interstitialEventWithPrimaryItem_identifier_time_templateItems_restrictions_resumptionOffset_playoutLimit_userDefinedAttributes( primary_item: &AVPlayerItem, identifier: Option<&NSString>, time: CMTime, template_items: &NSArray<AVPlayerItem>, restrictions: AVPlayerInterstitialEventRestrictions, resumption_offset: CMTime, playout_limit: CMTime, user_defined_attributes: Option<&NSDictionary>, ) -> Retained<Self>

👎Deprecated: Use interstitialEventWithPrimaryItem:time: instead
Available on crate features AVPlayerItem and objc2-core-media only.

Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.

  • Parameter primaryItem: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.

  • Parameter identifier: An external identifier for the event.

  • Parameter time: The time within the duration of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.

  • Parameter templateItems: An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content. An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.

  • Parameter restrictions: Indicates restrictions on the use of end user playback controls that are imposed by the event.

  • Parameter resumptionOffset: Specifies the offset in time at which playback of the primary item should resume after interstitial playback has finished. Definite numeric values are supported. The value kCMTimeIndefinite can also be used, in order to specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback.

  • Parameter playoutLimit: Specifies the offset from the beginning of the interstitial at which interstitial playback should end, if the interstitial asset(s) are longer. Pass a positive numeric value, or kCMTimeInvalid to indicate no playout limit.

  • Parameter userDefinedAttributes: Storage for attributes defined by the client or the content vendor. Attribute names should begin with X- for uniformity with server insertion.

  • Returns: An instance of AVPlayerInterstitialEvent.

§Safety

user_defined_attributes generic should be of the correct type.

Source

pub unsafe fn interstitialEventWithPrimaryItem_identifier_date_templateItems_restrictions_resumptionOffset_playoutLimit_userDefinedAttributes( primary_item: &AVPlayerItem, identifier: Option<&NSString>, date: &NSDate, template_items: &NSArray<AVPlayerItem>, restrictions: AVPlayerInterstitialEventRestrictions, resumption_offset: CMTime, playout_limit: CMTime, user_defined_attributes: Option<&NSDictionary>, ) -> Retained<Self>

👎Deprecated: Use interstitialEventWithPrimaryItem:date: instead
Available on crate features AVPlayerItem and objc2-core-media only.

Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.

  • Parameter primaryItem: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.

  • Parameter identifier: An external identifier for the event.

  • Parameter date: The date within the date range of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.

  • Parameter templateItems: An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content. An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.

  • Parameter restrictions: Indicates restrictions on the use of end user playback controls that are imposed by the event.

  • Parameter resumptionOffset: Specifies the offset in time at which playback of the primary item should resume after interstitial playback has finished. Definite numeric values are supported. The value kCMTimeIndefinite can also be used, in order to specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback.

  • Parameter playoutLimit: Specifies the offset from the beginning of the interstitial at which interstitial playback should end, if the interstitial asset(s) are longer. Pass a positive numeric value, or kCMTimeInvalid to indicate no playout limit.

  • Parameter userDefinedAttributes: Storage for attributes defined by the client or the content vendor. Attribute names should begin with X- for uniformity with server insertion.

  • Returns: An instance of AVPlayerInterstitialEvent.

§Safety

user_defined_attributes generic should be of the correct type.

Source

pub unsafe fn interstitialEventWithPrimaryItem_time( primary_item: &AVPlayerItem, time: CMTime, ) -> Retained<Self>

Available on crate features AVPlayerItem and objc2-core-media only.

Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.

  • Parameter primaryItem: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.

  • Parameter time: The time within the duration of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.

  • Returns: An instance of AVPlayerInterstitialEvent.

Source

pub unsafe fn interstitialEventWithPrimaryItem_date( primary_item: &AVPlayerItem, date: &NSDate, ) -> Retained<Self>

Available on crate feature AVPlayerItem only.

Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.

  • Parameter primaryItem: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.

  • Parameter date: The date within the date range of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.

  • Returns: An instance of AVPlayerInterstitialEvent.

Source

pub unsafe fn primaryItem( &self, mtm: MainThreadMarker, ) -> Option<Retained<AVPlayerItem>>

Available on crate feature AVPlayerItem only.

An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.

Source

pub unsafe fn identifier(&self) -> Retained<NSString>

An external identifier for the event.

If an event is set on an AVPlayerInterstitialEventController that already has an event with the same identifier, the old event will be replaced by the new one.

Source

pub unsafe fn time(&self) -> CMTime

Available on crate feature objc2-core-media only.

The time within the duration of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.

Will have a value equal to kCMTimeInvalid if the event was initialized with a date instead of a time.

Source

pub unsafe fn date(&self) -> Option<Retained<NSDate>>

The date within the date range of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.

Will have a value of nil if the event was initialized with a time instead of a date.

Source

pub unsafe fn templateItems( &self, mtm: MainThreadMarker, ) -> Retained<NSArray<AVPlayerItem>>

Available on crate feature AVPlayerItem only.

An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content.

If you want the instances of AVURLAsset used during interstitial playback to be identical to the ones you specify for templateItems in AVPlayerInterstitialEvents that you set on an AVPlayerInterstitialEventController, rather than equivalent AVURLAssets with the same URL, you must create them with a value for the key AVURLAssetPrimarySessionIdentifierKey that’s equal to the httpSessionIdentifier of the primary AVPlayerItem’s asset. See AVAsset.h. This is especially useful if you require the use of a custom AVAssetResourceLoader delegate for interstitial assets.

An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.

Source

pub unsafe fn restrictions(&self) -> AVPlayerInterstitialEventRestrictions

Indicates restrictions on the use of end user playback controls that are imposed by the event.

Source

pub unsafe fn resumptionOffset(&self) -> CMTime

Available on crate feature objc2-core-media only.

Specifies the offset in time at which playback of the primary item should resume after interstitial playback has finished.

Definite numeric values are supported. The value kCMTimeIndefinite can also be used, in order to specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback; this value is typically suitable for live broadcasts. The default value is kCMTimeZero.

Source

pub unsafe fn playoutLimit(&self) -> CMTime

Available on crate feature objc2-core-media only.

Specifies the offset in time at which playback of the interstitial event should end.

Can be any positive numeric value, or invalid. The default value is kCMTimeInvalid, which means there is no limit.

Source

pub unsafe fn alignsStartWithPrimarySegmentBoundary(&self) -> bool

Specifies that the start time of interstitial playback should be snapped to a segment boundary of the primary asset

If true, the start time or date of the interstitial will be adjusted to the nearest segment boundary when the primary player is playing an HTTP Live Streaming asset.

Source

pub unsafe fn alignsResumptionWithPrimarySegmentBoundary(&self) -> bool

Specifies that the resumption time of primary playback should be snapped to a segment boundary of the primary asset

If true, the resumption time of primary playback following an interstitial will be adjusted to the nearest segment boundary when the primary player is playing an HTTP Live Streaming asset.

Source

pub unsafe fn cue(&self) -> Retained<AVPlayerInterstitialEventCue>

The cue property is used to schedule event playback at a predefined position of primary playback.

Source

pub unsafe fn willPlayOnce(&self) -> bool

Specifies that the interstitial should be scheduled for playback once only, and suppressed for subsequent replay.

The “once” provision takes effect at the start of interstitial playback. The interstitial will not be scheduled again even if the first playback is canceled before completion.

Source

pub unsafe fn userDefinedAttributes(&self) -> Retained<NSDictionary>

Attributes of the event defined by the content vendor or the client.

Dictionary keys are attribute names. Dictionary values are attribute values.

Source

pub unsafe fn assetListResponse(&self) -> Option<Retained<NSDictionary>>

The asset list JSON response as a dictionary, or nil if no asset list response has been loaded for the event.

If the AVPlayerInterstitialEvent’s templateItems is empty and the assetListResponse is nil, then an asset list read is expected. If the AVPlayerInterstitialEvent’s templateItems is not empty and the assetListResponse is nil, then an asset list read is not expected.

Source

pub unsafe fn timelineOccupancy( &self, ) -> AVPlayerInterstitialEventTimelineOccupancy

Indicates this event’s occupancy on AVPlayerItemIntegratedTimeline. The default value is AVPlayerInterstitialEventTimelineSinglePointOccupancy.

Source

pub unsafe fn supplementsPrimaryContent(&self) -> bool

Indicates this event will supplement the primary content and should be presented unified with the primary item. The default value is NO.

Source

pub unsafe fn contentMayVary(&self) -> bool

Indicates this event’s content is dynamic and server may respond with different interstitial assets for other particpants in coordinated playback.

Indicates this event’s content is dynamic and server may respond with different interstitial assets for other particpants in coordinated playback. If this value is set to NO and the primary asset is particpating in coordinated playback, this event will participate in coordinated playback as well. The default value is YES.

Source

pub unsafe fn skipControlTimeRange(&self) -> CMTimeRange

Available on crate feature objc2-core-media only.

The time range within the duration of the interstitial event for which a skip button should be displayed.

The start of the time range should indicate at which point the skip button should appear. The duration of the time range should indicate how long the skip button should be available. If this value is set to kCMTimePositiveInfinity, then the skip button will be available for the remainder of the interstitial’s duration after appearing. If either the start or duration of the time range is kCMTimeInvalid, then the interstitial will NOT be eligible to be skipped.

Source

pub unsafe fn skipControlLocalizedLabelBundleKey( &self, ) -> Option<Retained<NSString>>

The key defined in the AVPlayerInterstitialEventController’s localizedStringsBundle that points to the localized label for the skip button.

If the value of the property is nil, the skip button may contain a generic label depending on the implementation of the UI that’s in use. To ensure the best available user experience in various playback configurations, including external playback, set a value for this property that provides localized translations of skip control labels.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

pub fn class(&self) -> &'static AnyClass

Dynamically find the class of this object.

§Panics

May panic if the object is invalid (which may be the case for objects returned from unavailable init/new methods).

§Example

Check that an instance of NSObject has the precise class NSObject.

use objc2::ClassType;
use objc2::runtime::NSObject;

let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use Ivar::load instead.

Use Ivar::load instead.

§Safety

The object must have an instance variable with the given name, and it must be of type T.

See Ivar::load_ptr for details surrounding this.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: DowncastTarget,

Attempt to downcast the object to a class of type T.

This is the reference-variant. Use Retained::downcast if you want to convert a retained object to another type.

§Mutable classes

Some classes have immutable and mutable variants, such as NSString and NSMutableString.

When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.

So using this method to convert a NSString to a NSMutableString, while not unsound, is generally frowned upon unless you created the string yourself, or the API explicitly documents the string to be mutable.

See Apple’s documentation on mutability and on isKindOfClass: for more details.

§Generic classes

Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.

You can, however, safely downcast to generic collections where all the type-parameters are AnyObject.

§Panics

This works internally by calling isKindOfClass:. That means that the object must have the instance method of that name, and an exception will be thrown (if CoreFoundation is linked) or the process will abort if that is not the case. In the vast majority of cases, you don’t need to worry about this, since both root objects NSObject and NSProxy implement this method.

§Examples

Cast an NSString back and forth from NSObject.

use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};

let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();

Try (and fail) to cast an NSObject to an NSString.

use objc2_foundation::{NSObject, NSString};

let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());

Try to cast to an array of strings.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();

This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.

Downcast when processing each element instead.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);

for elem in arr {
    if let Some(data) = elem.downcast_ref::<NSString>() {
        // handle `data`
    }
}

Trait Implementations§

Source§

impl AsRef<AVPlayerInterstitialEvent> for AVPlayerInterstitialEvent

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<AnyObject> for AVPlayerInterstitialEvent

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSObject> for AVPlayerInterstitialEvent

Source§

fn as_ref(&self) -> &NSObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for AVPlayerInterstitialEvent

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for AVPlayerInterstitialEvent

Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for AVPlayerInterstitialEvent

Source§

const NAME: &'static str = "AVPlayerInterstitialEvent"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = NSObject

The superclass of this class. Read more
Source§

type ThreadKind = <<AVPlayerInterstitialEvent as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl CopyingHelper for AVPlayerInterstitialEvent

Source§

type Result = AVPlayerInterstitialEvent

The immutable counterpart of the type, or Self if the type has no immutable counterpart. Read more
Source§

impl Debug for AVPlayerInterstitialEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for AVPlayerInterstitialEvent

Source§

type Target = NSObject

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for AVPlayerInterstitialEvent

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for AVPlayerInterstitialEvent

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl NSCopying for AVPlayerInterstitialEvent

Source§

fn copy(&self) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

impl NSObjectProtocol for AVPlayerInterstitialEvent

Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl PartialEq for AVPlayerInterstitialEvent

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for AVPlayerInterstitialEvent

Source§

const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl DowncastTarget for AVPlayerInterstitialEvent

Source§

impl Eq for AVPlayerInterstitialEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T> AnyThread for T
where T: ClassType<ThreadKind = dyn AnyThread + 'a> + ?Sized,

Source§

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,