3

Is there a way to get the current time elapsed of a youtube video on iphone?

I'm embedding the YouTube player in a UIWebView.

flopes
  • 1,345
  • 1
  • 14
  • 21
  • Well I don't think this will help but I hope it does... I know that you can specify the time in a youtube video url by getting the url of a video... ex:http://www.youtube.com/watch?v=RF8GeOYjO3Q and just at the end of the url the time of the video would be like... http://www.youtube.com/watch?v=RF8GeOYjO3Q04m37s notice the last 6 digits, it indicates second and minutes... – Gabriel Oct 18 '11 at 17:29
  • Thank you Gabe, but it doesn't help in my problem. – flopes Oct 28 '11 at 10:44
  • Did you ever come up with a solution to your question? – alex Jan 21 '12 at 00:11
  • @flopes anybody with this solution in youtube player. – Ajay Sharma Mar 07 '12 at 04:31
  • 2
    you can use javascript to get the time as mentioned in the link http://stackoverflow.com/questions/6970013/getting-current-youtube-video-time – Hanuman Mar 12 '12 at 10:31

1 Answers1

0

The best solution would be not to use a UIWebView but to roll your own Foundation based video player. If you utilise the AVPlayer class and stream the YouTube video into a AVUrlAsset (I think, from the top of my head).

The link to the documentation is:

http://developer.apple.com/library/ios/#DOCUMENTATION/AVFoundation/Reference/AVPlayer_Class/Reference/Reference.html

This way you can utilise KVO for monitoring the current play state for display, or other, purposes. There is a sample AVPlayer application on the Apple Developer site that you can reference to get you going.

JordanMazurke
  • 1,103
  • 10
  • 22