jPlayer preload audio for android chrome - android

I have a website webapp which is highly dependent on jPlayer (audio playback only).
I have different audios and audio live streams on the webapp.
I am using the "preload" option of the jPlayer and has tested it with "metadata" and "auto" option.
On an IOS device I am able to preload the audio and the audio starts playing as soon as I hit play, but on Android Tablets and Mobiles using chrome I am not able to preload the audio as the request gets cancelled.
When I click play the audio then starts buffering and then plays causing a delay in audio playback and time on clicking play.
I tried changing the "solution" of the jPlayer as well from 'html, flash' to 'flash, html'. The wmode option is also set to 'window'.
The same code works fine on IOS and Desktop but causes delay in Android Mobile/Tablet Chrome.
$("#jquery_jplayer_1").jPlayer({
ready: function(event) {
$(this).jPlayer("setMedia", {
wav: c,
mp3: c,
m4a: c,
}).jPlayer('play').jPlayer('stop');
$(this).jPlayer("volume", 0.9);
}, cssSelector: {
mute: '.jp-mute',
unmute: '.jp-unmute',
},
solution: "flash, html",
swfPath: "_/js/_lib/",
supplied: "mp3, m4a, wav, oga",
wmode: "window",
preload: "metadata",
nativeVideoControls: true,
volumechange: function(event) {
if (event.jPlayer.options.muted) {
$(".jp-volume-bar").slider("value", 0);
} else {
$(".jp-volume-bar").slider("value", event.jPlayer.options.volume);
}
}});

Although it is not intended for, you can achieve preloading by using the browser application cache. Create a manifest that declares your audio files url's as part of the 'application'.
https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache
http://alistapart.com/article/application-cache-is-a-douchebag
If your audio files are not hosted on your site server, make sure you do not use https: files from other sources do not get cached in this case...

Related

Is it possible to play sound effects with Android Auto using app types other than media-apps?

Is it possible to play sound effects with Android Auto using app types other than media-apps (Messaging apps, Navigation, parking & charging apps)?
When I try to play a sound effect using "SoundPool API", it is muted and there is no sound while Android Auto is running.
Is there any good way?
My Source code
https://github.com/LeoAndo/android-auto-automotive-training/blob/main/SoundPoolAutoApp/app/src/main/java/com/leoleo/helloautoapp/sound/MainSoundPlayer.kt
https://github.com/LeoAndo/android-auto-automotive-training/blob/main/SoundPoolAutoApp/app/src/main/java/com/leoleo/helloautoapp/auto/MainScreen.kt
There has been progress.
With the implementation of voice-guidance, it was successful to run the app on the DHU and output sound from the smartphone speaker.(app type: POI)
references:
https://developer.android.com/training/cars/apps/navigation#voice-guidance
https://developer.android.com/guide/topics/media-apps/audio-focus
Was self resolved. By installing the implementation of audio focus, we were able to make sound on the car side.(App Type: POI)
Reference

Android - how to play a midi file data to external midi keyboard

Following up (or should have been preceding) my last post, I am now wondering if I am on the wrong path.
I want to play midi file data (not audio) to an external device, such as a midi enabled keyboard, and have the midi data play the keyboard.
As per my last post, I have:
MediaPlayer mediaPlayer;
String music = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
mediaPlayer = MediaPlayer.create(MainActivity.this, Uri.parse(music + "/test.mid"));
mediaPlayer.start();
When I run this, it just play the midi file as audio.
Later, the next part is sending this out (hopefully) by Bluetooth, ie code sometime like form the suggestion from my last post:
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
for (AudioDeviceInfo device : devices) {
int type = device.getType();
if (device.getType() == AudioDeviceInfo.TYPE_BLE_HEADSET ) {
mediaPlayer.setPreferredDevice(device);
break;
}
}
However, is the above going to midi data, or just the generated audio? Can MediaPlayerMediaPlayer be used for this, or do I need to use something completely different such as java-midi or the MidiManager as used in these examples.
I have not got any Bluetooth midi receiver device yet (ie to play into the keyboard), as I do not want to purchase something like this, for example this, though it only claim to support iOS, but isn't Bluetooth universal?, At any rate, that is a separate topic, this is just about actually playing out the midi data
I only ever want to replay a file, I never want to actually generate the midi events, so was hoping something simpler like MediaPlayer would do what I am after, but is this correct?

Android tv box (TX3 mini) run app without connecting display

I am trying to use my android tv box (TX3 mini) like a radio. The app I build using react native and expo work and the audio does play when the app is in the background. The audio is coming through AV port and not through HDMI. However when I unplug the HDMI after launching the app, the audio stop working. Is this setting i have to configure in the Android box to keep the audio and the app running when HDMI (display) is unplug or something i have set in my app when coding? I look for setting in the code, but could not find one.
I am using import { Audio } from 'expo-av' library.
Audio settings:
await Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
playsInSilentModeIOS: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
shouldDuckAndroid: true,
staysActiveInBackground: true,
playThroughEarpieceAndroid: true
});
Once the app is running i want to disconnect the display and keep the audio playing on the speaker.
Let me know if you need more details and thanks for any input.
Thanks,
A

AudioContext audio stuttering in Android Chrome

I'm using AudioContext in an ionic app to stream raw PCM audio data to a backend, the resulting audio is has a lot of stutters if the client is google chrome on android. All other android browsers work fine (tried firefox, edge and samsung browser) also all desktop browsers work fine including google chrome.
startRecording() {
navigator.mediaDevices
.getUserMedia({
audio: {
echoCancellation: true,
},
})
.then((s) => {
this.stream = s;
this.record();
this.startRecordingStream(this.stream);
});
startRecordingStream(s) {
let audioContext = new AudioContext();
this.scriptProcessor = audioContext.createScriptProcessor(2048, 2, 1);
let input = audioContext.createMediaStreamSource(s);
input.connect(this.scriptProcessor);
this.scriptProcessor.connect(audioContext.destination);
this.scriptProcessor.addEventListener("audioprocess", this.streamAudioData);
}
I tried logging the buffer on the client side, it has zeros scattered all over it in a periodic manner.
I have also tested this example https://mozdevs.github.io/MediaRecorder-examples/filter-and-record-live-audio.html on my device, it uses audioContext and it seems to suffer from the same audio stutter on google chrome on android.
Is there any walkarounds to this?

RTSP 1080p live-streaming android client gets error (100,0)

My new surveillance camera just arrived, so I'm trying to write an app to live stream the video from it.
Since it came with basically no documentation, I installed the 'onvifer' android app which allows you to browse the camera's capabilities. This app works fine - gets the video and allows PTZ controls, etc. It reports the streaming url as:
rtsp://192.1.0.193:554/mpeg4
I tested the stream in the VLC windows client, and it's able to stream video from that URL as well. This makes me comfortable that the network is working OK.
The camera states the feed will be 1920x1080; VLC confirms this.
The basic code in my activity:
VideoView videoView = (VideoView)this.findViewById(R.id.VideoView);
videoView.setVideoURI(Uri.parse("rtsp://192.1.0.193:554/mpeg4"));
videoView.requestFocus();
videoView.start();
I've also given the app INTERNET permissions in AndroidManifest.xml, disabled authentication on the camera, and am running on a real device (not the emulator).
When I run the app, LogCat shows this immediately:
setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: rtsp://192.1.0.193:554/mpeg4
at android.content.ContentResolver.openTypedAssetFileDescriptor (ContentResolver.java).
About 15 seconds later, the app shows a "Can't play this video" modal dialog box and this is added to LogCat:
MediaPlayer error (100, 0)
AudioSystem AudioFlinger server died!
MediaPlayer error (100, 0)
VideoView Error: 100,0
I've googled everything I can think of, but haven't found anything useful.
Any thoughts?
wild-ass-guess on your logcat and the RC=100... No SDP file or no equivalent for RTSP of the 'moov atom' block required to negotiate details of the stream /container/ codec/ format... You can get the AOSP code for mediaPlayer/videoView and grep the RC value in the source.
RTSP is gnarly to debug ( note the tools links ) and not assured to run inside a NAT'd network due to UDP issues. So, to get better result, you may have to look into forcing your config to do data channel on TCP an not UDP. Or it could be other issues , of which there are many.
If you really want to investigate, some possible tools below:
Use command line and CURL client to request your stream:
Android - Java RTSP Session Mgmt package on Git
Protocol dumps for CLI RTSP sessions to Youtube RTSP/SDP streams
To pursue the issue, you may need to get into the weeds with debug tools that track details of the protocol negotiation that preceeds the MediaPlayer actually starting play on the stream. That would include learning the RFP and the protocol details.
videoView.setVideoURI(“rtsp://192.1.0.193:554/mpeg4”);
Try your app on another phone.
You may find the problem is about the mobile device.
Try this
path:"rtsp://218.204.223.237:554/mobile/1/4C024DFE77DC717D/onnuvesj43xj7t26.sdp".
See whether the code has something wrong.

Categories

Resources