Embedded media player gets inconsistent currentPosition on both IE8 and Firefox3 - browser

I have a embedded media player in the browser that is controlled by javascript to handle all the mediaChange event. The code looks like
mediaChangeHandler: function(media) {
if (media && this.offset && !this.offsetJumpPerformed) {
if (parseFloat(media.duration) > this.offset) {
pos = parseInt(pos);
this.getPlayer().controls.currentPosition = pos;
alert("jump to position: " + this.getPlayer().controls.currentPosition);
this.play();
this.offsetJumpPerformed = true;
alert("currentPosition:" + this.getPlayer().controls.currentPosition);
}
}
}
The first alert indicates the currentPosition is where I want it to be. However, the second alert would get currentPosition that's couple seconds less than what I have set up.
Does anyone have idea why? I tried googled it but haven't found anything useful. Thanks!

This is a bug introduced with WMP10 and present also in WMP11, while Windows Media Player 9 worked perfectly. I didn't find any workaround to correct this behavior...

Related

Detect collision direction in Phaser3

I'm trying to create a 'Bomber-man' like game using Phaser3 library.
For this purpose I'd like to define a collision relationship between the player and the bricks,
and more importantly - detect the collision direction relative the the player.
I've noticed body properties like touching or blocked but they are always set to false. (please see below)
//scene.js
// bricks static group
this.scene.physics.add.staticGroup({ immovable: true });
// player defined in external file (as sprite)
this.player = new Player(this, 90, 90)
// player.js
// ...
this.physics.add.collider(
this,
scene.bricks,
function(player, brick) {
if(player.body.touching.left) { //ALWAYS FALSE!!!
this.isBlockedFromLeft = true;
}, else if(player.body.touching.right) {
this.isBlockedFromRight = true; // ALWAYS FALSE!!!
}
},
null,
this
);
I'd appreciate any help. This is driving me crazy. Maybe there is a better way to do it and i'm missing something...
Thanks in advance.
So I finally figured it out.
The major issue was the way I defined the player movement. It should be
if (this.keyboard.right.isDown) {
this.body.setVelocityX(this.speed);
}
rather than
if (this.keyboard.right.isDown) {
this.x += this.speed;
}
The second way prevent collision detection and the body.touching and body.blocked properties to be updated.
Furthermore, I've found out that when it comes to top-down tiled games, it's really easier to build up the game using the tile-map feature.
official examples can be found here:
https://phaser.io/examples/v3/search?search=map
and here is a tutorial of how to make a tiled-map using a light-weight software called 'Tiled'
https://www.youtube.com/watch?v=2_x1dOvgF1E
Thank you all!

Xamarin UITest - determine if device is Phone or Tablet for Android?

Is there a way to determine if the Android device I'm running tests on is Phone or Tablet? Found various answers on this topic from an Android development perspective, but I'm just developing tests and looking for some method from Xamarin.UITest that could tell me this. For the iOS there is a built-in method like app.Device.IsPhone, but I can't seem to find something similar for the Android.
Any ideas?
The way that I do it in my tests is check the size of the device see code below:
public bool DeviceIsTablet()
{
var screen = app.Query(x => x.Id("content"));
var height = screen.FirstOrDefault().Rect.Height;
var width = screen.FirstOrDefault().Rect.Width;
if (width < 1600 || height > 1850)
{
return false;
}
else
{
return true;
}
}

Drag-&-drop and Dockbar menu is not working in Chrome using touch laptop / screen

I have been using Liferay 6.2.1 CE GA2 and both issues are reproducible in Chrome (only). I have also verified that you will find both of the above issues been fixed on latest Liferay 6.2.5 CE GA6. I further drilled down and identified that these issue were primarily fixed in Liferay 6.2.2 CE GA3.
My problem is that I am unable to find relevant ticket(s) in which these issues were fixed, as I just require these fixes (can not upgrade). It would be thankful, if someone can point out the exact tickets.
Many thanks in advance.
After hell of research and code debugging, I have been able to resolve both of the issues.
Thought of sharing my findings here, as this might be helpful for others.
Unable to Drag-&-drop portlets:
Fix: Upgrading alloy zip (\portal-web\third-party\alloy-2.0.0.zip) to 2.0.0.37 or later resolves this issue. Since, this was the only minor upgrade of zip between Liferay 6.2 GA2 - GA6.
2 . Dockbar menus not clickable:
Fix: Resolved it with following custom javascript hack:
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isChrome = !!window.chrome && !isOpera;
/* Run code, if application is running on touch device with chrome */
if(isTouchDevice() && isChrome){
var docbar_dropdowns =
document.querySelectorAll('li.admin-links, li.my-sites, li.user-avatar');
/* Attach click event */
if(docbar_dropdowns.length > 0){
for(var d = 0; d < docbar_dropdowns.length; d++){
docbar_dropdowns[d].addEventListener("click", toggleMenu, false);
}
}
/* Toggle menu on click */
var elementId = null;
function toggleMenu(event){
event.stopPropagation();
if(elementId != null && elementId != this.id)
hideMenu();
elementId = this.id;
if(this.children[1].style.display == "block"){
this.classList.remove("open");
this.children[1].style.display = "none";
}else{
this.classList.add("open");
this.children[1].style.display = "block";
}
}
/* Hide previously opened menu */
function hideMenu(){
for(var d = 0; d < docbar_dropdowns.length; d++){
docbar_dropdowns[d].classList.remove("open");
docbar_dropdowns[d].children[1].style.display = 'none';
}
}
document.body.addEventListener("click", hideMenu, false);
}
/* Detect touch device */
function isTouchDevice() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
NOTE: In our environment, both issues were only reproducible in chrome on touch devices / using mouse on touch laptop.

Foursquare search venues with "intend = browse" always return 0 results

My app is in the app store and all worked well but now foursquare has changed something and I can't get any places.
I search places in area and use "intend" = "browse". I researched that if change "intend" to "checkin" it works well, but I need "browse".
Additionally if I choose "checkin" I need to add "ll" parameter that I sometimes don't have.
My request:
https://api.foursquare.com/v2/venues/search?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&intent=browse&query=subway&v=20140806&m=foursquare&ne=59.969420,30.265150&sw=59.871682,30.388964&limit=50&categoryId=4bf58dd8d48988d1c5941735&ll=59.920551,30.327057
Response:
{
meta = {
code = 200;
};
response = {
venues = ();
};
}
Sorry for this, i garbled ne and sw with nw and se.
Remember that ne - top right corner,
sw - bottom left.

How to implement auto-hide navigation?

I'm not sure where to post this question, so please excuse me if I am violating any policies.
To clarify my question, I want to achieve the same navigation bar as Teehan + Lax's.
Here is their website: http://www.teehanlax.com/tools/
If you notice, the navigation auto hides itself when you scroll down, however when you scroll up it would show it self again.
So my question is, how did they achieve this? Is it through only CSS or do I need JavaScript to do this? Whatever way it is, can someone also point towards the right direction on how I can find the information to implement this?
Thank you
It's not possible to change position from fixed to absolute in pure CSS like you want, so I used some javascript to do so. Demo
function followTo(elem, pos) {
var element = document.getElementById(elem);
window.onscroll = function(e){
var disFromTop = document.all? iebody.scrollTop : pageYOffset;
if (disFromTop > pos) {
element.style.position = 'absolute';
element.style.top = pos + 'px';
} else {
element.style.position = 'fixed';
element.style.top = 0;
}
};
};
followTo("nav", 100);
It even includes an IE fix pulled from this SO post to get the correct scroll position
Here is the jQuery version, taken from this SO post
EDIT
As pointed out by zanona, I did not include the feature where the navigation appears if you scroll up from a place further down in the page. As a result, I create a new technique that uses a setInterval
var last = 0, // The last read top value
delay = 150, // The delay for the setInterval
threshold = 30; // The max scroll distance before showing/hiding the nav
//I always set a variable to my setIntervals in case I want to stop them later on
var navMovement = setInterval(function() {
var nav = document.getElementById('nav'), // Gets nav object
pageVertOffset = document.all? iebody.scrollTop : pageYOffset;
// Happens if the difference in scroll is below the negative threshold
if(pageVertOffset - last < -threshold) {
nav.style.top = "0px"; // Put the nav at the top of the window
}
// Happens if the difference in scroll is above the threshold
else if(pageVertOffset - last > threshold){
nav.style.top = - nav.offsetHeight + "px"; // Hides the navigation
}
last = pageVertOffset; // Updates the previous scroll value
}, delay); // Runs every `delay` amount
Javascript version, or if you prefer, jQuery version
I thought I recreated the site pretty well (but it's better because mine has a kitten, haha)

Resources