Is a .mp4 video file recorded in the WP Emulator ready for outside storage? - windows-phone-7

MS have released some code examples where a video is recorded in the WP Emulator and then saved in isolated storage. Is this .mp4 file ready to export away from the WP Emulator and play in other applications? Or is it needed to format it in some way or the other? If so, how to do it?
http://channel9.msdn.com/Shows/Inside+Windows+Phone/Inside-Windows-Phone-16-Mango-Camera-APIs
Source code for video recording is located in the WP project is called CameraUpload:
https://skydrive.live.com/?cid=bc58fec5c97e307a&sc=documents&id=BC58FEC5C97E307A%21295
http://msdn.microsoft.com/en-us/library/hh394041(v=vs.92).aspx
Edit:
I am trying to upload a video recorded in the WP Emulator to Azure blob.
A file does get uploaded, but I am not able to play that file in Zune.
I would like to be able to play the video file recorded in the WP Emulator on Zune, what to do to enable this?
The method in the Azure WCF service role, which saves the video looks like this:
(Please forgive if the method parameters have slightly misdirecting and confusing names.)
bool SaveImage(int salesItemId, string contentType, byte[] photo);
The video is saved to a blob container named "firstmay".
The code in the phone client saving the video looks like this:
client.SaveImageAsync(77, "mp4", GetPhotoBytes(m_capturedFileName));
public byte[] GetPhotoBytes(string fileName)
{
using (var appStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream isoStream = appStorage.OpenFile(m_capturedFileName, FileMode.Open);
byte[] buffer = new byte[isoStream.Length];
isoStream.Read(buffer, 0, (int)isoStream.Length); isoStream.Close();
return buffer;
}
}
When uploading a video from the WP client application, one first records a video and then uploads it by clicing "Save", it all goes on in the MainPage.
The client and server application can be downloaded from skydrive:
https://skydrive.live.com/redir?resid=159250F5CE7FE134!118

That'll all depend on what you want to be able to play back the content on. PCs with Zune would be fine, and I'd expect other video capable mobiles to be fine, but older mobiles, or standard Vista installs would require additional software, or transcoding of the video to be playable.

Related

How to get video thumbnail of a video file in windows phone 8?

I want to get thumbnail of a video file which uri or path is given. I have searched for api in windows phone developer site bt with no success. If anybody have does this please help me.
There is a method GetThumbnailAsync in class StorageFile which intended to retrieve thumbnail of image and video files. So despite the fact that MSDN states that this method throws exception and not supported for Windows Phone 8, actually this method works when invoked with parameter ThumbnailMode = ListView. But I seems that using this method requires ID_CAP_MEDIALIB_PHOTO_FULL.
var files = await KnownFolders.CameraRoll.GetFilesAsync(); // Throw UnauthorizedAccessException without ID_CAP_MEDIALIB_PHOTO_FULL
var storageFile = files.First();
var thumbnail = await storageFile.GetThumbnailAsync(ThumbnailMode.ListView);
Video Thumbnail code in c# windows phone
First we use capturesource.completed then after we create the thumbnail and use that thumbnail
and we use capturesource.Imageasync()
And this is the only way to generate the thumbnail image from video file.

Play remote mp3 using Song.FromUri

I am trying to play audio files hosted on Azure blob. I serve them up over HTTP (not HTTPS) and I use SoundEffect.Play from a stream I open using web client. This works great with WAV files.
WebClient wc = new WebClient();
wc.OpenReadAsync(uri);
wc.OpenReadCompleted += (s, e) =>
{
try
{
var sfx = SoundEffect.FromStream(e.Result);
FrameworkDispatcher.Update();
sfx.Play();
}
catch (Exception ex)
{
Debug.WriteLine("Well, crap!");
}
};
For MP3s, I use this method:
var song = Song.FromUri(item.Title, uri);
FrameworkDispatcher.Update();
MediaPlayer.Play(song);
It works in the emulator, sometimes, but NOT on a device! I even tried not using Zune to deploy and use WPConnect to deploy the XAP directly to the device (some folks said this made it work)
This is driving me nuts! These mp3 files should just play, right?
Whether you can play an MP3 or not very much depends upon the specifics of that file.
See
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff462087(v=vs.105).aspx#BKMK_AudioSupport for details of the MP3s that are supported.
Please also note that the codecs supported by devices and the emulator have some differences so there are cases where you can play something in the emulator but not on a device.

Windows Phone leave background music playing

My Windows Phone app was rejected because when I play a sound in the browser in my app it stops existing background music from playing (rejection issue 6.5.1).
How do I update my application to not stop background music?
My JavaScript is something like this:
var mySound = new Audio(soundpath);
Sound.play(mySound);
I could not find anything in Microsoft.Xna.Framework.Media that handles how the app handles browser sound, but maybe I missed something?
What you are looking for is from the xna soundeffect
Here is what I use and it works for me great for all my sound effects.
(You cannot use music with a 'soundeffect' object, as it will not pass the windows store qualifications. You have to use the MediaElement for music)
I can’t remember which you need but I have all these includes
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
and this function
private static void LoadSoundEffect(string fileName, SoundEffectInstance mySound)
{
var stream = TitleContainer.OpenStream("Sounds/" + fileName);
var effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
mySound = effect.CreateInstance();
}
If you use a SoundEffectInstance, you can start,pause,stop the soundeffect etc. without all the problems.
SoundEffect works as well, but I prefer the SoundEffectInstance.
Edit: If you use soundeffect, it will not effect the music being played.
I'm assuming that you are building a native Windows Phone app (.XAP) and then using a browser control to display your app content. If that is the case, you have checks that you will need to perform when the app is first opened. Below is a description of how to resolve that issue.
You will need to add this piece of code to your app (I suggest you check this every time your app loads/opens). Add a reference with the using statement as well for the Media.
if (Microsoft.Xna.Framework.Media.MediaPlayer.State == MediaState.Playing)
{
MessageBoxResult Choice;
Choice = MessageBox.Show("Media is currently playing, do you want to stop it?", "Stop Player", MessageBoxButton.OKCancel);
if (Choice == MessageBoxResult.OK)
mediaElement1.Play();
}
If the user allows or disallows the media to be played you must put checks in your JavaScript for this. You will fail certification again if the user says "Cancel" and you play music anyway.
There is more information on the topic here.

Extrading Metadata of an audio streaming file (MediaElement)

I just started to develop for the Windows Phone (7.1/8) platform and am still not really familiar with it.
My plan is an internet radio app which streams the audio file from a server. I used MediaElement to set the source property to the streaming URL.
It works and the app starts playing the music but I can't read any metadata about the song which is coming from the server such as artist name/title or any string which I can use to know about the song itself.
I've been searching around and tried the MediaReached event as well, but it never gets fired as well?
So any idea what should I do?
and My Code Behind Sample:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
MyMedia.Source = new Uri("MyURL");
}
I hate to tell you this but it is because the MediaElement.Attributes are not supported for Windows Phone 7 - all the limitations can be found here: http://msdn.microsoft.com/en-us/library/ff426928(VS.95).aspx

Play multiple audio streams in WP7 PhoneGap

I new to wp7 phonegap environment and I am having issues playing audio files. I am able to play one audio file as many times possible but cant play another audio of different instance, which is a requirement for my on-going project.
Any help?
you can use a phonegap native sound system
the javascript code for it is
src1="sounds/cartoon001.mp3"
src2="sounds/cartoon002.mp3"
var soundObj1 = new Media(src1,onSuccess,onError);
var soundObj2 = new Media(src2,onSuccess,onError);
soundObj1.play();
soundObj2.play();
also kindly check that mp3 files are supported in mobile.
you have to write a overriding functions for onSuccess and onnError.
javascript function to play:
playAudioFile("spellsound");
function playAudioFile(id){
var s=document.getElementById(id);
s.play();
}
html page<audio id='m' src='audio/baby/M.mp3'></audio>
or u can load src to audio tag by id in DOM

Resources