Seeking forward in time works.If I seekTo(160), for example, it works. But, if I try to seek backwards seekTo(30), it sets back to 160. This happens in opera,chrome; works like it should in firefox.
player.seekTo(duration, true);
Just set the allowSeekAhead value to true and it should work. It worked for me.
I had the same problem has you described.
I don't know if it can help but I found out that after you query the API for the video duration, seek to previous location seemed to work...
I needed to do a "replay" kind of thing so what I've done is :
var duration = player.getDuration();
player.seekTo(duration-duration, false); // equals to video exact start time which should be the same as 0
player.playVideo();
My tests showed that doing
player.seekTo(0, false);
was working after the duration has beed queried but I didn't wanted to take any chances :-)
Related
I want to resume video second time from the same time interval from which I left last time. But when I'm opening player for the second time, it either take longer time than the usual or (and mostly) it throws kBCOVPlaybackSessionLifecycleEventError Not sure what and why it's happening. Following is my pseude code to resume the video.
Can anyone please help on this? In the native docs also, there is not much info is mentioned which can be of help. So do let me know if anyone has input on this one?
Summarising in one line: How can we seek in the start itself when BCOV player loads?
Here is the link for brightcove-ios-native SDK
func seekToTimeWithSeconds(seconds:Double) {
let seekToTime = CMTimeMakeWithSeconds(seconds, preferredTimescale: 60000)
playbackController?.seek(to: seekToTime, completionHandler: { [weak self] (finished: Bool) in
self?.playbackController.play()
})
}
After spending days on this issue figured out the actual problem which was authToken for playing video was getting empty value. Because of which BCOV player was unable to load the player and was throwing kBCOVPlaybackSessionLifecycleEventError
So if anyone is stuck with this you might first wanna check if your player is getting authToken and videoID in not nil.
Also before getting to above solution I tried following things. So if above didn’t work for some of you guys you can try with following things which I Tried.
Nil all the values of BCOV player related values at the time for
deinit()
Take reference of BCOV session from lifecycleEvent delegate and make sure to terminate it whenever you leaving the view.
Check whether your internet connection is appropriate.
Hope this might help someone.
Cheers.
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);
});
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.
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;
});
I did not found solution for one issue: how to play mp3 file from offset immideately?
I can only play file then send -(void)seekToTime: but in this case sound begins and interrupts then begins from defined offset.
I tried to apply seekToTime method on ASStatusChangedNotification (in different cases of AudioStreamerState) but there were without result.
upd: I think that may set time offset after the file began streaming (before playing). But how?
Thanks.
What I did was create a method to seek to the desired time that I run after [streamer start]:
while(streamer.bitRate == 0) {
sleep(1);
}
If you're concerned about waiting too long, you can add a time out: either a count of times through the loop, or set a start time and compare it to the current time to break out of the loop.
This blog post has another take:
http://www.saygoodnight.com/2009/08/streaming-audio-to-the-iphone-starting-at-an-offset/
Is there a way to cause an event when a video reaches a specific time? I want to get to a callback function at the time when the video has reached to a certain time, and the time it takes for the video to reach that time is unpredictable, since the user can skip part of the video, or buffering might take some time before the video resumes, or something like that, so simply setting a timed event wont work because the video might reach specific time earlier.
I can query the time of the video, but what I want is to get a callback when the video has reached a certain time. Is there a way to do this?
I'm not going to write the full code, but you should set up an interval, like this:
var time = 70; // Time in seconds, e.g. this one is one minute and 10 seconds
var reached = false;
var interval = setInterval(function(){
if(player.getCurrentTime() >= time && !reached) {
clearInterval(interval);
reached = true;
timeReached();
}
},1000);
function timeReached() {
// Do what you have to
}
You can use this Javascript wrapper for the YouTube player API.
The API provides very simple event handling. E.g:
youtubePlayer.at('5000', function() {
alert("You're five seconds into this Youtube clip");
});
use player.getCurrentTime()!
https://developers.google.com/youtube/iframe_api_reference#Playback_status
I am developing a phonegap application that sends the current GPS location to a server. In order to do so, we have the following code fragment:
navigator.geolocation.watchPosition(gpsTracker.onNewCoordinates, gpsTracker.onError, {
enableHighAccuracy : true,
maximumAge: 4000, //should be default, just in case
timeout: 5000
});
The callback functions take care of submitting the results. On our Android test-device this functionality is working just nicely. However when we run the same code on an iOS device it usually does nothing, except when the GPS reception is fine it will send two coordinates and then it stops.
It looks like iOS only obtains some information once, and never triggers the callback functions when there are new coordinates available.
Anyone with similar experience / solution to this problem?
I solved my issue as follows. It turns out that navigator.geolocation.watchPosition does not seem to work well on iOS. I rewrote the code using a javascript setInterval which invokes getCurrentPosition every 5 seconds instead:
navigator.geolocation.getCurrentPosition( gpsTracker.onNewCoordinates, gpsTracker.onError, {
enableHighAccuracy : true,
maximumAge: 4000, // should be default, just in case
timeout: 5000
});
Now the GPS position is correctly returned every 5 seconds.
Have a look at this:
http://groups.google.com/group/phonegap/browse_thread/thread/58f7ff98170b16c4
There is something written about geolocator.start() and stop(), preserved for iOS. Maybe this helps?
According to my experience, the GPS must be "hot" in order to deliver valid positions, i.e. it must be given enough time to connect to satellites etc. Usually, you have it "hot" only if you start watching, not if you just pick single positions. On my HTC, values gained by getCurrentPositions() have therefore turned out too unprecise (related to a near scope, e.g. within 50m). So it might be the right way to try once more to find a solution with startWatching().