I'm developing an Android app (Android 5.1) for playing the video stream from IP camera using the RTSP protocol.
I receive and display video stream using the Android VideoView's standard methods:
videoView.setVideoURI(Uri.parse("rtsp://192.168.1.13:8888/test"));
try {
videoView.start();
}
catch (Exception ex) {
ex.printStackTrace();
}
Everything works fine, but the connection to the camera takes too long.
It takes about 5-7 seconds (too long for my needs) before video starts playing.
Is there any way to speed up the connection time?
Finally found a solution.
The problem was that Android' MediaPlayer, that is a part of VideoView, has fixed buffer size that cannot be changed.
So i used Google' ExoPlayer, which provides such feature.
Making buffer size smaller resolved my problem.
P.S.
Maintaining the resource/connection with VideoView.suspend() or VideoView.pause() to resume stream later doesn't make a thing.
Related
I have voice recognition code that crashes upon launch (after the splashscreen). My app works great without voice recognition, but it is required for this app that I have it.
This Acer Chromebook 10 outside of my development has no issue with voice recognition (Okay Google, what time is it... etc.)
Here is a partial screenshot of the error I am getting from logcat on the Chromebook:
I have added permissions in the manifest (before I added this it worked on the Pixel 2XL):
<addPermission android:name="android.permission.BIND_VOICE_INTERACTION"/>
... but still get the same error. I am not launching a competing service, but rather a thread runnable activity. Here is a snippet of the code that I think that may be throwing this error (it crashes right after the splash screen so I don't even get the catch response):
try
{
_activity.runOnUiThread(new Runnable()
{
public void run()
{
// I don't know why, but we have to destroy and redo the recognizer after a failure (unlike onResult), then works great.
mSpeechRecognizer.destroy();
mSpeechRecognizer.setRecognitionListener(recognitionListener);
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
}
});
} // end of try
catch (Exception e)
{
Log.debug("Recognition failed with exception " + e.getMessage());
}
Some background - like the title says this code is working with Pixel 2XL. It is part of an in-house plugin that I've written for the Unreal Engine to support voice recognition. As such I test for the permission "android.permission.BIND_VOICE_INTERACTION" in Blueprints (a flowchart-like language for UE4) when running the code on my Pixel and it comes back true - so I know this permission is okay with the Pixel 2XL.
I get the impression that there may be a competing service causing conflict on the Chromebook specifically (ArcVoiceInteractionService?) and if this is so, I need to find out how to get around it.
I'm currently developping my first app in java.
This app requires a direct connection with my BL652, which doesn' t accept any kind of pairing option. That being said, I'm stuck with the code below, which still tries to pair with my bluetooth device instead of just connecting. Therefore, I wanted to know what am i supposed to do in order to make a connection that doesnt require pairing.
Thanks in advance for any response.
String mac_address = "DA:72:21:29:0F:F0";
private static final UUID MY_UUID = UUID.fromString("E54B0002-67F5-479E-8711-B3B99198CE6C");
lvNewDevices.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
BluetoothDevice device = (BluetoothDevice) mBluetoothAdapter.getRemoteDevice(mac_address);
try {
socket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
socket.connect();
} catch (IOException e) {
e.printStackTrace();
}
I'm not sure about connection to external hardware but it's definetly possible to connect 2 phones without pairing. I made it using Android Nearby Connections . And yeah it's basically working with BLE. As far as I know it's possible to connect to RaspberryPi using that API.
Bluetooth devices can be made to communicate with each other using master-slave configuration. I first tried with two BLE-HC05s, made one as master and the other as slave, and as expected the master is able to send data, slave is able to receive data, that can be seen using the Serial Monitor in Arduino IDE. I have developed a similar app, which connects to a BLE-HC05 device, sends and receives data. But since you are trying to get data or send data to the App on your phone, Android will not support such unpaired anonymous communications. If you are having trouble with connection or pairing Bluetooth device and your app, I may help you with that. But as far as Bluetooth communication without pairing is concerned, you may not be able to find a way.
Edit: The code to connect any bluetooth device, like BLE-HC06 as you have mentioned, is 1234 (Only if you have not changed it)
I'm currently working on a project where I need to record VOIP Calls for apps like (Whatsapp and other app that uses VOIP for calling)
I have tried below code for triggering an event when whatsapp call is made so at the same time I have started audio recorder but here is the problem
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//i have tried VOICE_COMMUNICATION , VOICE_CALL but same issue
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setOutputFile(file);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
recorder.prepare();
recorder.start();
checkRecording = true;
Log.e("Audio", "recording starts") ;
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Log.e("Audio", "recording stops") ;
recorder.stop();
checkRecording = false;
}
}, 60000);
} catch (IllegalStateException e) {
e.printStackTrace();
Log.e("Audio stop", "error "+e) ;
}
When audio recording starts and same time whatsapp call then receiver cannot listen to my voice but i can hear his voice and audio recorded only my voice - basically when recording starts it uses same audio source as whatsapp so then whatsapp block mic thats why reciever cant hear my voice
I need a way to use same audio source with multiple app so when I start recording it should not busy mic so whatsapp can also use it?
So, anyone can help to record call over voip (Android studio) or guide me where Im doing it wrong or any suggestion would help me!
And I'm making this app for Emulator which is rooted so any kernal way for this also entertain
and this question already been asked but never answered so please
anyone answer or suggest any solution to this issue
VoIP calls cannot be recorded as of now in Android.
Normal Calls dont use microphone so another app can acquire microphone and record the conversation.
But in VoIP calls, the app would be using the microphone so another app cannot acquire, if it tries it fails with an error. If the app tries to acquire microphone before the VoIP call then during the call the other side will not be able to hear anything.
So bottom line is there is no such app as of now to record VoIP calls in Android.
Cube call recorder or any spy app claiming to record VoIP calls won't record on majority of the phones (even if rooted). They might work on some Chinese phones which might be having dual microphone.
There is a need to use the built in device camera flash as a torch.
Unfortunately I don't have access to an Android device so I can only use the Android emulator.
How can I validate that my code does work?
I have been trying several times to update my app with different ways to access the camera flash and each time the app was crashed.
My app minimum OS version is 2.2,
At the moment I'm using the following code
private void turnFlashOn() {
camera = Camera.open();
Parameters p = camera.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);
camera.startPreview();
}
private void turnFlashOff() {
camera = Camera.open();
Parameters p = camera.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(p);
camera.stopPreview();
}
Haven't tested it yet.
What is your way to use the camera flash?
Thanks!
The first two errors here is that you have called Camera.open() twice and never close it. You need to open it in onResume() and close it in onPause(), and in between operate on the Camera handle you obtained.
You can debug on emulator and mock camera class (with jmockit) , but you will have to be careful - not every camera on real devices supports torch mode ( or have a flash at all) - so you will have to check whether camera object supports this.
Once you got your code working correclty, you will still have to test it on real device
( hint: you can recruit testers on android developers mailing lists if you ask politely and provide signed APK somewhere on the web so people can install it )
I'm trying to use vlcj to play live internet radio stations in a project. I've played around with some sample programs for a few hours, but I cannot get either the sample programs or programs that I've played around with to play the stream from the URL.
An example of a URL I'm trying to play is: http://network.absoluteradio.co.uk/core/audio/wmp/live.asx?service=vr
Is there anything special I have to do in order to get vlcj to play this stream? I couldn't find anything to help in the API. (Assuming it can because it can be played through the VLC media player!)
Thanks a lot
Ok, the MRL you have provided us http://network.absoluteradio.co.uk/core/audio/wmp/live.asx?service=vr is a MMS server that may pull a ASX (XML) metafile which may contain at least one sub-item.
http://all-streaming-media.com/faq/streaming-media/Metafiles-ASX-Advanced-Stream-Redirector.htm
To be able to play this type of streaming media and go through each sub-item, you need to do the following code snippet:
VideoPanel.getMediaPlayer().setRepeat(true);
VideoPanel.getMediaPlayer().setPlaySubItems(true);
VideoPanel.getMediaPlayer().prepareMedia(media, options);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for(String s: VideoPanel.getMediaPlayer().subItems()) System.out.println(s);
VideoPanel.getMediaPlayer().play();
For the example MRL above, it will list down all sub-items as follows:
http://wms.absoluteradio.co.uk/g1/absoluteradio.co.uk/prerolls/ar_account_1310455302_hi.wma
mms://wms.absoluteradio.co.uk/absoluteradio.co.uk/vr_lo?u=
http://wms.absoluteradio.co.uk/absoluteradio.co.uk/vr_lo?u=
mmsu://wms.absoluteradio.co.uk/absoluteradio.co.uk/vr_lo?u=
mmst://wms.absoluteradio.co.uk/absoluteradio.co.uk/vr_lo?u=
mms://wms.absoluteradio.co.uk/absoluteradio.co.uk/prerolls/problems_lo.wma
To stop playing all of them, set the following code snippet:
VideoPanel.getMediaPlayer().setRepeat(false);
VideoPanel.getMediaPlayer().setPlaySubItems(false);
VideoPanel.getMediaPlayer().stop();
For a better explanation, refer to: http://code.google.com/p/vlcj/wiki/HowToHandleYouTubeMedia
You cannot use the http to play such link directly. You will ve to use the port number of the radio station router. this is because if i want to receive my home live video streaming from the internet at my workplace, i type the following on url: http://my dns server ip address:8080 The 8080 is the port number I opened on my router.