Drag and drop
YTPlayerView-iframe-player.html
YTPlayerView.h
YTPlayerView.m
files in your project.
Add bridging header and use this:
#import "YTPlayerView.h"
Go to YTPlayerView.m file :
Find :
NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
ofType:@"html"
inDirectory:@"Assets"];
Change to :
NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
ofType:@"html"];
In your View Controller:
use :
class ViewController:UIViewController,YTPlayerViewDelegate {
var playerView = YTPlayerView()
fetch videoID and load :
self.playerView.load(withVideoId: videoID)
self.playerView.playVideo()
}