I want to play a song which is stored in Music+video Hub in AudioPlaybackAgent.
I can get songs by this way:
MediaLibrary mediaLibrary = new MediaLibrary();
var songs = mediaLibrary.Songs;
but this songs are of type Song and BackgroundAudioPlayer accepts sounds of type AudioTrack:
BackgroundAudioPlayer.Instance.Track = ..
Question: how can I play a song from music hub in AudioPlaybackAgent?
From here: Windows phone 8 on emulator - why can't I play audio files? see the answer number 3 (Author:Frederik Winstrup Johansen). He also added a good sample about playing AudioTracks
The BackgroundAudioPlayer can play files only from isolated storage or
from a remote URI, that is why you can here anything!
If you have your file as resources in your app, you must first copy
them to the isolated store, and then make a reference to the file in
the isolated store to your BackgroundAudioPlayer.
Related
I was publishing my first C# Windows Form Application with a built-in audio player (I used System.Media), but when I tried to run the program on another PC of mine, it returned an exception and then crashed every time I click on the button to play audio so I was wondering if there was a way to play the audio on another PC without crashing.
Here's the code part I used to play the sound:
System.Media.SoundPlayer player = new System.Media.SoundPlayer("mouse_click.wav");
player.Play();
Then the PC I used to run the program returned this error: verify that the audio file path is correct.
Thank you everyone for the help!
If you want to add a Wav file to Windows Form Application, you can refer to the following steps:
First, add the Wav file in the Resources File (Project>Properties>Resources):
Second, refer to the following code to play the Wav file in VS:
System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources._15035);//Use your own filename in place of _15035
player.Play();
I'm getting id each items of track but I don't play it as next,back, play, pause...
E.g:
I have items name is "Blank Space" song and is "015668". Now. How to play Blank Space song with id 015668.
I dont see tutorial about that and Have other media player API support wpf,universal app for mp3 and video stream youtube
The MixRadio API supports playback of 30 second clips within your application - in C#, you would use this method to get the URI and then play how the platform you're on supports it.
i m making a Windows Application which work over ITunes. Currently i m able to find the location of a song (which is on local machine ) and URL ( which is running from stream like radio, podcast at the time of buffering)
Is it easy to play a song which is on local Machine..
obj = new iTunesAppClass();
obj.PlayFile(#"d:/4.mp3")
but when i tries the url inside playfile() method it doesn't work is there another way to play
online songs/radio ?
We can see play method here
if you want to open an Url you should use the OpenUrl() Method.
obj.OpenURL("http://108.166.161.205:8795");
I need to access videos on camera roll and also on Music+Video. but it seems there is no way at all.
Here in the documentation says we can use:
MediaLibrary library = new MediaLibrary();
But it only can access musics.
Can we say I should forget this thing for ever in WP8?
Unfortunately, there is no way to access videos in Media Library.
You have read-write access only to audio and photos.
See this answer: https://stackoverflow.com/a/13473349/1029518
There are a couple answers in the following thread which points out it is now feasible to read the video files via KnownFolders if you upgrade to Windows Phone 8.1: Windows Phone 8: Media file access
Here is an alternative option for accessing the videos (also in Windows Phone 8.1):
FileOpenPicker picker = new FileOpenPicker();
picker.ViewMode = PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
picker.FileTypeFilter.Add(".mp4");
picker.PickSingleFileAndContinue();
Once you have the file you should be able to play it back.
When I try to play a sound with a media element on my local machine I can't hear any sound. But I can hear sound in the simulator(same thing almost right?) and on my surface when I test it on there. It Doesn't work on all my pages too not just one on the local machine only too.
load event goes off in simulator but not in local machine. Also stream isn't null.
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Sound/" +selectedCharacterSets[currentCharacterSet].character[currentCharacter].romaji + ".mp3", UriKind.Absolute));
var stream = await file.OpenAsync(FileAccessMode.Read);
mdeSound.SetSource(stream, file.ContentType);
Media failed event going off. Error: MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED : HRESULT 0x8000FFFF. Does anyone know how to fix this and why its only on local machine?
EDIT: converted mp3 to wma... still doesn't load. converted it to wmv now it plays on local machine... why? I'm still confused. Opening the mp3 in the music app throws an error too, windows media player plays it fine.
There is an issue with the file you are trying to play. This could be because of DRM or because of bitrates being too high, etc. Windows 8 Pro can play more codecs than Windows 8 RT, but you said it worked on your Surface which is interesting. Try using Audacity or another program to save it as a lower bitrate MP3 or even a basic .WAV file.
It's also interesting that you couldn't play it as WMA but you could as WMV. WMV is video while WMA is audio. You may have a corrupt media stack on your machine.
P.S. The simulator essentially uses Remote Desktop, so there is a difference in how the audio gets played.