Unable to reference microsoft.xna.framework.media.phoneextensions.dll

心不动则不痛 提交于 2020-01-02 10:17:49

问题


I am trying to follow this answer to add some audio files to the windows phone emulator's media library. But I get the error

The type or namespace name 'PhoneExtensions' does not exist in the namespace 'Microsoft.Xna.Framework.Media' (are you missing an assembly reference?)`

I am unable to reference microsoft.xna.framework.media.phoneextensions.dll as it is not present at the location

C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71

I installed Microsoft XNA Game Studio 4.0 but still could not find the dll in the system folders.
I tried but couldn't get the dll anywhere on internet.
Here's my code (if it matters)

Uri file = new Uri("files/a_wink.mp3", UriKind.Relative);
var myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
var fileStream = myIsolatedStorage.CreateFile("a_wink.mp3");
var resource = Application.GetResourceStream(file);
int chunkSize = 2000000;
byte[] bytes = new byte[chunkSize];
int byteCount;
while ((byteCount = resource.Stream.Read(bytes, 0, chunkSize)) > 0)
    fileStream.Write(bytes, 0, byteCount);
fileStream.Close();
Microsoft.Xna.Framework.Media.PhoneExtensions.SongMetadata metaData =
    new Microsoft.Xna.Framework.Media.PhoneExtensions.SongMetadata();
metaData.AlbumName = "Some Album name";
metaData.ArtistName = "Some Artist Name";
metaData.GenreName = "test";
metaData.Name = "someSongName";

var ml = new MediaLibrary();
Uri songUri = new Uri("someSong.mp3", UriKind.RelativeOrAbsolute);
var song =
    Microsoft.Xna.Framework.Media.PhoneExtensions.MediaLibraryExtensions.SaveSong(
        ml, songUri, metaData,
        Microsoft.Xna.Framework.Media.PhoneExtensions.SaveSongOperation.CopyToLibrary
    );

Edit: I am using Windows Phone SDK 7.1 on Vista Home Basic.


回答1:


You can find the library here once you have installed WP8 SDK

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\Microsoft.Xna.Framework.MediaLibraryExtensions.dll

If you can't install WP8 SDK's You can find the XNA Framework dlls here:

  • Microsoft.Xna.Framework.dll
  • Microsoft.Xna.Framework.GamerServices.dll
  • Microsoft.Xna.Framework.GamerServicesExtensions.dll
  • Microsoft.Xna.Framework.Input.Touch.dll
  • Microsoft.Xna.Framework.MediaLibraryExtensions.dll


来源:https://stackoverflow.com/questions/24848978/unable-to-reference-microsoft-xna-framework-media-phoneextensions-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!