Im trying to play a video clip in my Silverlight Application.
var video_path = "http://mydomain.com/path-to-media/file.wmv";
mediaPlayer.AutoPlay = true;
mediaPlayer.Source = new Uri(video_path);
mediaPlayer.Play();
MessageBox.Show(mediaPlayer.Source.ToString()); //test the source string
But the video does not start or even display.
Is there a step I have forgotten ?
mediaPlayer is a simple Silverlight MediaElement
Update
When I attach a media Failed event and display the error exception i get
4001 AG_E_NETWORK_ERROR
It's because your silverlight application has a different URL scheme, and cross-scheme access is not allowed for media.
If the video URL starts from http://, your application URL should start from http:// too.
I think your application URL looks something like file:///C:/project/page.html. If so, you should add a ASP.Net website to your solution and host your Silverlight application there so that your URL looks like http://localhost:25252/page.html.
Related
I would like to do video call from UWP PeerCC app to Browser or from HoloLens (HL) peerCC (unity) to browser.
With PeerCC-browser example I am able to call successfully from web-browser to web-browser but when I try to call from UWP peerCC sample (windows app), I am not able to see the remote stream at browser.
browser --> browser : works fine
browser --> uwp peerCC : at peercc i can see local and remote video but on browser side it just show local video.
HL --> browser same result.
It also did not show any error.
I am using this https://github.com/OpticalTone/PeerCC-Browser code sample for browser side.
I have tried to debug it with some log messages, I noticed that the
ontrack()
function {the code is below} called but the stream object has zero length.
//display remote track in the video element
pc.ontrack = function(event) {
videoRenderer = document.getElementById("rtcRenderer");
videoRenderer.srcObject = event.streams[0];
console.log("Remote track resceved");
document.body.style.cursor = "default";
};
updateServerStatus();
}
any idea what could be the potential problem will be highly appreciated.
Thanks
I am trying to play an audio stream from stream server in my windows phone app. I read on Microsoft Documentation that I have to reference an Audio Stream Agent.
I have these projects in my solution :
I've tried to reference a new project as Audio Streaming Agent in my Windows Phone 8.1 application
but I keeping receiving the error :
I read that I have to change the target framework, but there is no option for target framework in the AudioStreamAgent1 properties.
Also, Can I do this using an application that is not the Silverlight kind? Is there a way to do without using the Silverlight one?
The problem is that the AudioSteamAgent is targeted at WP Silverlight, and your actual app is WP8.1 (WinRT).
To create background audio in WP8.1, you will want to use the Background Media Player.
You can find a great guide for how to get started here.
But basically (without all the boilerplate code to wire everything up), it comes down to telling the BMP what to play (code is from the link above):
BackgroundMediaPlayer.Current.SetUriSource(new Uri("ms-appx:///Assets/Media/Ring02.wma"));
BackgroundMediaPlayer.Current.Play();
And telling the OS player controls what to show, and what to do when the user interacts with them:
systemmediatransportcontrol = SystemMediaTransportControls.GetForCurrentView();
systemmediatransportcontrol.ButtonPressed += systemmediatransportcontrol_ButtonPressed;
systemmediatransportcontrol.PropertyChanged += systemmediatransportcontrol_PropertyChanged;
systemmediatransportcontrol.IsEnabled = true;
systemmediatransportcontrol.IsPauseEnabled = true;
systemmediatransportcontrol.IsPlayEnabled = true;
systemmediatransportcontrol.IsNextEnabled = true;
systemmediatransportcontrol.IsPreviousEnabled = true;
This is all assuming that you want the user to be able to leave the app and have media continue to play. If you just want to stream audio/video while the user is in the app you can use the MediaElement control.
I Develop windows phone application and i want to stream audio from sound cloud without using sound cloud API ( i write this Code
"webBrowser1.NavigateToString("<!doctype html>" + "<html><head><title></title></head><body>" + "<iframe height=\"1000\" src=\"https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/125791854\" width=\"1200\"></iframe>" + "</body></html>");"
and C# and using web Browser Control In Xaml Page in but when i Run it it load sound cloud site but the audio didn't run.
Try Background Audio Player, here is a sample , basically what you will end up doing is
new AudioTrack(new Uri("[your soundcloud uri]", UriKind.Absolute), "[Track Name]", "[Artist]", "[Album]", null)
Things to note :
Url should be something like : http://api.soundcloud.com/tracks/[trackNo]/stream?client_id=[id]
You need to wait for the PlayerState to change to track ready and then call .Play(), This is due to the asynchronous nature of the background audio player. It actually resides in a different process than the rest of the code.
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 have been trying to play some sound(.wav) from a website link on windows phone 7 using the media element.
MediaElement mediaElement = new MediaElement();
mediaElement.source = new uri("http://api.microsofttranslator.com%2fwav");
mediaElement.play();
doesnt do anything.
i tried implementing handlers or even try to use the Webclient class to download the stream and play it but it has the same problem i dont hear anything.
and also i copied the uri to the browser and it played the wave i needed.
If you want to use Microsoft Translator, you can add a Service Reference to the API SOAP service. The Service Client exposes the SpeakAsync method which will return the URL of the WAV file. You can then use your WebClient or HttpWebRequest to download the stream and play it. There's example code in this blog post.