/***
 * Excerpted from "Developing for Apple Watch",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/jkwatch for more book information.
***/
//
//  ViewController.m
//  WatchMediaPlayback
//
//  Created by Jeff Kelley on 5/8/15.
//  Copyright (c) 2015 Pragmatic Bookshelf. All rights reserved.
//

@import MediaPlayer;

#import "ViewController.h"

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter];
    
    infoCenter.nowPlayingInfo =
    @{
      MPMediaItemPropertyArtist: @"Rick Astley",
      MPMediaItemPropertyTitle: @"Never Gonna Give You Up",
      MPMediaItemPropertyPlaybackDuration: @211.0,
      MPMediaItemPropertyAlbumTitle: @"Rick Astley: The Greatest Hits",
      MPMediaItemPropertyAlbumTrackCount: @17,
      MPMediaItemPropertyAlbumTrackNumber: @0,
      MPMediaItemPropertyGenre: @"Pop"
      };
    
    MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    
    [commandCenter.playCommand addTargetWithHandler:
     ^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) {
         [self play];
         
         return MPRemoteCommandHandlerStatusSuccess;
     }];
}

- (void)play
{
    // Play code here
}

@end
