Programmatically call default media player in Blackberry? - java

Like I said, the application has to call the default Blackberry media player.Does anybody know or maybe point in a direction to implement it
Enviroment : Eclipse+BB plugin 4.5

There are two ways to do this.
The first approach would be to use the content handler mechanisms of the device. You'll essentially be forcing the device to deal with a given file in a default manner. For audio files, the default manner would be to launch the media player on the device with the file.
So, for example if you have a file called song.mp3 on the SD card on the device, you would do something like the following (code is from memory, haven't checked it in a while):
Invocation invocation = new Invocation("file:///SDCard/BlackBerry/music/song.mp3");
Registry reg = Registry.getRegistry("net.rim.device.api.content.BlackBerryContentHandler");
reg.invoke(invocation);
The second approach would be to use the content handler in the BlackBerry web browser to, essentially, accomplish the same thing. In the case of a browser, you can use the standard classes related to net.rim.blackberry.api.browser.BrowserSession to launch an instance of a browser with the URL to the music file. The URL can be something on the web, or, as above, it can be a file:// location on the device itself. This will cause the browser to deal with the content, which will essentially launch the music player and play the file.

Related

Android: Retrieving shared preferences of other application (rooted device)

I am running a vulnerable android application on a rooted device using the Genymotion and i am trying to read shared preferences and a file in files directory inside different android application like:
/data/data/xxxx/config.xml and
/data/data/xxx/files/xxxx.xml
i am trying to read this data programmatically using a sample java application to show the data in logcat, but when i try to read the files, i get permission issue on the logcat.
The funny thing is the application is running on a rooted device, so i suppose to have access to other applications sharedpreferences.I need something like this, but show this in the logcat:
https://lightsec.wordpress.com/2014/04/28/android-sharedpreferences-insecure-storage/.
I have also tries this answer, but it does not work:
Android: Retrieving shared preferences of other application
How can i retrieve all the available keys from sharedpreferences and show in logcat?
Both of those links describe using the WORLD_XX constants as in the app you're trying to read from.
Literally no one in the world would use those constants, as they don't want their shared preferences to be read by others. Everyone uses the MODE_PRIVATE constant, so they can't be read by others.
To achieve this, you'll need to do the following:
1) Request Root Access in your app (Having a rooted phone is NOT enough). (A library like RootTools can help you do this)
2) After you get root access, then you have to read the raw .xml file from the file system, and parse it accordingly. Then you can read all the data, and even write to it if you wanted.
Sounds a bit like you're confusing having a rooted phone and your app having root access, those are different things.

How to capture (record) video stream that enters to my browser?

Imagine you watch sports live in your browser. It means you receiving a video stream, right? I need to record this stream and save to disk. The problem is that I don't have a clue from where to start. I'm not new to programming, but have a little experience in live video streaming.
I see this problem divided into this parts:
1) Parse html page and find live source URL. (? sounds silly, I'm not sure it is easy to find URL)
2) When I have URL everything else becomes easy. I would use Java for example, to receive and record stream.
So the main problem is to find live source URL. Does anybody know how to do that?
a) From HTML5 video player
b) From flash player
I had similar concerns before the best think I can suggest would be ;
For the first option :
open browser developer tools or wireshark and monitor the network while watching the video this is the most efficient way of locating the video source than you can just download the stream from the link
The second option :
there are some java libraries(jentpcap,jpcap ) for capturing ip packets after capturing the network adapter a while, you can filter them by type such a mpeg and get destination url note:some servers are sending these video samples as fragments you might need to merge them after downloading.
one more suggestion is gstreamer , as far as I know it has java wrappers and it is very useful for recording live videos to a file.
If the sport you are watching has any sort of value then it will most likely be protected by DRM and you will not be able to do what you are suggesting on your PC/laptop.
You can still capture the file but as it is encrypted you won't be able to play it back.
If it is not protected by DRM then finding the URL from the source can work - it depends on the video file type and whether the server is using any sort of authentication before mapping the URL sent from the browser to the URL of the actual video.
You also likely need to understand the type of URL - not all videos play in all devices, and some video URL's actually point to a manifest or 'index' file which then contains the actual URL's for the individual video and audio streams.

Passing string/path arguments on my main program to open image files

I'm trying to make a program similar to Windows Photo Viewer, the program that pops up usually if you double-click an image in Windows. I've already made my own program, however it uses a JFileChooser associated with a button to bring up images to open inside the application itself (Windows photo app doesn't seem to do this).
Question:
How can I make my application handle certain file types when its double-clicked from Windows? My guess would be something along the lines of my main class having a Path/String type argument of the file I want to open, but I'm not sure how to exactly implement that.
What type does Windows pass to a program whenever we open a file? String?
Once my first question is fixed, is there anything special I would need to do to associate my program to image files (when making .exe file or installer)?
Include a java-web-start <association/> tag as a "hint to the JNLP client that it wishes to be registered with the operating system as the primary handler of certain extensions and a certain mime-type." Note that " the <offline-allowed/> element must also be included." A web server is not required and a platform-specific <shortcut/> is optional. The file to open will be a command line parameter.

sound recognition in web

I am building a web page where i need to do something when a particular sound is caught by the microphone. I searched a lot and found this link :
Write a Program Which Recognizes a Sound and Performs Action
I am stuck at two things:
how to use java based sound recognizers though a webpage or
javascript
how to match two sounds (one from the mic. and other from saved file) using any recognizer
For sound recognizer, I am using Sphinx-4 .
To use java sound recognizers, you will need to: either submit/stream the content recorded in the browser, or use a local processing (applet/javafx).
An applet/javafx might not be a bad idea at all; since recording might yield a large data blob, you can do the processing in the local machine. My bet is that the applet will need to be signed to access the mic. You could also stream the audio data to the server, websockets might be a cool shot.
For Javascript, i think you need to use HTML5 for microphone recording or Flash.
For audio comparison, i think you want audio fingerprinting. That is a summary of the audio file. You need to search your own database for the "best match" from what you got among what you have.
I'm not sure Sphinx is the man here. Both Musicg and MusicUri have audio fingerprinting.

How can I convert one slide of a PowerPoint file to flash in jsf app (using javaSE/javaEE)?

I need to show the first slide of a PowerPoint presentation in my jsf app. It must look something like that:
user upload the .ppt file to jsf app
the app take the first slide and converts it to Flash
user sees the converted slide in the separate (not as part of the another page)
I suppose that I couldn't use any external converters because the user of the system will not have them when he uses our system.
Also I'm thinkinig about Flash, not HTML, because the presentation can be dynamic.
Any ideas? Can I do this task or it's impossible and I need to think in another way (maybe restriction for end users - to save presentation as png, but I think that my boss won't like this decision).
Maybe I need to look at .xslt format, maybe it would help?
suppose that I couldn't use any external converters because the user of the system will not have them when he uses our system.
You can truly use external tools since your Java/JSF code runs at the webserver, not at the webclient (webbrowser). All the webbrowser get is just the Java/JSF-generated HTML/CSS/JS code. Open a page in webbrowser, rightclick and View Source and see it yourself. You just install the external tool at the webserver and execute it there.
To upload a file in JSF, you'll need to grab a 3rd party component library since the standard implementation doesn't have an upload component, for example Tomahawk's t:inputFileUpload or the one of whatever component library you're currently already using.
To convert PPT to Flash, execute the appropriate action using external tool in the managed bean action method and store the Flash file somewhere in the local disk file system of the webserver. You can store it in the public webcontent so that it's directly accessible by URL, but those files will be lost whenever you redeploy the webapp. If this shouldn't happen, then store it outside the public webcontent.
I don't have hands on experience with PPT-Flash converters, so I can't recommend a specific one, but Google learns me that there's pretty a lot of choice. There seems to be a Java solution of iSpring.
To display the Flash file, use the HTML <object> element which points to the URL of the Flash file. If the Flash file is stored outside the public webcontent, then you'll need to create a Servlet which gets an InputStream of the file from the local disk file system and writes it to the OutputStream of the response along a correct set of HTTP headers and then let the URL of the <object> element point to that instead.

Categories