youtubeuibuttonxcode4.2mpmovieplayercontroller

Play icon in a button


How do I get this play arrow in a button? This arrow should look like if you have an website with an embed YouTube video.

Image
(source: iPhoneIncubator.com)


Solution

  • If you're going to be playing YouTube content directly from the app there is some information on how to place a UIWebView to display the content from YouTube. Check out Method #2 which demonstrates the creation of this thumbnail.

    YouTube API Information

    For other video sources, you could set the background color of the button to be a still frame of the video using

    button.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"videoStill.png"]];
    

    Then set the button's image property to a play button with transparency.

    [button setImage:[UIImage imageNamed:@"playButton.png"] forState:UIControlStateNormal];