views:

232

answers:

2

Hello,

I have an HTML5 video player with a custom seek bar, that's working great on the iPhone (playing inline) and on the browser.

It plays great on the iPad too and the seek bar is updated as the movie plays, but for some reason, I can't seek.

All of the values are correct and I'm trying to set:

myPlayer.currentTime = XX;

Unfortunately, the iPad refuses to set the .currentTime attribute.

From what I can gather the difference between the browser and iPad is that on the browser I get:

myPlayer.networkState = 3
myPlayer.readyState = 4

On the iPad I get:

myPlayer.networkState = 2
myPlayer.readyState = 3

It's exactly the same code, running a local MP4 video.

Any idea why this is happening?

Cheers, Andre

+1  A: 

I've had all kinds of problems getting JavaScript to control audio elements, and a lot of frustration with the currentTime property, along with Apple's restrictions on what constitutes direct user initiation of events.

It wouldn't surprise me if there were some kind of weird bug with JavaScript & HTML5 video playback on the iPad (or "feature" that's undocumented), which requires a workaround. From my experience, the iPad has a unique way of doing things than what's in the official documentation.

You should check the error, buffered, seekable, and seeking properties of the video element. Looking at your readyState & networkState values, the iPad seems to think that the video has not been completely loaded - which is odd for a local resource.

buffered and seekable should be equal to the time range of your entire video. seeking should be TRUE. That should at least give you a little more information about the problem.

Have you tested it with other videos? It might be that there is some kind of encoding problem with the video that the iPad has a problem with.

Other than that - there was a bug in a previous iPad OS version that broke the ability to set the currentTime property. Are you using the latest OS version?

Kyle Lowry
I'm using 3.2 (because I can't limit it to the latest) and I have tried a different video source, with the same problem :/
Andre
A: 

I am having the same issue - here are the properties in my case:

UIWebView - iPad Simulator
duration=4.861666679382324
startTime=0
currentTime=4.861666679382324
buffered(1)=[0-0]
seekable(0)=
seeking=false
error=null
readystate=4
networkstate=3

Chrome:
duration=4.9226298332214355
startTime=0
currentTime=4.9226298332214355
buffered(1)=[0-4.9226298332214355]
seekable(1)=[0-4.9226298332214355]
seeking=false
error=null
readystate=4
networkstate=1

so - nothing is getting buffered and nothing is seekable. i am playing a local clip from the resources directory of an iPad bundle, via a UIWebView.

In my case, all i need is to reset to the top of the video after each play, and I was able to accomplish this via a call to "load()"

-c

wodenx