Embedded YouTube Video in Landscape

Discussion in 'iOS Programming' started by RagingGoat, Nov 14, 2012.

  1. RagingGoat macrumors 6502

    Joined:
    Jun 21, 2010
    #1
    I have an app that is locked into portrait orientation but I have an embedded YouTube video that I want to play in landscape when the user hits play on the thumbnail. Can anyone help me out with this? Maybe point me in the right direction?

    Code:
    //
    //  YouTubeView.h
    //  KFBNewsroom
    //
    //  Created by KFB on 11/8/12.
    //  Copyright (c) 2012 com.kfb. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface YouTubeView : UIViewController
    {
        IBOutlet UIWebView *thumbnailView;
    }
    @property (nonatomic, retain) IBOutlet UIWebView *thumbnailView;
    
    @end
    
    Code:
    //
    //  YouTubeView.m
    //  KFBNewsroom
    //
    //  Created by KFB on 11/8/12.
    //  Copyright (c) 2012 com.kfb. All rights reserved.
    //
    
    #import "YouTubeView.h"
    
    @interface YouTubeView ()
    
    @end
    
    @implementation YouTubeView
    @synthesize thumbnailView;
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.title = @"Monthly Video";
        // Do any additional setup after loading the view from its nib.
        // webView is a UIWebView, either initialized programmatically or loaded as part of a xib.
        
        NSString *htmlString = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 280\"/></head><body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"280\" height=\"218\"><param name=\"movie\" value=\"http://www.youtube.com/embed/videoseries?list=PL0B9BF37A24840E28&hl=en_US""></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/embed/videoseries?list=PL0B9BF37A24840E28&hl=en_US""type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"280\" height=\"218\"></embed></object></div></body></html>";
        
        [thumbnailView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.youtube.com/playlist?list=PL0B9BF37A24840E28&feature=plcp"]];
    
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
    
     
  2. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
  4. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
    #5
    I've started looking at it but haven't gotten through it yet.
     

Share This Page