I'm trying to show a YouTube video in my app using JW.player, but nothing happen when I press play. I can see the UIWebView
in my viewcontroller
, but the video doesn't appear how come?
- (void)viewDidLoad
{
[super viewDidLoad];
htmlPlayerWebView =[ [UIWebView alloc]initWithFrame:CGRectMake(0, 51, 674,381)];
[self.view addSubview:htmlPlayerWebView];
}
-(void)loadVideo
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"home" ofType:@"html"];
NSString *HTMLString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[htmlPlayerWebView loadHTMLString:HTMLString baseURL:[NSURL URLWithString:path]];
}
And the HTML code:
<html>
<head>
<title>Title of the document</title>
<script src="http://jwpsrv.com/library/NwqHmnPBEeORiiIACmOLpg.js"></script>
</head>
<body>
<div id='playerNtFziJDGyTtg'></div>
<script type='text/javascript'>
jwplayer('playerNtFziJDGyTtg').setup({
file: 'https://www.youtube.com/watch?v=ac7KhViaVqc',
title: 'Sintel | first official trailer US (2010) 3D open movie project',
width: '360',
height: '640',
fallback: 'false'
});
</script>
</body>
</html>