Respond to local http request in Android - java

I have an application the requests a media stream from a server, however the request needs to include a cookie or else the server returns a 500 error. MediaPlayer does not have the functionality to send a cookie along with a URI request.
My way around this is to have Android proxy the requests. I'll have the MediaPlayer make a request to the localhost (http://localhost/?ID=1) and then I'll have a small proxy app make the request along with the cookie and return the media stream.
My question is how would I go about making the proxy side? How do I have my app setup a listener on localhost for an http request?
I don't need a full blown code write up on how to do it, just some simple class names and example code showing how to have an android app listen for requests from the mediaplayer.

Would I be able to create a custom intent and pass a URI to that intent i.e. (cookieplayer://songid1) and have MediaPlayer play that returned stream?

Related

How to upload videos to JWplayer server from android programmatically

I am using JW player in my Android application. Is there any way to upload videos from my client side(Android app) to JWplayer Server? I gone through
your site https://developer.jwplayer.com/jw-platform/docs/developer-guide/management-api/uploading-videos/ to upload videos but its not clear that the code given is to upload the videos from android app or from a intermediate server.
Any clarifications on this would be greatly appreciated.
What we tried from our android app side is to upload the videos using below,
POST URL : http://upload.jwplatform.com/v1/videos/upload?api_format=json&key=vtQmcboj&token=e2bbad0fd889d5d2e30047596cfe3789778257d2
The params i sent,
api_key
api_secret
local_video_path
You cannot upload videos directly to JW player since its a Two tier process.
I have been workign in a java application where the user can upload videos, watch it and download it.
You will have to send the key and the token for the auth request, which JWplayer thinks is not safe from their end so they just will not allow you to upload the videos to their server.
To acheive the scenario, you must be running your own server which instead upload the video to the JW platform. All the error responses will have to be handled in your server side if the upload gets failed.
Also, JW player handles resumable upload process. So, once you sent the data to your server, your server can send the data in small units and the interruption in connection will be handled in JWplayer end.
In my own scenario, my server will be handling the resumable uploads from client(since its not possible to resume uploads from client without having valid protocols embedded in Server side) and my it indeeds send the data's to the JW player for encoding.
To be more precise,
Client ----> Your server ----> JW player server.
The POST method URI which you tried is for server side coding and not meant for client side. You can refer their support team for more details, since i came to know these details after reaching out them.
As #DeadSpider answered,
It is not possible from client side. Go for a server and once you get it work, cheers!
Yesterday i got a demo project from JWplayer and it is absolutely possible now to upload videos to your dashboad from client side.
http://qa.jwplayer.com.s3.amazonaws.com/~george/BishopQA.zip
Check the above project and in upload activity you will have the code. Its working for both android and ios platforms.

How to implement Kurento one to one video call tutorial with websocket Sip servlet

Here is my work till now
Mobicents SIP server is running a websocket-sip-servlet for WebRTC client registration and proxy. with Sipml5 WebRTC client i had registerd and make a call audio/video after registering succesfully.
Kurento tutorial one to one video call from git is running too
kurento media server is runnig fine on port 8888.
What i'm trying,
On the doResponse of websocket-sip-servlet java file,
I'm trying to create a kurento media pipeline and send sdp of registered user to Kurento media server to get sdp response and send to registered user for media session.
similary with other user,
and later on when a one caller call to calle the video call should be established via Kurento media server.
May be my concepts were wrong or question may be wrong, please suggest me how can i achieve my task, suggestion, guiding, tutoring all are heartily welcome. Thanks in advance.

Nexmo inbound callback URL

I'm attempting to use Nexmo.com to send and receive text messages. Sending works fine, but I am having some issues receiving messages.
My issue is with the Callback URL and what format that page should be in. Nexmo's documentation is here and says this
Inbound Message
If you have purchased long virtual numbers, you will need to set up a CallBack URL for inbound to which we will send a request for each incoming message. Nexmo will be expecting response 200 OK, or it will retry.
The request parameters sent via a GET (default) to your URL include the following parameters.
Am I missing something extremely simple? Is there somewhere that I haven't found with an example of a Callback URL page? Thanks for any help!
Edit: For clarification, I'm using Nexmo's provided java library, but since their api is all built around URL's the java program simply visits a URL to send the message. Here
are their provided libraries
Not sure if I've understood your question.
Generally, if you want to receive messages, you have to setup a service on your server, with a callback url, say http://api.example.com/sms/
Then you setup this callback url in Nexmo. After that, Nexmo will access your server through the callback url, and send parameters via GET method.
And your server receives those info, and response 200 to Nexmo.

Client Communication over GAE

What is the best way for the communication between an Android app(native app) & a desktop App(C#/Java Client) over GAE?
One way I found was Channel API. Unfortunately I found no client side scripts other than Javascript supports Channel API.
Another way was to make a static class and communicate through these static variables.
This is what I'd like to achieve:
I want an Android app to send a message to GAE.
This message should be retreived by my PC App(C#/Java client)
PC App should return a response to this message
PC response should send to Mobile App.
Actually I am trying to execute commands on the windows command prompt from my mobile.
How about:
Android <-> App Engine : C2DM
Here's a good video about it:
http://www.youtube.com/watch?v=M7SxNNC429U
C#/Java <-> App Engine : Http Post/Get, create a http servlet at the app engine side.
And standard http request on c#/java.
Here's a blog about the servlet side:
http://zawoad.blogspot.com/2010/04/how-to-call-servlet-in-gwt.html
Basically this is how it works:
GAE handler receives messages from mobile device over http, and stores it to datastore. Here is an example of request which is done by movile device over http:
POST http://myapp.appspot.com/messages
Content-type: application/json
{"message":"Message from mobile device","userid":"myuserid",[other data..]}
Desktop app makes repetitive requests (every 10 sec or so) to GAE over http. GAE handler will give an empty response if there are no new messages, but if message has arrived, message is loaded from datastore and served over http, so you application will receive it. Here is request example:
GET http://myapp.appspot.com/messages?last_message_id=...
Database query example:
SELECT * FROM messages WHERE message_id > LAST_MESSAGE_ID
Response example:
Content-type: application/json
[{'id':1, 'message':'Message 1 from mobile device','userid':1},
{'id':2, 'message':'Message 2 from mobile device','userid':1}]
With Channel-API, it is possible to make one long request (long-polling) instead of many repetitive every 10 seconds. It is more efficient but it will be more difficult to implement if libraries does not exists.
I cannot recommend you specific libraries because I don't code in C# or Java, but all you need is a library which can make http requests, and also a library which encodes and decodes data in your chosen format. JSON data encoding is used in my example.

Android MediaPlayer URL's with Cookie

I have an android application that plays music from a site, however to authenticate to the stream, you need to send a cookie first I.E:
http://example.com/site/content?id=SOMEID = mp3 formatted stream
If you access the url without a cookie, you'll get a Server 500 error.
If you have a cookie, then you'll get the stream.
For the life of me, I can't figure out how to make the mediaplayer play a URL while sending a cookie.
I can play any url that doesn't require a cookie, however.
As far as I can tell you can't. Almost everything MediaPlayer does is done in native code, including opening any connections, so there is no way to access the stream it is using AFAICT.
One possible workaround is to create a web server in your Android app, have it authenticate and download your MP3 and having your MediaPlayer call setDataSource with your local server's address (something like http://127.0.0.1:8000/mymp3.mp3). You can have the playback occur while your web server class is still downloading so ideally your users would notice a difference.

Categories

Resources