I know that Microsoft hasn't officially supported doing any video capture applications as of yet. I've found the Clarity Consulting blog entry that highlights how to use the camera through Silverlight (entry is here: http://blogs.claritycon.com/kevinmarshall/2010/12/23/wp7-camera-access-flashlight-augmented-reality-and-barcode-scanning/). But, as of yet, I have been unsuccessful in porting the code to be used by an XNA framework.
Has anyone had any luck either using the Windows Phone 7 camera in an XNA application? If so, care to share your wisdom?
Thanks!
Generally you can access the camera the same way you do it in Silverlight - there is the CameraCaptureTask - you need to add a reference to Microsoft.Phone first and then call it from the game.
Microsoft.Phone.Tasks.CameraCaptureTask task = new Microsoft.Phone.Tasks.CameraCaptureTask();
task.Completed += new EventHandler<Microsoft.Phone.Tasks.PhotoResult>(task_Completed);
task.Show();
That would be for static capture, and your event handler is like this:
void task_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
{
// Do something with e.ChosenPhoto
}
Currently, video recording is done through the undocumented way - this will most likely get your app submission disapproved from the Marketplace, but it is possible nonetheless.
What's done that way is a MP4 file is constantly updated in the IsolatedStorage as the recording is in progress. But then again, there are methods present to include the file in the media library.
Think you are a bit unclear about the whole microsoft and supporting cameras.
Microsoft released not too long ago Expression Encoder 4 which allows you not only to video screen capture your screen but as well access all devices connected to your pc.
I would believe this would be much more ideal then being restrained to only using a windows 7 phone especially for an xna game.
Hope this sheds some light.
Nowadays you can use FileSink to save video from a CaptureSource like VideoCaptureDevice into a file.
http://msdn.microsoft.com/en-us/library/system.windows.media.filesink%28v=vs.96%29.aspx
http://msdn.microsoft.com/en-us/library/system.windows.media.capturesource%28v=vs.96%29.aspx
http://msdn.microsoft.com/en-us/library/system.windows.media.videocapturedevice%28v=vs.96%29.aspx
Related
I tired to googling that how share videos form camera roll in windows phone 8 like in Nokia video upload and facebook app. I used to try this
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff967563(v=vs.105).aspx
Only share picture but I want to share only videos for my app e.g. when my app show in list when share a video by camera roll of windows phone in sharing
To quote the link you included in your question:
Note that this extensibility is only available when the photo is a JPG
file.
And from my experience, I can confirm that it is not possible to register your app as a share target for a video file.
In other words, if a user tries to share a video from the camera roll or another app, there is no way to make your app appear as one of the options in that list.
Did you try using the share media task function?
Check this article out from the msdn :
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207027(v=vs.105).aspx
You can use MediaLibrary and there is already an answer for your question in this link. As said, there is no way to select existing sound media and video files through default choosers. Thank you.
I have an existing application developed for Windows Phone 7, which uses CameraCaptureTask.
The captured image is returned back to the app, which will be processed for grayscale conversion.
While testing the same app (same binary to be precise) in Windows Phone 8 Lumia 920, I figured that a copy of all the images captured through the CameraCaptureTask are saved in "camera roll" folder.
This is a bit annoying as the users of my app are not expecting the captured images crowding the "camera roll" folder. I looked up the documentation http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006(v=vs.105).aspx and found the below quote,
On Windows Phone 8, if the user accepts a photo taken with the camera capture task, the photo is automatically saved to the phone’s camera roll. On previous versions of Windows Phone, the photo is not automatically saved.
So far I couldn't find a way to avoid this case in Windows Phone 8.
Is there a way to turn off this feature before calling the CameraCaptureTask's Show() method in Windows Phone 8?
No. This is a consumer feature request implemented on WP8 that's transparent to developers. The usecase here is that a consumer uses the CameraCaptureTask to line up a perfect shot, doesn't use it an app for whatever reason and can't find it ever again later.
As a side-note, I actually had this happen a few times to me when using various twitter and photo editing apps and it's quite annoying.
Makes no sense. CameraCaptureTask was created to allow apps to capture photos for the app use, not for users to push them into Camera Roll. That is what Lenses are for (either custom code can write into camera roll as well).
It is not transparent to developers because one of my apps has just been removed from the WP8 market. They say because can cause "undesired upload of an app photo to skydrive".
Justin are you sure it isn't a bug? is it going to be fixed?
This forces me to break my development into 2 now: WP7 and WP8. I don't want that hassle right now...
I am developing one Flash Light application in Silverlight for windows phone 8. Currently
I am deeply stuck in one issue for the use of "Microsoft.Phone.Media.Extended" assembly. Flash Light Application for Windows phone 7 is already live in Windows Phone Marketplace and it is working very fine for Windows Phone 7 but it is not working for Windows Phone 8 because of "Microsoft.Phone.Media.Extended" dll.
After converting WP7 app into wp8 and run then I got this type of error message:
Could not load file or assembly 'Microsoft.Phone.Media.Extended,Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e' or one of its dependencies. The system can not find file specific."
According to following link for Windows Phone-specific features:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206947(v=vs.105).aspx
If you were using reflection to access the API in this assembly, because they were not publicly exposed, your app may fail on a Windows Phone 8 device. Remove the calls to this assembly and use the publicly exposed media API.
I an not understanding how to use publicly exposed media API. I used Microsoft.Phone.Media.Extended using reflaction in Windows Phone 7. Is there any direct method for accessing Microsoft.Phone.Media.Extended in Windows Phone 8 or other way to solve this?
Thanks.
==========================================================================
Edited Question:
Hi,
As per the thread, we used "VideoTorchMode" enumeration to make flashlight ON. As per that, I used AudioVideoCaptureDevice class using Windows.Phone.Media.Capture namespace with following code:
var objDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, AudioVideoCaptureDevice.GetAvailableCaptureResolution(CameraSensorLocation.Back).First());
objDevice .SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
I want to keep the flash light on but without capturing video. So, i have not initialized video capture code. The issue is, i don’t have WP8 yet and in simulator i am not able to test this.
Can any one confirm that once i put this code, my app will work as Flashlight-X where light will be on without blinking and also it will not get crashed in WP8.
Thanks
Microsoft.Phone.Media.Extended is a private API in WP7 that wasn't meant to be used by 3rd party developers. That API doesn't exist or works on WP8.
For WP8 flashlight use the AudioVideoCaptureDevice known property of VideoTorchMode=On. Also, make sure to handle failures like exceptions or devices that don't have a Camera Torch by showing a white screen.
Here's a code sample that turns on the camera flash on my Lumia 820 and Lumia 920:
var sensorLocation = CameraSensorLocation.Back;
try
{
// get the AudioViceoCaptureDevice
var avDevice = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,
AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());
// turn flashlight on
var supportedCameraModes = AudioVideoCaptureDevice
.GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode);
if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
{
avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
// set flash power to maxinum
avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower,
AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchPower).Max);
}
else
{
ShowWhiteScreenInsteadOfCameraTorch();
}
}
catch(Exception ex)
{
// Flashlight isn't supported on this device, instead show a White Screen as the flash light
ShowWhiteScreenInsteadOfCameraTorch();
}
Make sure to add the required capabilities and requirements to your WP8 app when using the camera torch (ISV_Camera, Microphone, and ID_REQ_BACK_Camera).
What about getting this assembly from somewhere and adding it to your XAP directly (try asking on XDA developers)? This might work, if it's signed and not requiring any special capabilities.
If you use the new API to "record" a video, then using the VideoTorchMode enumeration might do just want you want to create a "flashlight" effect.
I'm developing a windows phone app with a background player based on the windows phone 7.1 project template(so i have 2 projects). My question is how i dynamically set the list of tracks for the background player to play? I tried static fields but didn't work and my guess is that i have to define a resource in the app.xaml but how it is done exactly? I need to share a List and an integer.
Thanks for the help!
The audio agent won't be able to read any resources in the App object (app.xaml).
As far as I can see the only way to communicate between your app and the background audio is via the BackgroundAudioPlayer.Instance object, the AudioTrack (see especially the Tag property) and using files stored in Isolated Storage.
This is described on MSDN here.
Also check out the Background Audio player in the MSDN code samples.
I am trying to make a simple application which will store the sound said by user , say on click of record button and will play it back to him/her , say on click of play button.
Can anyone suggest me some appropriate way to do this ??
Thanks,
Miraaj
You can use QuickTime Kit's capture APIs to record a movie of the audio, and QTMovie (from the same framework) to convert it to a more conventional format for audio files and to play back both the intermediate file and the converted file.
There used to be a QuickTime Kit Programming Guide, but it didn't cover capturing and is now gone from developer.apple.com. You should file a bug against the docs.
This answer will work in a Cocoa (Mac) app. If you meant to ask about the iPhone, you should re-tag your question, as the solution will be completely different for a Cocoa app vs. a Cocoa Touch (iPhone) app.
I used direct sound to create an entire internet phone application a few years ago. Your question is far simpler, you won't have to deal with the circular buffer as critically. Direct sound is pretty main stream and you can find a lot of help with it in forums, and it's free!