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.
Related
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.
Application use: I am creating a connection between a tablet and a desktop. This tablet will send command to my desktop that my java app will then interpret and do accordingly. One of these features I would like to include is controlling Skype. Such as focusing on it. Switching chats. Initiating call. Sending message. ect. But I can't seem get the URI api to work. (This is the only known api that will allow me to initiate calls and chats, so if you know of any other. Please do tell.)
I am not sure If I am doing it right being that this is my first time using a URI ever. This is what I have using
import java.net.URI
public void uriTest(){
try{
URI uri = URI.create("skype:echo123?call");
}catch(Exception ex){
ex.printStackTrace();
}
}
What am I missing? I know it is probably a lot. Is there some sort of way to implement it. Or when you call .create() does it automatically do it for you?
Any help or clarification will be greatly appreciated.
Your code constucted an URI and now you have one, nothing more, nothing less. An URI is - as the name "Universsal Resource Identifier" says - just an identifier.
What you probably want to do is establish a connection to a location identified by that URI. So you need a special identifier, a so-called "Universal Resource Locator" or URL:
URL url = new URL("skype:echo123?call");
Still nothing happening since we only defined a location. Next you have to connect to it:
URLConnection conn = url.openConnection();
Now you got an URLConnection-object (in this case a HttpURLConnection) and you can operate with it: post data, read responses etc. Read up on the API of java.net.HttpURLConnection to learn more.
You should write a web application, and deploy it on a web server program such as Tomcat, on your desktop machine. You can then write an app on your tablet which would connect to the server and send commands to the server.
The web application could parse the commands and do something with Skype application running on the desktop.
You would probably write a JSON api and deploy it on the Tomcat server, and then invoke the JSON api from the tablet app.
My Android app uses curl to make network calls. I want to find out how I can get the URL that's present in the WiFi proxy auto config in an android device, inside of my application to actually be able to route the charles call through the proxy URL retrieved from the PAC file ?
This question is old, but this might be interesting for anyone else coming from search engines:
Do you know which URL the PAC resides on? If not, I would try to connect to the same WiFi with a PC and do a wireshark trace. When you initiate the connection to the WiFi, an option 252 is sent with the DHCP-lease, specifying where to download the PAC-file from. For example, your client might be told to download http://pac.yoursite.com/pac_file.txt - - - or simething like that.
Then, you can open a browser and navigate to that url, which will download the PAC-file for you to read as JavaScript.
I am developing a context aware mobile application. I need to have information about the capabilities of terminal devices and network characteristics such as current bandwidth. My question is, are there APIs in android to access this information?
Thanks.
The better question is, are there APIs for these terminal devices to access the information from outside. Of course you can get the bandwidth of your phone to the provider, but to get that info of the terminal device, you need to access their data.
I would suggest a three-way request for that. At first there is a webservice, in your language of choice, e.x. PHP, which has to get access to the terminal device. That device has to publish their data somehow, so thats the first point you need to know.
Then this webservice cleans the data like you need it and publish it as xml or json or whatever.
Then your App in Android acceess the service to get the info and parse it into your app.
There are alot posts here to find out, how to get a HTTP Request Result. For parsing XML you can find something here:
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
For accessing a network device with a specific port an such stuff, you can use PHP with the function fsockopen()
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?