I'm developing simple javascript game,
which should be embeded in Android and Iphone in-app browser.
I have problem with sounds. I tried this, works good on PC,
but not working on android and works strange with big delays on iphone.
init:
var hitSound = new Audio('hit.wav');
play:
hitSound.play();
How to play sounds without delay on Android and Iphone browser?
I think you're trying to use a HTML5 feature, which is not fully supported by Android's browser, at least up to FroYo. Still, if you use Android's WebView you can do the trick, but probably you are avoiding Native apps, aren't you?
This would help.
look for the page section where this is discussed:
The above two functions should be
placed in the HEAD section between a
<script language="JavaScript" type="text/javascript"> and a
.
The best place and time to invoke the
setEmbed function is in the BODY tag
after page load:
<body onload= "setEmbed('sample',
'http://www.yourdomain.com/music/')">
Related
I'm looking for how to embed a PDF file in a web page that will be viewable in the native Android browser / Chrome. If I use something like this:
<object data={'LINK_TO_PDF.pdf'+'#zoom=100&scrollbar=0&toolbar=0&statusbar=0&messages=0&navpanes=0'}
type='application/pdf'
width='100%'
height='90%'>
<p>This browser does not support inline PDFs. Please download the PDF to view.</p>
</object>
It works great on Chrome, FireFox, and Edge on Windows. It works great in Safari on iPad (iPadOS) and Safari on iPhone (iOS).
But it does not display on Android.
The files are not publicly accessible, so I cannot use the Google Docs viewer.
PDF.js doesn't seem to help. PDFObject doesn't seem to help. I've looked a bit at ViewerJS.org, but most of its source code has not been updated in 7yrs.
I've seen lots of questions and answers about this, but most of them are old. Surely in 2021, there's a way to do this that works with Android?
(Having to download the file, open it up in a third-party PDF Viewer app, and then close it, switch apps, delete the PDF, and go back to the webpage seems very backwards.)
How can this be done to provide a good user experience on Android?
In short, mobile browsers try to download a random file instead of loading video into the main player Website.
More info:
I've built a webseries type site on WordPress, that uses jQuery to load a video into the main player: http://suzellediy.com/
Recently, I made it responsive - and now, when testing on mobile, when clicking on the video thumbnail, the video does not want to load into the main player.
Instead of loading the video, mobile Chrome and Safari wants to download the file instead. The issue cannot be recreated by using firebug / chrome mobile emulator.
Any ideas what the issue could be?
Actually you may be able to reproduce the issue on the desktop when you disable Flash.
Try changing the URL in:
jQuery("#mainplayer").attr("src", "http://youtube.com/v/WKmUqV7abgw"+
"?&autoplay=1&loop=1&listType=user_uploads&list=suzellediy");
To this:
jQuery("#mainplayer").attr("src",
"https://www.youtube.com/embed/WKmUqV7abgw" +
"?autoplay=1&loop=1&listType=user_uploads&list=suzellediy");
Or this:
jQuery("#mainplayer").attr("src",
"https://www.youtube.com/embed/WKmUqV7abgw" +
"?autoplay=1&loop=1&listType=user_uploads&list=suzellediy&html5=1");
and see if that works.
Most likely what you see is that mobile browsers that don't support Flash try to download a file if they can't play it.
I created a music app using html and js. It works in background when I run in safari (iOS)But it not supporting multitask and background when I run natively in iPhone.
Any suggestions.
I assume you're talking about the difference between visiting the site in Safari vs standalone (i.e. accessing it from the home screen, assuming the mobile-web-app-capable meta tag is present).
Currently, only iOS5 supports background audio playback for standalone web apps. Anything prior to that won't work.
I currently have a simple flash Mp3 player on my site which works lovely. The issue is, most cell phones do not support flash and a large portion of my visitors come through via a mobile device. The alternative to this is to replace the flash player with a javascript player. I found a JQuery one but it only works on HTML5 compatible browsers. Does anyone know of a good alternative that would work on mobile devices as well as most desktop web browsers?
You can check if the browser supports the HTML5 audio tag if not, use the flash version.
Check out jPlayer.
I need to play few wav files on button click. I found solution working in IE but it requires QickTime plugin for Firefox.
Is there any other way?
<html>
<head>
<script>
function DHTMLSound(surl) {
document.getElementById("dummyspan").innerHTML=
"<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}
</script>
</head>
<body>
<h1>test</h1>
<span id=dummyspan></span>
<input type="button" value="Play" onmouseover="DHTMLSound('1.wav')">
</body>
</html>
Use one of these. I have only use jPlayer and can strongly recommend it.
jPlayer (requires Flash)
Scriptaculous plugin (works without Flash in Firefox)
MooTools (requires Flash)
I'd detect whether the browser allows the audio tag, and use that in that case.
That looks like this:
<audio src="1.wav" autoplay></audio>
Currently Firefox, Safari and Opera can play Wavs, Chrome as of version 3 can't, not sure about 4.
See http://html5doctor.com/native-audio-in-the-browser/ for info on how to detect whether the browser has the audio tag.
You'd then use your existing solution for IE.
<audio> as per Rich's answer is definitely the way of the future. Unfortunately at the moment there is no IE support and to get the other browsers that support it to be happy you have to use both WAV and (OGG or MP3).
So for the moment you may need to provide other ways instead or as-well-as <audio>.
Personally I would strongly avoid <embed>ding a media player plugin. It won't work on browsers without plugins and you might not get a plugin you expect, and the one you get might not work the same as you expect. There is also <bgsound> onĀ IE only, but controlling it can be annoying.
So I'd probably go for a Flash fallback solution for when <audio> isn't available. Flash has much better acceptance than any of the media player plugins.
Unfortunately, it doesn't natively support WAV, so either you use a (typically slow) WAV reader or you go with MP3 and have multiple audio formats to worry about again!
One day this will all work nicely. One day, probably around 2056.