pub struct AVPlayerInterstitialEvent { /* private fields */ }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
impl AVPlayerInterstitialEvent
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn new() -> Retained<Self>
Sourcepub 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: insteadAvailable on crate features AVPlayerItem and objc2-core-media only.
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>
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.
Sourcepub 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: insteadAvailable on crate features AVPlayerItem and objc2-core-media only.
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>
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.
Sourcepub unsafe fn interstitialEventWithPrimaryItem_time(
primary_item: &AVPlayerItem,
time: CMTime,
) -> Retained<Self>
Available on crate features AVPlayerItem and objc2-core-media only.
pub unsafe fn interstitialEventWithPrimaryItem_time( primary_item: &AVPlayerItem, time: CMTime, ) -> Retained<Self>
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.
Sourcepub unsafe fn interstitialEventWithPrimaryItem_date(
primary_item: &AVPlayerItem,
date: &NSDate,
) -> Retained<Self>
Available on crate feature AVPlayerItem only.
pub unsafe fn interstitialEventWithPrimaryItem_date( primary_item: &AVPlayerItem, date: &NSDate, ) -> Retained<Self>
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.
Sourcepub unsafe fn primaryItem(
&self,
mtm: MainThreadMarker,
) -> Option<Retained<AVPlayerItem>>
Available on crate feature AVPlayerItem only.
pub unsafe fn primaryItem( &self, mtm: MainThreadMarker, ) -> Option<Retained<AVPlayerItem>>
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.
Sourcepub unsafe fn identifier(&self) -> Retained<NSString>
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.
Sourcepub unsafe fn time(&self) -> CMTime
Available on crate feature objc2-core-media only.
pub unsafe fn time(&self) -> CMTime
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.
Sourcepub unsafe fn date(&self) -> Option<Retained<NSDate>>
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.
Sourcepub unsafe fn templateItems(
&self,
mtm: MainThreadMarker,
) -> Retained<NSArray<AVPlayerItem>>
Available on crate feature AVPlayerItem only.
pub unsafe fn templateItems( &self, mtm: MainThreadMarker, ) -> Retained<NSArray<AVPlayerItem>>
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.
Sourcepub unsafe fn restrictions(&self) -> AVPlayerInterstitialEventRestrictions
pub unsafe fn restrictions(&self) -> AVPlayerInterstitialEventRestrictions
Indicates restrictions on the use of end user playback controls that are imposed by the event.
Sourcepub unsafe fn resumptionOffset(&self) -> CMTime
Available on crate feature objc2-core-media only.
pub unsafe fn resumptionOffset(&self) -> CMTime
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.
Sourcepub unsafe fn playoutLimit(&self) -> CMTime
Available on crate feature objc2-core-media only.
pub unsafe fn playoutLimit(&self) -> CMTime
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.
Sourcepub unsafe fn alignsStartWithPrimarySegmentBoundary(&self) -> bool
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.
Sourcepub unsafe fn alignsResumptionWithPrimarySegmentBoundary(&self) -> bool
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.
Sourcepub unsafe fn cue(&self) -> Retained<AVPlayerInterstitialEventCue>
pub unsafe fn cue(&self) -> Retained<AVPlayerInterstitialEventCue>
The cue property is used to schedule event playback at a predefined position of primary playback.
Sourcepub unsafe fn willPlayOnce(&self) -> bool
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.
Sourcepub unsafe fn userDefinedAttributes(&self) -> Retained<NSDictionary>
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.
Sourcepub unsafe fn assetListResponse(&self) -> Option<Retained<NSDictionary>>
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.
Sourcepub unsafe fn timelineOccupancy(
&self,
) -> AVPlayerInterstitialEventTimelineOccupancy
pub unsafe fn timelineOccupancy( &self, ) -> AVPlayerInterstitialEventTimelineOccupancy
Indicates this event’s occupancy on AVPlayerItemIntegratedTimeline. The default value is AVPlayerInterstitialEventTimelineSinglePointOccupancy.
Sourcepub unsafe fn supplementsPrimaryContent(&self) -> bool
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.
Sourcepub unsafe fn contentMayVary(&self) -> bool
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.
Sourcepub unsafe fn skipControlTimeRange(&self) -> CMTimeRange
Available on crate feature objc2-core-media only.
pub unsafe fn skipControlTimeRange(&self) -> CMTimeRange
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.
Sourcepub unsafe fn skipControlLocalizedLabelBundleKey(
&self,
) -> Option<Retained<NSString>>
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>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
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());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
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.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
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<AnyObject> for AVPlayerInterstitialEvent
impl AsRef<AnyObject> for AVPlayerInterstitialEvent
Source§impl AsRef<NSObject> for AVPlayerInterstitialEvent
impl AsRef<NSObject> for AVPlayerInterstitialEvent
Source§impl Borrow<AnyObject> for AVPlayerInterstitialEvent
impl Borrow<AnyObject> for AVPlayerInterstitialEvent
Source§impl Borrow<NSObject> for AVPlayerInterstitialEvent
impl Borrow<NSObject> for AVPlayerInterstitialEvent
Source§impl ClassType for AVPlayerInterstitialEvent
impl ClassType for AVPlayerInterstitialEvent
Source§const NAME: &'static str = "AVPlayerInterstitialEvent"
const NAME: &'static str = "AVPlayerInterstitialEvent"
Source§type ThreadKind = <<AVPlayerInterstitialEvent as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<AVPlayerInterstitialEvent as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for AVPlayerInterstitialEvent
impl CopyingHelper for AVPlayerInterstitialEvent
Source§type Result = AVPlayerInterstitialEvent
type Result = AVPlayerInterstitialEvent
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for AVPlayerInterstitialEvent
impl Debug for AVPlayerInterstitialEvent
Source§impl Deref for AVPlayerInterstitialEvent
impl Deref for AVPlayerInterstitialEvent
Source§impl Hash for AVPlayerInterstitialEvent
impl Hash for AVPlayerInterstitialEvent
Source§impl Message for AVPlayerInterstitialEvent
impl Message for AVPlayerInterstitialEvent
Source§impl NSCopying for AVPlayerInterstitialEvent
impl NSCopying for AVPlayerInterstitialEvent
Source§impl NSObjectProtocol for AVPlayerInterstitialEvent
impl NSObjectProtocol for AVPlayerInterstitialEvent
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref