iOS Developer Library

Developer

AVFoundation Framework Reference AVQueuePlayer Class Reference

Options
Deployment Target:

On This Page
Language:

AVQueuePlayer

Inherits From


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.1 and later

AVQueuePlayer is a subclass of AVPlayer you use to play a number of items in sequence.

  • Initializes an instance of AVQueuePlayer by enqueueing the player items from a given array.

    Declaration

    Swift

    init!(items items: [AnyObject]!)

    Objective-C

    - (instancetype)initWithItems:(NSArray *)items

    Parameters

    items

    An array of AVPlayerItem objects with which initially to populate the player’s queue.

    Return Value

    An instance of AVQueuePlayer initialized to play the player items in items.

    Discussion

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Returns an instance of AVQueuePlayer initialized to play items from a given array.

    Declaration

    Swift

    class func queuePlayerWithItems(_ items: [AnyObject]!) -> AnyObject!

    Objective-C

    + (id)queuePlayerWithItems:(NSArray *)items

    Parameters

    items

    An array of AVPlayerItem objects with which initially to populate the player’s queue.

    Return Value

    An instance of AVQueuePlayer initialized to play the player items in items.

    Discussion

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Ends playback of the current item and initiates playback of the next item in the player’s queue.

    Declaration

    Swift

    func advanceToNextItem()

    Objective-C

    - (void)advanceToNextItem

    Discussion

    This method also removes the current item from the play queue.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Returns a Boolean value that indicates whether a given player item can be inserted into the player’s queue.

    Declaration

    Swift

    func canInsertItem(_ item: AVPlayerItem!, afterItem afterItem: AVPlayerItem!) -> Bool

    Objective-C

    - (BOOL)canInsertItem:(AVPlayerItem *)item afterItem:(AVPlayerItem *)afterItem

    Parameters

    item

    The AVPlayerItem object to test.

    afterItem

    The item that item is to follow in the queue. Pass nil to test whether item can be appended to the queue.

    Return Value

    YEStrue if item can be appended to the queue, otherwise NOfalse.

    Discussion

    Adding the same item to a player at more than one position in the queue is not supported.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Places given player item after a specified item in the queue.

    Declaration

    Swift

    func insertItem(_ item: AVPlayerItem!, afterItem afterItem: AVPlayerItem!)

    Objective-C

    - (void)insertItem:(AVPlayerItem *)item afterItem:(AVPlayerItem *)afterItem

    Parameters

    item

    The item to be inserted.

    afterItem

    The item that the newly inserted item should follow in the queue. Pass nil to append the item to the queue.

    Discussion

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Returns an array of the currently enqueued items.

    Declaration

    Swift

    func items() -> [AnyObject]!

    Objective-C

    - (NSArray *)items

    Return Value

    An array of the currently enqueued items

    Discussion

    The array contains AVPlayerItem objects

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Removes all the items from the queue.

    Declaration

    Swift

    func removeAllItems()

    Objective-C

    - (void)removeAllItems

    Discussion

    This has the side-effect of stopping playback by the player.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • Removes a given player item from the queue.

    Declaration

    Swift

    func removeItem(_ item: AVPlayerItem!)

    Objective-C

    - (void)removeItem:(AVPlayerItem *)item

    Parameters

    item

    The item to be removed.

    Discussion

    If item is currently playing, this has the same effect as advanceToNextItem.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later