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.
Related
I am trying to schedule a notification based on a time i am getting from a server.
the problem is the notification shows but its not showing at the right time sometimes it display at the right time and sometimes it doesn't i am not sure why, i think the problem is with the time formatting the one i am getting from the server and the devices time. here an example time i am getting from the server : 2019-12-20T13:55:00.000 now i want to schedule a notification with this time i am doing something like this:
var notifDate = new Date("2019-12-20T13:55:00.000").getTime()
var currentDate = new Date().getTime()
var diff = notifDate - currentDate
Notification.schedule(diff)
now my questions is how can i ensure every notification is gonna display at the right time and maybe if i have to make the currentDate and notifDate the same format. i don't know much about how Date works. i know this question doesnt state much but anykind of suggestion is appreciated.
Thanks
At our office we check in by opening a webpage and clicking on a check-in button.The following function is called while clicking the button:
function checkInOutSubmit(thisController, thisAction, checkName){
var visitortime = new Date();
var visitortimezone = "GMT " + -visitortime.getTimezoneOffset() / 60;
var timeZone = jstz.determine_timezone();
var timeZoneName = timeZone.name();
var checkInCheckOut = checkName
jQuery.ajax({type:'POST',data:{checkInCheckOut:checkInCheckOut,currentController: thisController,currentAction: thisAction,timez:timeZoneName}, url:'/pms/attendanceForgot/checkInCheckOut',success:function(data,textStatus){jQuery('#successdiv').html(data);successCheckInOut();},error:function(XMLHttpRequest,textStatus,errorThrown){}});
}
But I want to put a old time when clicking on the button and not the current time.(If I reach click the button at 11:00am, I want to post 10:00am as my checkin time).
How can this be done?
There is not enough information here to answer your question.
All this code is doing is finding the current time zone, not the current time. It passes that to the server via an ajax request, which makes me think the time is generated server side. It's possible you could alter the logged time on the server by changing the timezone to an offset that would make it look like you are clocking in at the right time, but it would have to be some seriously deficient code on the server for that to work.
In almost all likelihood, the server is storing the time of the request in universal time as the clock in time and when you leave it's storing the time you leave in universal time as well. (think a point in time that isn't dependent on timezones) If your goal is get more hours, you'll just have to work later when you come in late. If you want it to look like you came in "on time", then changing the timezone might help until they notice that you've been there from 10am to 6pm but are only logging 7 hours.
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.
Is it possible to ser a function to start in a given date and hour? How?
I thought about setTimeout, but what's the maximum time I can set?
--update
By the way, it's for a desktop application.
I agree with JCOC611 - if you can make sure that your application does not close, then just get a Date object of when your alarm should go off and do something like this:
window.setTimeout(function() { soundAlarm() },
alarmDate.getTime() - new Date().getTime());
I see no reason for this not to work, but a lot of people exalt a timer based solution where you have a short lived timer that ticks until the set time. It has the advantage that the timer function can also update a clock or a countdown. I like to write this pattern like this:
(function(targetDate) {
if (targetDate.getTime() <= new Date().getTime()) {
soundAlarm();
return;
}
// maybe update a time display here?
window.setTimeout(arguments.callee,1000,targetDate); // tick every second
})(alarmDate);
This is basically a function that when called with a target date to sound an alarm on, re-calls itself every second to check if the time has not elapsed yet.
setTimeout(functionToCall,delayToWait)
As stated in Why does setTimeout() "break" for large millisecond delay values?, it uses a 32 bit int to store the delay so the max value allowed would be 2147483647
Does setTimeout() have a maximum?
http://www.highdots.com/forums/javascript/settimeout-ecma-166425.html
It may surprise you that setTimeout is
not covered by an ECMA standard, nor
by a W3C standard. There are some
holes in the web standards. This is
one of them. I'm looking to the WHAT
Working Group to fix this. See
http://www.whatwg.org/specs/web-apps/current-work/
There doesn't seem to be a problem in
setting the timeout value to something
that is vastly greater than the MTBF
of the browser. All that means is that
the timeout may never fire.
http://javascript.crockford.com/
-Douglas Crockford
As others have mentioned, this isn't the way to handle the situation. Use setTimeout to check a date object and then fire the event at the appropriate time. Some code to play with is linked below.
http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clock
You should not relay on setTimeout for the actual alarm trigger but for a periodic function tracking the alarm. Use setTimeout to check the stored time for your alarm say every minute. Store that time in DB, file or server.
Is there any server component to this at all? You could use setInterval to call something serverside on a regular basis via ajax, then pull back a date object and once it's finally in the past you could trigger your "alarm"
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);
}