Giter Club home page Giter Club logo

youtubeplayer's Introduction

Embedded Youtube Video Player - (Objective-C)

This a simple youtube player which includes the Youtube helper api to get the most of it. The intention is to help some developers in the use of their framework.

Preview in Portrait Mode

screenshot-1

Preview in Portrait Landscape

screenshot-1

Screenshots in Portrait Mode

screenshot-1 screenshot-2 screenshot-3

Screenshots in Landscape Mode

screenshot-4 screenshot-5

Usage

  • Download the zip file and extract it. Then add the YoutubeHelper folder to your project.

  • After these folder have been added to the project (remember to select copy file if necessary when adding to the project) you can start using this helper library, it's really simple...

  • Create a player property.

@property (nonatomic, strong) YTPlayerView *player;
  • Set the player frame.
// setting up the player
self.player = [[YTPlayerView alloc] initWithFrame:CGRectMake(0, 50, 320, 350)];
  • Then, you can load a playlist, multiple videos, a simple video or even using the video url like.
// loading multiple videos from url
NSArray *videosUrl = @[@"https://www.youtube.com/watch?v=Zv1QV6lrc_Y", @"https://www.youtube.com/watch?v=NVGEMZ_1ETs"];
[self.player loadPlayerWithVideosURL:videosUrl];

// loading a video by URL
[self.player loadPlayerWithVideoURL:@"https://www.youtube.com/watch?v=mIAgmyoAmmc"];

// loading videoId 
[self.player loadPlayerWithVideoId:@"O8TiugM6Jg"];

// loading a set of videos to the player
NSArray *videoList = @[@"m2d0ID-V9So", @"c7lNU4IPYlk"];
[self.player loadPlayerWithVideosId:videoList];

// loading playlist
[self.player loadWithPlaylistId:@"PLEE58C6029A8A6ADE"];
  • Optional, you can load the video/playlist with some parameters to customize the youtube player.
// first create your dictionary to set the different parameters
@property (nonatomic, strong) NSDictionary *dictionary;

// setting up player parameters
self.dictionary = @{@"listType" : @"playlist",
                    @"autoplay" : @"1",
                    @"loop" : @"1",
                    @"playsinline" : @"0",
                    @"controls" : @"2",
                    @"cc_load_policy" : @"0",};
    
// loading playlist with player paramaters
[self.player loadWithPlaylistId:@"PLEE58C6029A8A6ADE" playerVars:self.dictionary];

// ******** OR **********

// use some customs parameters which will be load to the video like this.. (just for simplicity)
self.player.autoplay = YES;
self.player.modestbranding = YES;
 
// and then just call load the playlist/video
[self.player loadWithPlaylistId:@"PLEE58C6029A8A6ADE"];
  • Finally, add the player to your view and Done!
// adding player to view
[self.view addSubview:self.player];
  • Extra, Some helper functions were added to the project that you might want to use (just set the variable before loading the video) as...
// allows landscape mode 
self.player.allowLandscapeMode = YES;

// force to go back to portrait when exit fullscreen (this requires extra settings)
self.player.forceBackToPortraitMode = YES; 

// for forcing the portrait mode and allowing landscape you need to do this in your AppDelegate

// this in your AppDelegate.h
@property (nonatomic) BOOL videoIsInFullscreen;

// and this in your AppDelegate.m
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    if(self.videoIsInFullscreen == YES) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    else {
        return UIInterfaceOrientationMaskPortrait;
    }
}

DONE!

If you wish to help and improve this library, please fee free to create your own brach and submit your improvement. It will go under review and then added to the project if it's accepted.

Authors and Contributors

Just myself @jv17, I decided to create a simple youtube player for others who are interested in something simple and easy to use.

Support or Contact

Check out my website http://jorgedeveloper.com or contact [email protected] and I will be happy to help you.

youtubeplayer's People

Contributors

jv17 avatar jvdev17 avatar

Watchers

none-p avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.