Question

I've scoured the web, upgraded the player, rewritten it 5 times, and now completing my 5th day of failing, and still cannot accomplish what the folks at Longtail tell me will work. (Don't get me wrong, I love 'em there, but this has me ready to jump off a bridge).

I'm simply trying to load a video that will play with Flash or iOS, and upon loading it, immediately go to a specific point in the video useing the .seek() method. Longtail tells me to use the onBeforePlay() function because iOS apparently doesn't respect the start value of the playlist. This code works like smoke with Flash, but ignores the seek in iOS.

Can ANYone assist me with this - it has become the most expensive script I've ever worked on and I have made zero progress at all. :( :( :( Also, I removed all the console functions and tried that, but with the same result.

Full code/player can be seen at http://www.tempurl.us/jw6e.html. You can see that with Flash, the video starts at 60 seconds, but on iOS, it starts at 0.

jwp = jwplayer('jwp').setup({
    title: 'Single File Player', width: '720', height:'240', autostart: 'false', listbar: {position: "right",size: 400},
    sources:[
       {   file: 'http://media3.scctv.net/insight/mp4:nursing_4_clips_400.mp4/playlist.m3u8'},
       {   file: 'rtmp://fms.scctv.net/insight/nursing_4_clips_400.mp4'}
    ]
    }
);
jwp.onReady(function() {
    // Create a playlist item of the video to play
    var newItem = [
       {   title: 'Title4 ACUTE_ABDO_PAIN_400',
          image: 'playlistitem.png',
          sources:[
             {   file: 'http://media3.scctv.net/insight/mp4:ACUTE_ABDO_PAIN_400.mp4/playlist.m3u8'},
             {   file: 'rtmp://fms.scctv.net/insight/ACUTE_ABDO_PAIN_400.mp4'}
          ]
       }
    ];
    jwp.load(newItem);
});
jwp.onBeforePlay(function() {
     // This Works on PC/Mac with Flash, but does nothing on iPad/iPhone
     jwp.seek(60);
});
Was it helpful?

Solution

Simply to close the question, the bottom line on this problem was that iOS will not allow autostart - period. Knowing that, all the expected events that were not behaving as expected made sense. Once the user initiates the stream with Play, everything works as expected. In our case, this is still a problem because we want to start later in the stream, but knowing that made dealing with it more manageable.

OTHER TIPS

If the problem is iOS will not allow autostart - period. Knowing that, all the expected events that were not behaving as expected made sense. Once the user initiates the stream with Play, everything works as expected

then you can have a play button only for tablet and ios device and on Clicking the play button, call jwplayer().play(), this could be a work around for your problem, and after you have invoked jwplayer.play, which is only possible with the touch event, after play is triggeredother events will work.

otherwise even if you try jwplayer().play() onReady(), or autostart nothing will work because of iOs will not allow autostart as you said

I've solved this problem on iOS using onBeforePlay with seek() and play(). This work on desktop flash and IOS. Doesn't work on Android using the parameter androidhls:true

jwplayer().onBeforePlay(function() { jwplayer().seek(60); });
jwplayer().play();

As Ethan JWPlayer mentioned in comment use onPlay event. To prevent "loop buffering" as you said just use flag variable:

var isFirstStart = true,
    seekValue    = 60;

jwplayer().onPlay(function(){
    //exit if it's no first playback start
    if( !isFirstStart ) {
        return;
    }

    jwplayer().seek(seekValue);
    isFirstStart = false;
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top