0

In my cocoa apps for OSX 10.6 and newer versions I've always used this code to embed a video from youtube:

NSString *html = @"<center><iframe width=\"748\" height=\"461\" src=\"http://www.youtube.com/embed/SV1cVDhKZ6g?rel=0\" frameborder=\"0\" allowfullscreen></iframe></center>";

  [[videoView mainFrame] loadHTMLString:html baseURL:nil];

but now it is not working anymore, it just appears a black window and if I click on it I can still hear audio from video but no image anymore... I'm using Maverick and Xcode 5... Anyone knows what can be the problem? Thanks for any help. Massy

update: I'm also noticing that if I double click on video frame to see it fullscreen the video appears... but when I double click again to make it framed in my app the image of the video disappears again

update 2: As pointed by ThisDarkTao I can now say this is a problem concerning Safari's Flash sandbox. I tryed the solution by this post:

Flash videos in WebView not working in sandboxed app

but it didn't work at all...

During my research I read somewhere that someone says this must be a bug... I'm not so sure about it... I think this is exactly what Apple wants... finally flash is always been a bad topic for guys at Cupertino... isn't it?

I'm sure there must be a solution to this....

If anyone knows a better solution please write it... If none will give a better solution I will accept the answer of ThisDarkTao as it seams for now is the only way to make it work.

Community
  • 1
  • 1
Blue
  • 2,300
  • 3
  • 21
  • 32
  • This isn't an Xcode problem... Are you developing an app for OSX Mavericks or iOS 7, your question isn't entirely clear. – Matt S. Nov 06 '13 at 19:59
  • I'm developing for OSX 10.6 and newer... I also think that this is not related to an Xcode problem... but I don't know what to think... I tryed to install flash player again but with no results... – Blue Nov 06 '13 at 20:25

1 Answers1

3

It looks like this is a problem concerning Safari's Flash sandbox. I have the same problem on a Mavericks app I'm developing at the moment. I added html5=1 to the video arguments list, effectively forcing HTML5 video.

Yours in that case would be:

NSString *html = @"<center><iframe width=\"748\" height=\"461\" src=\"http://www.youtube.com/embed/SV1cVDhKZ6g?rel=0&html5=1\" frameborder=\"0\" allowfullscreen></iframe></center>";

If you definitely need Flash, I haven't been able to find a more elegant solution.

ThisDarkTao
  • 1,062
  • 10
  • 27
  • It works... thanks a lot... the only problem now is that video can't be opened full screen anymore... do you have a solution to that also? – Blue Nov 07 '13 at 14:51
  • You can allow fullscreen for WebKit browsers by adding `webkitallowfullscreen` to your player's iframe. Currently fullscreen and the `iv_load_policy` parameter to hide annotations do not work on Safari 7.0 (9537.71), but do work on Safari 6. I can only assume this is a bug with Googles iframe code, unless the sandboxing is disabling iframe fullscreen also. I'm filing a bug report with Apple about the fullscreen and annotation issues, so hopefully this will be fixed soon. – ThisDarkTao Nov 07 '13 at 16:01
  • It doesn't work... I replaced "allowfullscreen" with "webkitallowfullscreen" but it still doesn't go in fullscreen... – Blue Nov 07 '13 at 18:29
  • If I manage to find out any more info or fix the fullscreen problem I'll revive this question. – ThisDarkTao Nov 13 '13 at 21:00