objc2-media-player 0.3.2

Bindings to the MediaPlayer framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// MPContentItem represents high-level metadata for a particular media item for
    /// representation outside the client application. Examples of media items that a
    /// developer might want to represent include song files, streaming audio URLs,
    /// or radio stations.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaplayer/mpcontentitem?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPContentItem;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MPContentItem {}
);

impl MPContentItem {
    extern_methods!(
        /// Designated initializer. A unique identifier is required to identify the item
        /// for later use.
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier(
            this: Allocated<Self>,
            identifier: &NSString,
        ) -> Retained<Self>;

        /// A unique identifier for this content item. (Required)
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        /// A title for this item. Usually this would be the track name, if representing
        /// a song, the episode name of a podcast, etc.
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub unsafe fn title(&self) -> Option<Retained<NSString>>;

        /// Setter for [`title`][Self::title].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitle(&self, title: Option<&NSString>);

        /// A subtitle for this item. If this were representing a song, this would
        /// usually be the artist or composer.
        #[unsafe(method(subtitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;

        /// Setter for [`subtitle`][Self::subtitle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSubtitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSubtitle(&self, subtitle: Option<&NSString>);

        #[cfg(feature = "MPMediaItem")]
        /// Artwork for this item. Examples of artwork for a content item are the album
        /// cover for a song, or a movie poster for a movie.
        #[unsafe(method(artwork))]
        #[unsafe(method_family = none)]
        pub unsafe fn artwork(&self) -> Option<Retained<MPMediaItemArtwork>>;

        #[cfg(feature = "MPMediaItem")]
        /// Setter for [`artwork`][Self::artwork].
        #[unsafe(method(setArtwork:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setArtwork(&self, artwork: Option<&MPMediaItemArtwork>);

        /// Represents the current playback progress of the item.
        /// 0.0 = not watched/listened/viewed, 1.0 = fully watched/listened/viewed
        /// Default is -1.0 (no progress indicator shown)
        #[unsafe(method(playbackProgress))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackProgress(&self) -> c_float;

        /// Setter for [`playbackProgress`][Self::playbackProgress].
        #[unsafe(method(setPlaybackProgress:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlaybackProgress(&self, playback_progress: c_float);

        /// Represents whether this content item is streaming content, i.e. from the cloud
        /// where the content is not stored locally.
        #[unsafe(method(isStreamingContent))]
        #[unsafe(method_family = none)]
        pub unsafe fn isStreamingContent(&self) -> bool;

        /// Setter for [`isStreamingContent`][Self::isStreamingContent].
        #[unsafe(method(setStreamingContent:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStreamingContent(&self, streaming_content: bool);

        /// Represents whether this content item is explicit content
        #[unsafe(method(isExplicitContent))]
        #[unsafe(method_family = none)]
        pub unsafe fn isExplicitContent(&self) -> bool;

        /// Setter for [`isExplicitContent`][Self::isExplicitContent].
        #[unsafe(method(setExplicitContent:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setExplicitContent(&self, explicit_content: bool);

        /// Represents whether the content item is a container that may contain other
        /// content items, e.g. an album or a playlist.
        #[unsafe(method(isContainer))]
        #[unsafe(method_family = none)]
        pub unsafe fn isContainer(&self) -> bool;

        /// Setter for [`isContainer`][Self::isContainer].
        #[unsafe(method(setContainer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContainer(&self, container: bool);

        /// Represents whether the content item is actionable from a playback
        /// perspective. Albums are playable, for example, because selecting an album
        /// for playback means the app should play each song in the album in order. An
        /// example of a content item that may not be playable is a genre, since an app
        /// experience typically doesn't involve selecting an entire genre for playback.
        #[unsafe(method(isPlayable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPlayable(&self) -> bool;

        /// Setter for [`isPlayable`][Self::isPlayable].
        #[unsafe(method(setPlayable:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlayable(&self, playable: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl MPContentItem {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}