When a user triggers a Javascript action, I want the JW FLV to seek back 5 seconds from the current location. I know how to send events using player.sendEvent('SEEK',seconds). But I dont know how many seconds to pass as JS does not know the current location. Can someone please help?
http://developer.longtailvideo.com/trac/wiki/FlashEvents#Viewevents.
1)You can get the current location as :
getPosition(): Returns the current playback position in seconds, as a number.
2)And then seek to required position as:
seek(position):Jump to the specified position within the currently playing item. Parameters: position:Number: Requested position in seconds.
Also refer this
Actually you can get the current location with javascript. Here's how:
player.addModelListener('TIME', 'timeMonitor');
var time = null;
function timeMonitor(obj) {
time = obj.position;
}
The time variable constantly updates, so then just do something like:
function userTriggeredJsAction(){
var newTime = time - 5;
player.sendEvent('SEEK',newTime);
}
Related
I have a chromecast sender application that is using the default receiver.
I am passing a live MPEG-DASH stream and all is working.
I have one concern the time that is displayed in the seek bar is incorrect it looks like a malformation of an epoch timestamp.
example
416797:35:52
is there anything I can do to make this timestamp work?
I am currently getting an epoch timestamp back as currentTime from the remotePlayer
I have bound the RemotePlayerController like the following
this._remotePlayer = new cast.framework.RemotePlayer();
this._remoteController = new cast.framework.RemotePlayerController(this._remotePlayer);
This is because the duration for live is infinity. I had the same problem, I had to manually calculate progress to show it correctly, although you can't use it to seek to a position for live contents.
If you bind with RemotePlayerController it should handle this for you, this would basically disable seek bar and show you default -- -- start and end time.
The following code is where I can put the current TimeDomainData into an array.
fbc_array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteTimeDomainData(fbc_array);
And then I can use the for statement to let each fbc_array[i] value (Time Domain waveform) being displayed on canvas.
Question:
I want to use the mouse events to trigger the sound where the mouse hovers on the Time Domain waveform.
Is there any method inside the AudioContext can let the fbc_array[i] value back to the sound?
I've got a MediaElement.js player with a video loaded into it, and I have a (database-driven) function which, given a time offset within that video, gives me the actual real-world time at which that part of the video represents.
I.e., if the video consists of 2 30-second clips, the first of which was recorded Tuesday morning, and the second of which was recorded Thursday evening, the function I've got will take an input of 25.2 and return a particular time on Tuesday morning, or it'll take an input of 44.6 and return a time on Thursday evening. And so on.
My question is: Is it possible for me to intercept the bits of MediaElement that are used to display time (e.g. the floating div that shows the time offset when you're hovering over the time rail, and so on), and have them use my function to determine what to display? Ideally, I'd like to do this without modifying the MEJS code itself, if possible.
Thanks!
+1 Good question, and yes - it is possible. What you want to do is create your own plugin/feature for the progress and currenttime etc.
Here's a simple example how you can create a plugin/feature for currenttime, that should get you started, make sure you prefix your featurename with "build":
(function($) {
MediaElementPlayer.prototype.buildmyfeature = function(player, controls, layers, media) {
var t = this;
$('<div class="mejs-time">'+
'<span class="mejs-currenttime">' + (player.options.alwaysShowHours ? '00:' : '')
+ (player.options.showTimecodeFrameCount? '00:00:00':'00:00')+ '</span>'+
'</div>')
// append it to the toolbar
.appendTo(controls);
//attach element we want to update to t (this) for easier access
t.currenttime = t.controls.find('.mejs-currenttime');
// add a timeupdate event
media.addEventListener('timeupdate',function() {
if(t.currenttime) {
//replace with whatever time you want to insert here
t.currenttime.html(mejs.Utility.secondsToTimeCode(t.media.currentTime, t.options.alwaysShowHours || t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond || 25));
}
}, false);
}
})(jQuery);
And add your plugin/feature to the features: param, like so:
$('audio,video').mediaelementplayer({
features: ['playpause','myfeature','progress']
});
There is an example how to create a loop button (plugin/feature) from the official mediaelementjs site here:
http://mediaelementjs.com/examples/?name=loop
If you need some code to get started on the progress bar, just have a look at mep-feature-progress.js at git.
I have a simple JavaScript chronograph that displays on a form field called "d2", it is used to check how long someone takes on doing a specific task:
var milisec=0
var seconds=0
var complemento1=""
document.form1.d2.value='00:00:00'
function display(){
if (milisec>=9){
milisec=0
seconds+=1
}
else{
milisec+=1
}
complemento1=complemento2=complemento3="";
if ((seconds%60)<10) complemento1="0";
if ((Math.floor(seconds/60)%60)<10) complemento2="0";
if ((Math.floor(seconds/3600))<10) complemento3="0";
document.form1.d2.value=complemento3+Math.floor(seconds/3600)+":"+complemento2+(Math.floor(seconds/60)%60)+":"+complemento1+(seconds%60)
setTimeout("display()",100)
}
The problem is that when the person opens a new tab / uses another program the timer stops, and then resumes when the window is focused again (Using Chrome). It has the weirdest behavior, because sometimes it works, sometimes it doesn't.
I saw many posts that needed a script to stop when not on focus, I want the exact opposite and searched for over an hour with no luck. Your help is greatly appreciated!
JavaScript timeouts are not guaranteed be executed at a specific time. For example if the thread is busy with something else at the time when the timer finishes, it will first finish what it is doing and then execute your timer.
Also your function does not take into account the time spend inside the display function, so a little delay will be added for each millisecond.
The correct way to implement a timer is using the system time.
So something like:
//Call at the beggining to save the start time
var start_time = new Date()
// Compute seconds (does not matter when/how often you call it.)
var milliseconds_since_start = new Date().valueOf() - start_time
The Date object can also format this period as a clock for you:
var m = new Date(milliseconds_since_start)
m.getMinutes()+":"+m.getSeconds()
I have a MovieClip that fades in and then fades out. I'd like to find the half way mark in this movie clip and pause it. However in EaselJS I cannot find any way to get the movie clip's current frame position. Is this possible?
I'd like to do something like the following:
canvas = document.getElementById("introCanvas");
exportRoot = new lib.MyMovieClip();
exportRoot.onTick = function () {
//get the mc's length in frames
//get the current frame position
//if current frame postion == mc's lenght / 2
//then pause movie clip
};
Can anyone provide me with some suggestions or ideas for how I might accomplish the above?
Thanks!
After reading through the documentation, it seems that a TweenJS Timeline is automatically allocated to manage the change in the animation, it doesn't look like there are any actual frames like we see in flash.
If you look at the docs for TweenJS Timeline its possible you could use the duration property, as the docs state:
Read-only property specifying the total duration of this timeline in milliseconds (or ticks if useTicks is true). This value is usually automatically updated as you modify the timeline. See updateDuration for more information.
So if you get the duration and divide by 2, or multiply by 0.5 ;) then you could find out the middle point of your animation. Try using this in your onTick method to see if it works.
I always do this...
(movieclip.timeline.position)%movieclip.timeline.duration
Or another way...
var tl = movieclip.timeline;
var d = timeline.duration;
(tl.position)%d
You have to get the movieclip's timeline's position & duration, and add a %. This will get the current frame of the movieclip.