Windows Library to play a video file - c#

this.Background = new System.Windows.Media.ImageBrush(new System.Windows.Media.Imaging.BitmapImage(new Uri(label)));
The above code used the Media library to display an image from the Uri fed.(label contains the URL).
What library should I use to play a video file in the same manner.
(I need to play a video file instead of displaying and image)
Help ?

You can use the MediaElement for this.
It is located in System.Windows.Controls namespace and relies on the Windows Media Player. IF WMP is installed on your system MediaElement is an easy way to go.
The code to do this should look like this:
MediaElement me = new MediaElement();
// initialize and do other stuff to MediaElement
this.Background = new VisualBrush(me);

Related

How to display Camera Stream with Xamarin.Forms. Is it possible?

So I have created an interface and implemented this interface currently in my Windows Phone 8 application to start a camera stream. Like so:
public void StartCamera()
{
var cam = new Microsoft.Devices.PhotoCamera(Microsoft.Devices.CameraType.Primary);
System.Windows.Controls.Canvas canvas = new System.Windows.Controls.Canvas();
var videobrush = new System.Windows.Media.VideoBrush();
canvas.Background = videobrush;
videobrush.SetSource(cam);
}
so now the canvas object is holding a camera stream. But how Do I then pass this back to Xamarin forms and display it.
In Xamarin Forms I have:
IOperations camera = DependencyService.Get<IOperations>();
if (camera != null)
{
camera.StartCamera();
}
and this works apart from obviously I have no control to display the camera stream. How would I display this stream in Xamarin forms?
There is now a new Custom Renderer example project available here:
http://developer.xamarin.com/samples/xamarin-forms/CustomRenderers/ContentPage/
With a walkthrough of this sample available here:
https://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/contentpage/
I know this is a link only answer but due to the complexity of the question it would be too time consuming to repost the links contents
There is also now a control by the Xamarin Community toolkit called CameraView
Xamarin Community Toolkit Camera View

Setting AlbumArt of AudioTrack

I'm using Background Audio Player on Windows Phone 8 and I'm trying to set an album art for my audio track. As I've read here and at MSDN the image MUST be at shared/media/ - ok I've checked the image is there and I try to do:
AudioTrack myTrack = new AudioTrack(track.source, track.Title, track.Artist, track.Album, new Uri("shared/media/Episode29.jpg", UriKind.Relative));
The music starts, but there is no image. Am I doing something wrong?
I've also run Background Audio Player Sample mentioned here at MSDN and I also see no image.

how I put sound in a silverlight animation?

I'm trying to put a sound to play when the animation in my silverlight animation starts. I put the sound in the user control with blend, selected auto-play, and created a PlaySoundAction to play the sound on load. Nothing worked. Anyone knows what I could be missing?
Did you use Media Element? since you have not posted any code, here is a sample on how to include sound in silverlight
MediaElement media = new MediaElement();
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("YourNameSpace.Sound1.wav");
media.SetSource(stream);
media.AutoPlay = false;
media.Stop();
media.Play();

Display Current Video in Windows Phone 8 using AudioVideoCaptureDevice?

I've managed to setup code for a Windows Phone 8 Application that initializes and can start/stop recording video using an AudioVideoCaptureDevice. (saves it to an IRandomAccessStream)
//Initialize Camera Recording
Windows.Foundation.Size resolution = new Windows.Foundation.Size(640, 480);
captureDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, resolution);
captureDevice.VideoEncodingFormat = CameraCaptureVideoFormat.H264;
captureDevice.AudioEncodingFormat = CameraCaptureAudioFormat.Aac;
captureDevice.RecordingFailed += captureDevice_RecordingFailed;
However, I cannot figure out how to hook this recording up to a VideoBrush to display the recording to the user. I want the user to be able to see the video they are recording as it is happening...
I know there is a tutorial that shows how to do this using the old APIs for Windows Phone 7 (CaptureSource, VideoDevice, etc.) but I specifically need to use the AudioVideoCaptureDevice to record. Anyone know how to display this video on screen?
Well, I was able to solve my problem.
Apparently there is a library in Microsoft.Devices that contains extensions for the VideoBrush class.
Therefore, in order to set the videobrush source to an AudioVideoCaptureDevice, you must first have:
using Microsoft.Devices;
at the top of your class in which your using the videobrush.
Hope this is able to help someone else.
You should be able to simply use VideoBrush.SetSource(captureDevice).

WPF imagecontrol and media element

I wanna put a media element to inside a image control . For example like this ;
<Image>
<MediaElement
</Image>
And after do this I wanna save this image to my computer as a image . Is something this possible accorting to you?
What you trying to do is impossible on many levels.
First of all, Image control does not support direct content so you can`t put any other control inside it. And this control is used to display some image, it is not image itself.
Second, MediaElement is used to contain video or audio. How can you save audio or video as image (image that makes sense anyways)?
So the answer to your question is: no, it`s not possible.

Categories

Resources