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.
Related
I'm trying to create an OSGi bundle that'd be installed on a eurotech gateway (reliagate 10 05).
This bundle would essentially connect the gateway to a BLE device.
To do so, I use a framework provided by eurotech called Everyware™ Software Framework (ESF) that adds up an extra layer on top of the kura v1.2.0 framework.
The catch is, the BLE device only accepts random static address type.
I managed to connect the gateway manually to the BLE device using the following commands in console:
hcitool -i hci0 lecc --random <BD_ADDR>
then
gatttool -i hci0 -b <BD_ADDR> --interactive
This works fine. The hard part is when I try to do the same thing in code using the ESF/kura framework.
Here's a snippet from a sample I use that I found on this page
public boolean connect(String adapterName) {
this.bluetoothGatt = this.device.getBluetoothGatt();
boolean connected = false;
try {
connected = this.bluetoothGatt.connect(adapterName);
} catch (KuraException e) {
logger.error(e.toString());
}
if (connected) {
this.bluetoothGatt.setBluetoothLeNotificationListener(this);
this.isConnected = true;
return true;
} else {
// If connect command is not executed, close gatttool
this.bluetoothGatt.disconnect();
this.isConnected = false;
return false;
}
}
Here is a list of some objects that the sample uses to scan and establish a connection:
org.eclipse.kura.bluetooth.BluetoothAdapter;
org.eclipse.kura.bluetooth.BluetoothDevice;
org.eclipse.kura.bluetooth.BluetoothGattSecurityLevel;
org.eclipse.kura.bluetooth.BluetoothGattService;
org.eclipse.kura.bluetooth.BluetoothLeScanListener;
org.eclipse.kura.bluetooth.BluetoothService;
org.eclipse.kura.bluetooth.BluetoothDevice;
org.eclipse.kura.bluetooth.BluetoothGatt;
org.eclipse.kura.bluetooth.BluetoothGattCharacteristic;
org.eclipse.kura.bluetooth.BluetoothLeNotificationListener;
So I searched through the api doc but didn't find anything.
Though, one interesting SO post mentions a command code to send to the device.
I found a method in kura framework that might help.
Here's the signature:
void ExecuteCmd(java.lang.String ogf, java.lang.String ocf, java.lang.String parameter)
but I couldn't figure out the OpCode Group Field (ogf) associated to the OpCode Command Field(ocf) in any documentation (I skimmed the ~2300 pages of the Bluetooth 4.0 core spec). If anyone knows where to search... :)
In the end, the question is: is there a way to set the address type to random (as with the hcitool command) with the kura framework ?
Or am I totally misleaded ? :/
Anyway, I'm really new to the kura and ble ecosystems so, sorry if it looks like an obvious thing to do but I feel like I'm running out of inspiration and could totally use a hand!
PS: Congrats if you made it to the end!
Haha lol. Kura seems to just start a gatttool process, send commands in text, and parse the output as its interface...
Here is where it is stated, using the address as parameter: https://github.com/eclipse/kura/blob/0339ac787f90debdfc270c1dee0c16de16ea6f7e/kura/org.eclipse.kura.linux.bluetooth/src/main/java/org/eclipse/kura/linux/bluetooth/util/BluetoothUtil.java#L319. Unfortunately the Kura developers seem to have missed that there is something called Random Address in the BLE standard and I don't see how that could be worked around using the current API.
Okay so for those who find themselves in my position in the future, I just received an answer from the Eurotech support team.
Dear Mr. Carneiro,
[...]
Regarding the random BD_ADDR, this is a configuration of the BLE device.
So, your BLE device is advertising an address of type random, not public, and you should specify the address type on the connection string, as you already did.
Unfortunately, current Kura Bluetooth API doesn't provide a way to specify the type of address into the connection string. We are developing a new set of APIs for BLE that will be available on preview on the next Kura/ESF release, but the Reliagate 10-05 will not support these yet.
I want to test some scenarios on my app when there is no Wifi connectivity, I need to first LogIn on good connection and then switch off the Wifi and continue doing some activities, Is it possible to disable and enable the network by code? I am using Java/Selenium and Appium Server.
Some potential on this topic is contained over here.
You can try creating a class of yours which includes an instance of NetworkConnectionSetting in the java-client of appium and set the flags accordingly by calling the built-in methods.
try{
((HasNetworkConnection) appiumDriver).setConnection(Connection.ALL);
assertEquals(Connection.ALL,((HasNetworkConnection) appiumDriver).getConnection());
// NetworkConnectionSetting ncs = new NetworkConnectionSetting(false, true, true);
((HasNetworkConnection) appiumDriver).setConnection(Connection.NONE);
assertEquals(Connection.NONE, ((HasNetworkConnection) appiumDriver).getConnection());
}
catch(Exception e)
{e.printStackTrace();}
}
This class 'NetworkConnectionSetting' works on Android. As per the request, the need is for iOS app.
I only can recommend you use the Network Link Conditioner app from Apple. For more information please read NSHipster blog.
Does the native code of the VideoView give access to the received packets of the video before or after decoding it? I need to access these packets in order to transmit them to another device. The initial solution is to modify the Android native code. Other possible solutions that I found are to use GStreamer or FFmpeg libraries.
I need bit guidance in order to achieve that goal.
Assume the phone is rooted.
Short answer is no, not that I know of.
Long answer is that you haven't given enough detail. What data exactly do you need access to? Are you writing an application, or modifying your OS to do this to other applications?
The code that actually fetches a remote video is in MediaPlayer and is native. See the following method in MediaPlayer:
private void setDataSource(/* snip */) throws /* snip */ {
/* snip */
else if (scheme != null) {
// handle non-file sources
nativeSetDataSource(
MediaHTTPService.createHttpServiceBinderIfNecessary(path),
path,
keys,
values);
return;
}
/* snip */
Unfortunately for you, almost all of the relevant MediaPlayer code is native, and if not, it is private (so subclassing will not work here).
However, depending on what you need to do, you could possibly override VideoView method setVideoURI(Uri, Map<String, String>), which is public. Here you can grab the URI and then proxy it through your own web service, or something. This isn't quite what you were asking, though.
Or, you could possibly look into modifying the Surface that is drawn to by MediaPlayer. Most of the relevant code is still native though.
The final possibility that I'll mention (there are probably hundreds of possible approaches) would be to modify the MediaHTTPService class. This appears to be used by MediaPlayer, but I can't be sure because if it's used, it's used in native code.
This answer recommends finding the native code at androidxref.com
Edit:
As requested, here is a little more detail about what the "proxy server" solution might look like. I don't know the implementation details on Android.
Basically, when you get a URL to play in the VideoView, you pass it to your own server instead. Something like startProxyServer(videoUrl). This starts a server, which downloads and then re-hosts the video. To get this working locally, start a webserver listening on localhost. The server just downloads the video at videoUrl, saves it locally, and then hosts it at localhost:port/?video=${videoUrl}.
So in very high-level pseudo-code the server could look like.
public void startProxyServer(String videoUrl) {
int PORT = 28641; // random port
File f = downloadFile(videoUrl);
saveFile(f, '/path/to/server/storage');
startWebServer('localhost', PORT);
}
So now you give localhost:port/?video=${videoUrl} as url to the videoView instead. Also, now other videoView instances can download from that same localhost url.
To make it work with other phones, your server of course couldn't run on localhost.
Of course I've not implemented this, but it's just one solution I can think of.
I am currently on working on my university project which involves GStreamer audio streaming.
I have successfully managed to get streaming working between client/server and TCP.
My next task is to dynamically change the audio stream on user input.
I tried the following:
pp.setState(State.PAUSED);
pp.setState(State.READY);
pp.unlink(src);
source = ElementFactory.make("filesrc", "src");
pp.link(source);
source.set("location", fpath);
pp.setState(State.PLAYING);
fpath is the audio file location. When a user input is received, the state is set to PAUSE, the source is unlinked and a new source is added. The state is set to PLAYING.
I used GST_DEBUG on client side and there are no errors, buffers are sent to the client but no sound.
Any suggestions would be appreciated.
You don't need to unlink and add a new source. Just go straight to READY (no need to go to PAUSED and then to READY, this will happen implicitly), set a new location and go back to playing.
you need to syncStateWithParent();.
I am using it for different purpose but this can be extended to your application on property change Gstreamer: Pausing/resuming video in RTP streams
I know that by using AT commands we can control the handset.As example unlocking screen we can give a specific AT command or moving right to the menu or left or bottom or up we can give specific AT commands. What all are the AT commands for doing this kind of control.
Thank you.
From what I understand, the AT commands are more used for phone-type functions (making calls, or sending SMS, etc), rather than menu navigation, etc.
I'm not entirely sure if that was your end-goal after menu navigation, but you can find more details here: http://en.wikipedia.org/wiki/Hayes_command_set (the original +AT command set)
If you wanted to send SMS from a handset connected to your computer you might want to take a peek at this page: http://www.developershome.com/sms/atCommandsIntro.asp
If you wanted more control when performing functions, like sending SMS, etc, you might want to investigate "PDU Mode."
It is entirely possible that some handset manufacturers may have implemented additional +AT commands to allow other functions to be performed, so you might do better by specifically searching for the commands related to the handset you are using.
(Of course, if you're having issues connecting to the handset hardware itself, you need to ensure you have either the javax.comm extension or some favoured Java USB API installed)
If post doesn't help, perhaps you could provide more details in your question? (eg. what you are ultimately trying to do, if you think it would help)
List of AT commands
sample java code to use AT command
public void servicesDiscovered(int transID, ServiceRecord serviceRecord[])
{
String url = serviceRecord[0].getConnectionURL(1, false);
try
{
//ClientSession conn= (ClientSession)Connector.open(url);
StreamConnection meineVerbindung = (StreamConnection) Connector.open(url);
if(conn== null)
System.out.println("Kann Service URL nicht oeffnen\n");
else
{
OutputStream out = conn.openOutputStream();
InputStream in = conn.openInputStream();
String message = "AT+CGMI\r\n";
// send AT-command
System.out.println("send AT Comand request: "+message);
out.write(message.getBytes());
out.flush();
out.close();
byte buffer[] = new byte[10000];
// read the response from mobile phone
in.read(buffer);
System.out.println("AT Comand response: "+buffer.toString());}
}
catch(IOException e)
{
System.out.println("Service Error(3): "+e.getMessage());
}
}