How can I play a sound from the
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal
folder?
I have tried:
string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Sounds/Twing.mp3");
CCSimpleAudioEngine.SharedEngine.PlayEffect(path);
But it doesn't work
you get an exception ?
i assume that the specified sound is loaded via the content pipleline,
so you would need to add that to your content project.
So if you see ContentPipeline, ContentLoader or something in the stack trace, this may be the correct answer.
I dit not find a way to directly pass the audio.
With images that is possible.
Related
I'm making a application for steam games. Because shortcuts steal zone from desktop ,so i make this project for this. I want add a "drop file here to add list" when he put to shortcut on program i need get the app id, then it will automatically add to list.I added the drop file script!! But i dont know how to get URL title from assembly..There is a screenshot. I want get url from shortcut like this.
SCREENSHOT 1
SCREENSHOT 2
!! I made the drop file script.. I just have problems at get url script.
Opening steam applications is very simple, if you know the location of your steam.exe.
System.Diagnostics.Process.Start(#"C:\Program Files (x86)\Steam\steam.exe","steam://rungameid/730");
In my case (i think its default as well) you can start an application just by giving the path of the steam.exe and passing the content of the shortcut as argument.
Edit:
If you want to get the argument value you can just read the File using
File.ReadAllLines(path);
And get the argument from the string, which will then look like this:
string[] lines = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Golf With Your Friends.url");
string argument = lines.ToList().FirstOrDefault(item => { return item.Contains("steam://"); }).Replace("URL=", "");
System.Diagnostics.Process.Start(#"C:\Program Files (x86)\Steam\steam.exe", argument);
I create an application for android via Monogame (C#). In order to reduce my .apk size I decied to don't use Content Pipeline for audio. I found that I can use raw mp3 with Song.FromUri() method. Using next code
Song mySong;
//...
mySong = Song.FromUri("track01", new System.Uri("audio.mp3", System.UriKind.Relative));
//...
MediaPlayer.Play(mySong);
I got and exception "Unhandled Exception: Java.IO.FileNotFoundException: track01" on
MediaPlayer.Play(mySong);
, but I have file "audio.mp3" in main folder.
Solution Screenshot
Changing property "Build Action" to "None"/"Content"/"AndroidAsset" and "Copy to output directory" to "Copy always" didn't bring anything new.
I searched the solution, but it looks like nobody has the same problem or they solve it easily. The only similar problem I meet here, but their solution didn't help.
Do you have any ideas that can help me? Thanks.
I'm not sure about Song.FromUri Method, but this is how I'm using sound files.
var player = new MediaPlayer();
var fd = global::Android.App.Application.Context.Assets.OpenFd("sounds/Wrong.mp3");
player.Prepared += (s, e) =>
{
player.Start();
};
player.SetDataSource(fd.FileDescriptor, fd.StartOffset, fd.Length);
player.Prepare();
I have Kept my Wrong.mp3 in Assets/sounds Folder
Is it not a possibility to put the audio file into the resources?
If you open your project properties, there should be a resources tab. Within this tab, you should be able to add different values (strings, images, etc) including audio files. If you've added this here, it should be reachable through the resource manager.
Let me know if this works out!
I'm trying to use LiveConnectClient.BackgroundDownloadAsync to copy a file from Skydrive onto my computer. My code is below (this is a C# Metro app running on Win8).
var copy = connect.BackgroundDownloadAsync(f.id, dest);
LiveDownloadOperationResult result = await copy;
The result I get back contains no error, yet when I go have a look I see only the first 1K of my file. So my questions are:
Has someone used BackgroundDownloadAsync successfully?
Can someone suggest something I might have missed, that would match the symptoms?
Thanks!
The answer is to add "/content" to the ID of the file you want to download. Otherwise, you get the metadata.
I'm following one of the MSDN Introduction to Windows Phone Development labs, and have run into a problem with this lab (Introduction to Controls Available for Windows Phone Applications). The lab provides both the starting files, and the end files (i.e., what the program should look like upon completion of the lab).
The particular part of the lab that has me stumped is the point where I'm reading in a series of images from an Assets folder, then displaying them in a ListBox on screen. Whenever this code tries to run, it throws a Null Reference Exception:
public static BitmapImage GetImage(string filename)
{
string imgLocation = Application.Current.Resources["ImagesLocation"].ToString();
StreamResourceInfo imageResource = Application.GetResourceStream(new Uri(imgLocation + filename, UriKind.Relative));
BitmapImage image = new BitmapImage();
image.SetSource(imageResource.Stream);
return image;
}
I've dug into as much as I can, and imageResource always winds up Null somehow, and I can't for the life of me figure out where it's going wrong.
I've included a link to the two projects here (129 MB, sorry for that). Everything under the "Begin" folder is what I've done so far (and throws an Exception when I attempt to navigate to the Images page during runtime). Everything under the "End" folder is what it's supposed to end up looking like, and is functional.
I'm very new to C# and WP7 development, so any help would be greatly appreciated. Thank you!
Try to change the build for the .bmp to "Resource".
Here's a couple of links explaining it:
http://forums.silverlight.net/t/238891.aspx/1
Application.GetResourceStream called on a Content Resource still return null
The problem is that when you set your images directory in App.xaml file, there is a mistake in the tutorial. You should set the application resource, ImagesLocation like this:
<system:String x:Key="ImagesLocation">Begin;component/Assets/Images/</system:String>
Where Begin is your project name ;component/ is needed as separator, and finally the Assets/Images/ is the relative path to your images directory.
I have looked around, everything I find is talking about embedding it.
I do not want to embed it. I want to click a button and launch windows media player seperatly.
For example, I have a location saved in XML file. I have a right click to click Play. It pulls the location. like so.
int dd = dataGridView1.CurrentRow.Index;
string eLoc = dataGridView1.Rows[dd].Cells[4].Value.ToString();
if (eLoc == "")
{
MessageBox.Show("You have not saved a location for this movie","Movie Play",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show(eLoc);
ProcessStartInfo ps = new ProcessStartInfo("wmplayer.exe", eLoc.ToString());
Process.Start(ps);
}
As you can see, I have a pop up to view, what the string is.
It is this. I added %20 to replace spaces, thinking that was the problem but it isn't.
As you can see it pulls the full location. All I get back from windows media player is this.
Any ideas? To me it seems like this should be working..
I got it working now. It was the spaces causing the errors, I changed to this, and works perfect now.
ProcessStartInfo ps = new ProcessStartInfo("wmplayer.exe", "\""+eLoc+"\"");
It should be working, in fact on my computer and with a different path it does work, I suspect the file is damaged like jfs suggested.