detection

How can I tell if an HTML5 Audio element is playing with Javascript

泄露秘密 提交于 2019-12-05 03:56:05
I have an audio element in a webpage, and I want to ensure that a user is not still playing it when they leave the page. How can I be sure the audio element is not playing when the page is unloaded? So far, I have the following code, but it doesn't seem to work; the dialog that pops up upon unload reports that playing is false even when the audio is playing: <!DOCTYPE HTML><html> <head> <script><!-- Loading Scripts --> function unloadTasks(){ if (playing && !window.confirm("A podcast is playing, and navigating away from this page will stop that. Are you sure you want to go?")) window.alert(

MapBox water/land detection

耗尽温柔 提交于 2019-12-05 02:42:52
问题 I am starting to use the MapBox iOS SDK. Is there any possible way to query the MapView by a coordinate and get back the terrain-type (water, land) as a result? I've been reading the API doc for quite a while now, but could not figure it out. I know that there are (interim) solutions available to use a Google webservice, but I need this to work offline. I am not bound to MapBox (but I like it) though, thank you for any hint! 回答1: No need to delve into runtime styling (see my other answer,

how to tell if android user came from home screen app

♀尐吖头ヾ 提交于 2019-12-05 01:27:12
Is there a way to tell if a user came to your website via a home screen shorcut? With iOS I'm able to use the following javascript code to detect if the user opened the page via the home screen shortcut: if (('standalone' in navigator && !navigator.standalone && (/iphone|ipod|ipad/gi).test(navigator.platform) && (/Safari/i).test(navigator.appVersion)) { window.location = 'index2.html'; } i can't find that there is anything similar that you can do with android though. any help would be greatly appreciated :) The short answer is "No." A web site bookmark widget launched from the Android

How to check an object's type in C++/CLI?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 00:13:00
Is there a simple way to check the type of an object? I need something along the following lines: MyObject^ mo = gcnew MyObject(); Object^ o = mo; if( o->GetType() == MyObject ) { // Do somethine with the object } else { // Try something else } At the moment I'm using nested try-catch blocks looking for System::InvalidCastException s which feels ugly but works. I was going to try and profile something like the code above to see if it's any faster/slower/readable but can't work out the syntax to even try. In case anyone's wondering, this comes from having a single queue entering a thread which

Proper method to detect device model (iPhone/iPod Touch)?

南笙酒味 提交于 2019-12-04 18:34:32
Is this the proper way to detect which device a user is running? NSString *currentModel = [[UIDevice currentDevice] model]; if ([currentModel isEqualToString:@"iPhone"]) { // The user is running on iPhone so allow Call, Camera, etc. } else { // The user is running on a different device (iPod / iPad / iPhone Simulator) disallow Call. } It is not a general solution but Apple in many cases provides API calls to check wether specific feature is supported or not. Examples could be: +isSourceTypeAvailable: and +availableMediaTypesForSourceType: in UIImagePickerController allowing you to check if

Color detection on HoughCircles using OpenCV

狂风中的少年 提交于 2019-12-04 17:54:39
I have detected 22 balls and am struggling to find a way to run a color detection algorithm on these circles to get their colors. I am using HoughCircles to detect the circles but don't know how to check what color these circles are? Source Code: #include <stdio.h> #include <cv.h> #include <highgui.h> #include <math.h> int main(int argc, char** argv) { //load image from directory IplImage* img = cvLoadImage("C:\\Users\\Nathan\\Desktop\\SnookerPic.png"); IplImage* gray = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1); CvMemStorage* storage = cvCreateMemStorage(0); //covert to grayscale

Identify Cygwin, Linux, Windows using environment variables

一曲冷凌霜 提交于 2019-12-04 15:58:31
The problem arises when makefile needs be run on different OS and various setting should be properly set up (escaping, path separator, etc) depending on OS. The first approach was to use Windows COMSPEC: ifneq ($(COMSPEC)$(ComSpec),) ## in windows else ## in linux endif This is false positive for Cygwin, because it sees Windows' environment variables and detects Cygwin as Windows. Then we tried Linux PWD: ifeq ($(PWD),) ## in windows else ## in linux, cygwin endif However, as a result of integration of off-site tool we have PWD set in windows (one of the perl's modules). So, the detection

Cocos2d iPhone Non-Rectangular Sprite Touch Detection

那年仲夏 提交于 2019-12-04 14:32:10
问题 Have a project with a TRIANGLE shaped graphic in a sprite. I am arranging these sprites in a grid so that their rectangles are all overlapping. As sprites get touched their z-order is being changed (by me) to put them on the top of zOrder. I am using Cocos 0.8.1 and the touch dispatcher method. I have touches working but obviously the "hidden" sprites which are overlapped by other sprites are not able to be touched. The problem is that the "Is the touch in my rect" method is based on the

Detecting and accessing a usb device from within a webbrowser -i.e using a plugin

不打扰是莪最后的温柔 提交于 2019-12-04 10:42:07
问题 Is it possible through a plugin - activeX, Java or Flex to write a brower plugin that is able to detect an read a data stream from a USB device channel. I have done some research but have not found an answer. http://support.microsoft.com/kb/832678 http://www.vsj.co.uk/articles/display.asp?id=600 Detect USB drive and his name http://bytes.com/groups/net-vb/379899-detect-usb-drive-his-name Can JAVA be leveraged within embedded Javascript to access the USB port? http://p2p.wrox.com/topic.asp

iOS Motion Detection: Motion Detection Sensitivity Levels

放肆的年华 提交于 2019-12-04 09:14:13
问题 I have a simple question. I'm trying to detect when a user shakes the iPhone. I have the standard code in place to detect the motion and this works no problem. However, in testing this on my actual phone, I've realized that you have to shake the device quite hard to get the motion detection to trigger. I would like to know if there is a way to implement a level of sensitivity checking. For example, a way to detect if a user lightly shakes the device or somewhere between light and hard shake.