Viewers: in countries Watching now:
Discover how to build professional apps that encompass the 17 major feature areas of Windows Phone, from XAML to multimedia to network access. In this course, author Michael Lehman details the standard hardware device configuration, teaches how to navigate the development environment, and explores the Windows Phone APIs. The course shows how to build sample applications while learning Windows Phone concepts and frameworks, including the Metro design language.
Let's take a look at how to save that stream of data that we had in a MemoryStream into isolated storage so that we can play it back later. We haven't added any new additional images or user experience with this, just some underlying code. So now we've added a using for System.IO.IsolatedStorage, and we have added a variable here to keep track of the lastRecordedFileName and the reason for that is we have also changed the playback to play back from the file rather than playing back from the MemoryStream. So everything else we've done so far all looks exactly the same.
We haven't changed anything for the recording or the basic playback, except that in recording we now make a call to this SaveRecording method where we have the logic that actually writes to IsolatedStorage. Play logic is still the same until we get to the place where we're we actually going to play it, and we'll come back to here in just a second. Let's look at the method where we actually save the recording. So just like we did before, we use GetUserStoreForApplication to get access to the IsolatedStorage manager.
Now, here we have to decide what we're going to call our file. So we do this based on the time and date in the phone, and then we just convert that time into Ticks and use that long number that we get from that with the extension dat on the end of it to create the file name. And then we go and create the file, get the buffer from the stream and write it out to the IsolatedStorageFile, flush it and close it and set the stream to null. And then we also write an info file using the same name, but a different extension, in this case .info.
The reason we do this is it's not possible with the IsolatedStorage manager to find out the date and time of a file that's stored in IsolatedStorage. That particular functionality is just not there. So in order to be able to keep track of multiple files and have the ability, for example, to sort them by date, we actually have to have a separate file that has the metadata in there, in our case, the name of the dat file and the time. And in the next movie we'll actually see how we use this data to create a view model full of data to be able to populate a list box.
And last but not least, let's look at our updated play logic because the updated play logic no longer displays from the in memory stream. We actually go and load the data from the IsolatedStorage. Once again we get the IsolatedStorage manager, go and open up the stream containing our data, read it into a new MemoryStream because we need to have that in order to be able to create a SoundEffect instance, so we need to use stream.ToArray here. So we load the entire sound into memory, create a sound, and play it just as we did before, and that's it for persisting the recording as an individual file in IsolatedStorage, which once again is great if you only have one file, but the app becomes a great deal more useful if we can record multiple files and choose which one we want to play back.
So let's do that.
Find answers to the most frequently asked questions about Windows Phone SDK Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.