IS2Media Class Reference

Inherits from NSObject
Declared in IS2Media.h

Overview

IS2Media is used to access all media related data and functions. Whilst not everything available in terms of media controlling is found here, the contained methods are the most commonly used.

Setup

+ registerForNowPlayingNotificationsWithIdentifier:andCallback:

Sets a block to be called whenever music data changes. The identifier must be unique string; it is recommended to use reverse DNS notation, such as “com.foo.bar”.

+ (void)registerForNowPlayingNotificationsWithIdentifier:(NSString *)identifier andCallback:(void ( ^ ) ( void ))callbackBlock

Parameters

identifier

The identifier associated with your callback

callbackBlock

The block to call once data changes

Declared In

IS2Media.h

+ unregisterForNotificationsWithIdentifier:

The inverse of registering for notifications. This must be called when your code is unloaded, else gremlins will squirm their way into your device.

+ (void)unregisterForNotificationsWithIdentifier:(NSString *)identifier

Parameters

identifier

The identifier associated with your callback

Declared In

IS2Media.h

+ registerForTimeInformationWithIdentifier:andCallback:

Sets a block to be called whenever the current position in the track changes. The identifier must be unique string; it is recommended to use reverse DNS notation, such as “com.foo.bar”.

+ (void)registerForTimeInformationWithIdentifier:(NSString *)identifier andCallback:(void ( ^ ) ( void ))callbackBlock

Parameters

identifier

The identifier associated with your callback

callbackBlock

The block to call once data changes

Declared In

IS2Media.h

+ unregisterForTimeInformationWithIdentifier:

The inverse of registering for notifications. This must be called when your code is unloaded.

+ (void)unregisterForTimeInformationWithIdentifier:(NSString *)identifier

Parameters

identifier

The identifier associated with your callback

Declared In

IS2Media.h

Functions

+ skipToNextTrack

Jumps to the next track. If no track is left in the queue, then this function will instead stop playing media.

+ (void)skipToNextTrack

Declared In

IS2Media.h

+ skipToPreviousTrack

Jumps to the previous track. If no track was played beforehand, this function will then stop playing media.

+ (void)skipToPreviousTrack

Declared In

IS2Media.h

+ togglePlayPause

Toggles the playing state of the currently playing media.

+ (void)togglePlayPause

Declared In

IS2Media.h

+ play

Changes the currently media state to playing. If already playing, this does nothing.

+ (void)play

Declared In

IS2Media.h

+ pause

Changes the currently media state to paused. If already paused, this does nothing.

+ (void)pause

Declared In

IS2Media.h

+ setVolume:withVolumeHUD:

Changes the current volume for media audio, not for other audio sources like the Ringer.

+ (void)setVolume:(CGFloat)level withVolumeHUD:(BOOL)useHud

Parameters

level

The volume level, between 0.0 and 1.0

useHud

Whether to display the volume HUD when adjusting the level

Declared In

IS2Media.h

Data Retrieval

+ currentTrackTitle

Gives the title for the currently play track, with an auto-translated string for if no media is playing.

+ (NSString *)currentTrackTitle

Return Value

The current track’s title, or translated “No media playing”

Declared In

IS2Media.h

+ currentTrackArtist

This function gives the artist name for the current track. If the user is playing a video via Safari, or another such application, then this value may be NULL since there may not be appropriate metadata value available.

+ (NSString *)currentTrackArtist

Return Value

The current track’s artist.

Declared In

IS2Media.h

+ currentTrackAlbum

Gives the album for the current track. Please see currentTrackArtist for when a video is played.

+ (NSString *)currentTrackAlbum

Return Value

The current track’s album

Declared In

IS2Media.h

+ currentTrackArtwork

Initializes an `UIImage' object with the current album artwork data.

+ (UIImage *)currentTrackArtwork

Return Value

The current track’s artwork image

Declared In

IS2Media.h

+ currentTrackArtworkBase64

Initializes a string with the current album artwork data as base64.

+ (NSString *)currentTrackArtworkBase64

Return Value

The current track’s artwork image as base64

Declared In

IS2Media.h

+ currentTrackLength

Gives the current track’s length, which measured in seconds.

+ (double)currentTrackLength

Return Value

The current track’s length

Declared In

IS2Media.h

+ elapsedTrackLength

Gives the position in the current track that has been played to, which measured in seconds.

+ (double)elapsedTrackLength

Return Value

The current track’s elapsed time

Declared In

IS2Media.h

+ trackNumber

Gives the current track number for the currently playing music track. For videos, this value is likely to be 0.

+ (int)trackNumber

Return Value

The current track’s number in its album

Declared In

IS2Media.h

+ totalTrackCount

Finds the amount of tracks in the album the current track is playing from. For videos, this value is likely to be 0.

+ (int)totalTrackCount

Return Value

The number of available tracks in the current track’s containing album

Declared In

IS2Media.h

+ currentPlayingAppIdentifier

Retrieves the bundle indentifier of the currently playing application.

+ (NSString *)currentPlayingAppIdentifier

Return Value

Current now playing app’s bundle ID (eg, com.apple.Music)

Declared In

IS2Media.h

+ shuffleEnabled

A boolean specifying whether shuffle mode is currently enabled.

+ (BOOL)shuffleEnabled

Return Value

The state of shuffle mode

Declared In

IS2Media.h

+ iTunesRadioPlaying

A boolean specifying if media is currently being played via iTunes Radio.

+ (BOOL)iTunesRadioPlaying

Return Value

Whether the current track is being played from iTunes Radio

Declared In

IS2Media.h

+ isPlaying

A boolean specifying if media is playing or not.

+ (BOOL)isPlaying

Return Value

Whether media is playing or not

Declared In

IS2Media.h

+ hasMedia

A boolean specifying whether there is a currently a track available to play.

For example, this will be NO if music has stopped playing, such as after an album finishes.

+ (BOOL)hasMedia

Return Value

Whether a track is available

Declared In

IS2Media.h

+ getVolume

The current volume for media. Note that this will not return volume for the Ringer, or for anything else other than media audio.

+ (CGFloat)getVolume

Return Value

Current media volume

Declared In

IS2Media.h