I am developing an app which requires that I play a song in two phones via Bluetooth. At the time I am able to do so, but with a delay in playing sounds.
The way I am doing this is by sending a string over bluetooth which when sent tells the app to play a song and when received do the same.
Of course there will be a delay because of the bluetooth connection but the main problem is that this delay is not constant at all so I am having trouble in synchronize both well..
Any suggestions will be really appreciated :)
Related
I have music player and need to add sync play functionality with other mobile. For example if 2 or more users are using my music player and want to play same song on all devices then they just connect through same network and can play music on all devices from one device with complete music player control of all devices on single device.
Would anyone explain me which is best and how can I share audio from one Android device to another device on Sync and what are the steps to do so.
Points I know about WiFi P2P-
create connection
create socket for sharing
share a complete file
Points I want to know:-
How can I share file without storing in another device storage.
How to play sound on both devices at same position (ON SYNC).
and after Wifi P2P I want to say that I don't know about WebRTC like:-
How it works?
How to setup connection for this ?
Is it always required internet connection ?
Is same application is required in both devices to create connection between devices?
I don't know is this helpful for you or not just see the links may be you get some useful info...
for web rtc
https://webrtc.org/native-code/android/
This link will help you to know about webrtc like how it works and how to setup
Is it possible to connect 4 speakers together and these 4 speakers need to connect to a phone to play music ? I don't need the 4 speakers to play music at the same time.
I just want 1 of the 4 speakers to play music, but I need to control which one should play the music (The closest speaker to the phone should play only).
I want 4 speakers to be able to communicate with each other to vote for 1 speaker to play the music, that's why I need to connect those speakers together. There is no application required for the phone to choose the right speaker, the speakers have to choose for themselves.
UPDATE 1:
To communicate between speakers I will create a piconet between them. The speakers then update their distance to the phone to each other. The closet speaker will play music.
To calculate the distance, I wonder if I could use the Proximity Profile. Is it possile to use Proximity Profile to calculate distance in which the Phone is reporter and speakers are monitors?
Assume the 2 points are possible. Can I just disconnect a playing speaker and connect another speaker to the phone to switch playing music role?
Steps are as bellow:
Speaker 1 is playing music -----> phone is moving toward speaker 2.
Speaker 1 disconnects to the phone, speaker 2 connects to the phone.
Speaker 2 is playing music, speaker 1 stops.
UPDATE 2:
I gave up the idea of making the speaker so intelligent. Instead, I will have an application running on the smart phone to take care of distance monitoring and switching to nearest speaker.
I will accept the answer from #Floris to close this question.
Thanks
For this to work, your speakers need to be pretty intelligent - in essence each would be a little Android device. Assuming you want to give them that much smarts, then the steps would be:
each speaker is "paired" with the phone (assuming that they are connected with Bluetooth)
each speaker is "paired" with all the other speakers (so they know the others exist)
each of these pairings has its own set of communications protocols:
1) for phone-to-speaker, the closest speaker should communicate its availability to play music
2) phone-to-phone, they must compare distances. Each phone communicates its distance to the others. If in a given time period it does not seem to be the closest, it communicates "I am not playing music" to the other three. If it had been playing music until the last update, it communicates to the phone "I am out of reach" and disconnects.
3) On the other hand, if a speaker becomes "king of the hill" it should communicate this to the phone, so the phone will start sending information to it.
This leaves the problem "which is the closest" - in other words, how well does a speaker know its distance to the phone. The detailed specification explains how to get the path loss and in particular the transmit power level which is not the same thing as the distance, but a reasonable proxy (the further away you are the greater the path loss) - and in general you care more about signal strength than distance.
Finally, you need to build in a mechanism for preventing that two speakers that are "almost the same distance" start fighting each other over the channel - usually you do this by creating hysteresis (the current speaker gets a '5 point advantage' over any others, and so it will appear to be the closest unless it really isn't - at that point a new speaker becomes the master, it gets the advantage, and it will remain so until it is really no longer closest).
For "5 point advantage" you can read anything - perhaps the link loss is expressed in dB, and you report the loss as smaller than it is (e.g. if the loss is -43 dB, you might report -40 dB)
This is a big project - I have a hard time thinking of a use case (perhaps a person walking through a museum, getting the narration over nearby speakers). Good luck.
Yes, basically, it is possible. But then, if what you want is that ONLY the speakers should decide which one plays the music, you will need to program them. So you will need a chip in each speaker, or a controller that controls all four speaker, but anyways, you will need some hardware to program. In my opinion, the best way to do this, is to do this in an app, even if that's not what you want.
This is a big project...
Why?
1.) Assuming that Proximity Profile is really working... You need to know which speaker that your phone is currently connected while checking the distance of 4 speakers.
2.) I disagree for what you said about the speaker will decide on which the right speaker it will connect. Because you need to make a program in your phone that will decide for that..
If that really the case, well just like the above post you need to have wide understanding about hardware and chips. Well, I prefer make the phone decides.
3.) You need a program to check the distance of your phone to other 4 speakers every second.. and then you're gonna configure it to connect automatically (in case password is required or any other security issue) once it discovers that there's a nearer speaker.
This idea is possible... and great...
No not possible. You can not connect speakers to a phone. Not even one. Only a headphone.
I am building a small robot that I can drive around outside of bluetooth range -- so I want to send signals via the internet. The eyes and ears are an old Droid phone (running android 2.2.3). I can get the phone to talk to a bluetooth module to control the robot (tap the left button, it sends the letter L to the bluetooth, which turns the robot etc etc). I have got Skype or Tango to both give me video and sound to a pc, so that problem is sorted. The thing I cannot solve is how to send e.g. the letter L over the internet and for the phone to know what I sent. I wrote an app that checks the contents of a WebDB every second (it works), but that app stops running when I power up the video chat application. So the question is...how can I get my old Android phone to know that someone via the internet has sent the letter L via Skype or some other way, and for that to happen while I'm also running a video chat application? PS...my phone has no number, no carrier, and can't receive sms messages or calls.
You wrote:
I wrote an app that checks the contents of a WebDB every second (it works), but that app stops running when I power up the video chat application.
So the answer is simple. Write an Android Service that runs on the background and polling the internet. Read about android service, and you can see a real example in the ApiDemos. Good luck!
I am building an app that converts text messages to speech and sends them to the destination. At the other end, the speech is converted back to text messages.
I imagine it may be easy with Twilio but I don't want to use internet connection. A simple call should be enough to transmit the data.
Any idea on how I should proceed with this?
I don't think this is really possible to do, your tasks would be pretty heavy ...
TTS- that's no problem android has a library for that TTS and recording it
Make a phone call and monitor state Make phone call monitor state
Send your synthesized message - can't quite find a way to do this, seems problematic sending recorded messages over phone network it has been suggested that you could play the recording over the speaker and the microphone might pick that up, seems like a good way to introduce even more errors into the system though
On the other end something must answer - Answering a phone call
Record incoming call - this seems to be highly problematic on a non-rooted phone Recording incoming calls? or Recording incoming calls
Take the recording and do reliable STT without the benefit of a server back end, also highly problematic since the translation errors even on high end server apps are sometimes quite comical
So without a rooted phone with a custom rom I don't think all of this is possible even if you could overcome the poor quality of a double translation TTS -> STT
Twillo seems to be about making calls over the net vs. the phones digital network not about sending text (in essence) over a phone connection
Seems like a whole lot of extra work just to avoid an internet connection charge (of about 2 seconds and few bytes!)
I am writing an application that runs as a background service recording and analyzing audio recorded from the microphone. When my app is running I can't use other apps that use the microphone (e.g. phone, voice recording, etc...).
My question is - Is there a way to share the microphone stream in Android? Maybe by using the NDK? If not, is it possible to receive an indication (e.g. a BroadcastIntent) that another app is requiring the microphone?
Simple Answer would be "NO" , This is just because Audio Recording Method is synchronized. So Two or more resources can not attempt it simantenously. Doing so might sometime force close the applicatio.
I know this is old, but you may be able to kill/reactivate the microphone connection every few minutes to simulate a shared microphone resource. This is an untested hack...
Essentially:
Set a timer to disconnect from the mic every few minutes
Hopefully, if another app is trying to collect mic data, it can
while blocking other apps from collecting at the same time
Attempt to reconnect and test for data
if the other app has the mic and is blocking data then you can
try to reconnect at some time in the future.
I haven't tested this but I need a solution too so I'll post code if it works.
Recording audio/video, while other applications are running , is possible. I've done it in Sony Xperia Z1, continuously recorded videos and calls with a downloaded screen recorder. However, I do believe that this was a glitch of some sort, as it stopped being able to record after some time (about 2 months)and started showing an error which says that the microphone is being used by another application...
Yes, with Android 10 you can.
Before Android 10 the input audio stream could only be captured by one app at a time