WP7 playready customdata - windows-phone-7

I have a wp7 app that will play Playready protected live smooth stream.
Before hitting the protected URL, the customData field needs to be set.
I could not find, where to set the customdata in Wp7, whereas in Silverlight app it can be done using below code...
LicenseAcquirer la = new LicenseAcquirer();
la.ChallengeCustomData = "MY_CUSTOMDATA_HERE";
PlaylistItem playlistItem = new PlaylistItem();
playlistItem.LicenseAcquirer = la;
But LicenseAcquirer class does not have ChallengeCustomData field in WP7.
How can then the custom data be set?

Windows Phone 7 is based on a very old version of Silverlight (v3). This version did not have support for sending the PlayReady CustomData element in license requests. I believe what you are trying to accomplish is not possible.

Related

How to access mobile data usage from settings in android mobile using xamarin forms

In my application i want to access contact names and mobile data usage from Android mobile. I get the contacts list from the mobile by using the below code. But I have no idea how to access mobile data usage from the settings in android mobile. I have referred many sites but none of them could give me a clear answer. How do I access the mobile data usage when mobile data is turned ON?
var context = MainActivity.GetAppContext();
var uri = ContactsContract.Contacts.ContentUri;
string[] projection = { ContactsContract.Contacts.InterfaceConsts.Id,
ContactsContract.Contacts.InterfaceConsts.DisplayName,
ContactsContract.Contacts.InterfaceConsts.HasPhoneNumber
};
var cursor = context.ContentResolver.Query(uri, projection, null, null, null);
ObservableCollection<UserContact> UserContactList = new
ObservableCollection<UserContact>();
cursor.MoveToFirst();
You can query only basic info using the Android.Net.TrafficStats class:
var receivedTotal = Android.Net.TrafficStats.MobileRxBytes;
var transmittedTotal = Android.Net.TrafficStats.MobileTxBytes;
//app-specific
var uid = Android.OS.Process.MyUid();
var receivedByApp = Android.Net.TrafficStats.GetUidRxBytes(uid);
var transmittedByApp = Android.Net.TrafficStats.GetUidTxBytes(uid);
Please note that the app-specific methods return overall number of bytes since the network interface or app started and may be zeroed-out when connection drops or app closes. Also they count not only mobile data, but include wi-fi connection as well.
There is no built-in API to query mobile data usage of other apps in the default API. Some manufacturers might offer their own implementations for this, but it is not available in the "clean Android OS".

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

Accessing phone gallery and camera

How to access Phone gallery and camera in windows phone7 through code
there are Launchers and Choosers which allow you to call these options and they also allow you to call other things such as map,sms compose,search etc.
here is an example of one (camera)
Creating Object
CameraCaptureTask cvt = new CameraCaptureTask();
Registering event
cvt.Completed += new EventHandler<PhotoResult>(cv_Completed);
cvt.Show();
Creating callback method
private void cv_Completed(object sender, PhotoResult r)
{//Your Code Here
}
also read here - MSDN- Launchers and Choosers
You want to see many good samples in the good Nokia Developer Windows Phone Website. They're good tutoriel with many samples.

facebook c# sdk how to post to user's wall as application from wp7

I'd like to know, how can I use facebook c# sdk to post to user's wall from my wp7 app as application.
So I want to display message from FB application on users wall.
I have so far:
var app = new FacebookApp();
var parameters = new Dictionary<string, object>
{
{"access_token", accessToken},
{"appId", appId,
{"message", "TEST"}
};
var fbCB = new FacebookAsyncCallback(postResult);
app.PostAsync("me/feed", parameters, fbCB);
But this displays text on my wall as I wrote it, not like the application specified by appId.
app.PostAsync("friendId/feed", parameters, fbCB);
I would also suggest you to use the latest facebook c# sdk.

Resources