0

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>
Soma
  • 861
  • 2
  • 17
  • 32
user3140296
  • 169
  • 1
  • 9
  • Have you added a [UIWebViewDelegate](https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIWebViewDelegate) to monitor the view and any errors? – wmorrison365 Jan 02 '14 at 15:49
  • Yes i have and i have no errors. The webview appear but there is nothing in it. – user3140296 Jan 02 '14 at 15:54
  • Also, have you seen this SO link [trying-to-implement-jw-player-on-ios?](http://stackoverflow.com/questions/15005762/trying-to-implement-jw-player-on-ios?) Could this be the problem? – wmorrison365 Jan 02 '14 at 15:57
  • Ok, it doesn't load but are you getting delegate feedback and, more specifically, does the delegate method `webView:didFailLoadWithError:` not indicate that there are load issues? If not, it would appear that youtr URL is not being loaded. – wmorrison365 Jan 02 '14 at 15:59
  • I get no response. i've tested it is something wrong with the objective-c part. the html file works fine. it adds the UIWebView, but does not load the file. – user3140296 Jan 02 '14 at 16:11
  • Can you give a brief on what you've tried? – wmorrison365 Jan 02 '14 at 17:10
  • i did not fix this issue, but i added a UIWebView from storyboard and it worked like a charm. – user3140296 Jan 02 '14 at 17:50

0 Answers0