I have the following code:
MediaPlayer media = new MediaPlayer(MediaManager.createMedia(thePath, true));
media.setAutoplay(true);
video.add(BorderLayout.CENTER, media);
that works. I want that the users can continue to "listen to" the video if they want to put the smartphone in their pocket. It can make sense when the video doesn't requires to be watched (like for a talking, a conference or other similar talking videos). Usually an user presses the hardware button to power off the screen before putting him/her smartphone in the pocket, that means to put the app in the background (I'm not sure if it's exactly as putting the app in the background, please correct me if I'm wrong).
Moreover, I want that the users can continue to "watch to" the video if they put the app from background to foreground.
How can I implement this use case with Codename One?
In this blog post https://www.codenameone.com/blog/material-icons-background-music-geofencing-gradle.html, there is a section about "Background Music", but this use case is different. I need "Background video".
For iOS the build hint ios.background_modes=music build hint should work. Android might be more problematic as it requires a different media API call and right now that media API call is designed for audio.
It's possible that you can detect suspend (stop call) and stop the video playback then switch to MediaManager.createBackgroundMedia() and continue from the same offset. Then detect the start() call to resume the video. I haven't tried this though and I'm not sure if it's the right way to do this.
Related
Part of the process used in my app involves taking a photo (done with Capture.capturePhoto()). The photo is then resized to a small square of 200px and finally sent to a server.
I am able to delete the resized image with FileSystemStorage.delete() however the initial photo taken with Capture.capturePhoto() cannot be deleted because of the app being sand boxed (as described in this SO question )
This can be embarrassing for the user because these photos are polluting their gallery (the photos have no value for the user).
As deleting the initial photo is not possible, I was wondering if I could force the Captured photo to be stored in cache so that it gets automatically removed by the OS.
Maybe this question could be a solution for Android but I would prefer to avoid having to go native?
Consequently is it possible with Codename one to take a photo that will only be temporary and be deleted automatically ?
Thanks a lot,
Cheers
We try to delete the file automatically but since the OS takes the photo some platforms just stick it in the gallery and there isn't much we can do there. It's literally a matter of "this works on Android device A and fails on Android device B".
Apps like snapchat etc. don't use the device camera app but instead use the low level camera API's which are more complex and flaky. At this time we don't map these API's in Codename One so if you need something with lower level control you will need to use native interfaces. This is a non-trivial API though.
I’m about to deploy an application without a GUI or console-output. It works flawless but the application icon bounces for like 5 minutes after launching in the dock.
I want to keep the dock-icon (so no LSUIElement=1) but get rid of the bouncing.
Any ideas?
If you your application to appear in the Dock, it will need to have a Cocoa event loop and some amount of GUI (I believe it'll need at a menu bar, at a minimum, and should be able to at least handle a quit event).
Depending on what your application is and how it works, this may or may not be feasible. You'll have to provide more information for us to provide more specific advice.
I have a simple digital signage solution with a presentation application in WPF. I would like to "monitor" it from my remote machine. I would like to send a stream of the content the application is showing now (images, video, userControls, etc.).
How to do this, do i need to manually take a screenshot and send it in a video stream to my monitor - how to encode it into a stream the monitoring application can playback (that one is also WPF).
Ok, if snapshots are ok then I've done this before. The way I did it was to take a "screenshot" of the app (using code you can find here: http://www.grumpydev.com/2009/01/03/taking-wpf-screenshots/ ) then have the signage app spin up a webservice (HttpListener, WCF or SelfHosted Nancy) that returns the current screen whenever a request is made to a particular url. You monitor app then polls that url however often you need to.
This was done to monitor an interactive game for a Surface device, and didn't seem to cause any perf issues, so should be fine for your needs.
I have a WPF application in which I'm using SoundPlayer to play several short sounds such as keyboard clicks. Sometimes, seemingly at random, the sounds will stop playing. When I navigate away from the page the sounds will then play all at once in one screeching playback.
My question is, are there any obvious reasons as to why this would happen?
I've tried several things but because I can't consistently reproduce the issue it's hard to find the cause. The sounds are used throughout the application, so I load them in app.xaml.cs into an application scoped static collection. I call SoundPlayer.Load() to ensure they're loaded into memory straight away.
Like I said, this never stops working completely. The play backs seem to pile up until navigating to another page where they all play at once.
One other thing that may have an impact is that I am displaying a webcam feed in the application. The webcam feed is loaded using the DirectShow.NET library. I'm not sure if loading graphs can have any adverse effect on the playback of sound.
I suppose the web cam is updating a UI element which will cause the UI thread to be pretty busy, in that case you probably do not want to use SoundPlayer.PlaySync() or SoundPlayer.Load which both block the current thread.
Instead try SoundPlayer.LoadAsync() and SoundPlayer.Play() which use a separate thread.
Suppose there is a Silverlight streaming video player on a random web site. How can I intercept the video stream and for example save it to file - i.e. the real source of the file.
I know some of the sites embed the source in tag - or at least that was the case with Flash. But sometimes, players are smarter than that and call some logic via web service. It is still possible to figure everything out by analyzing the .dll with reflector, but that is hardcore! Every player may have a different logic, so I figured out it would be easier to just get the current stream somehow.
Any thoughts?
Ooook! Got me an answer that could be used as a nice workaround. With the use of fiddler I was able to capture the traffic and figure out what's going on. Now I'm happily watchin the same video as before only using the uber feature of WMP that lets me play videos faster.