I want to play few specific files in my app using MediaElement. The files are stored in the assets folder. So I dont want to use the FileOpenPicker. I just want that when a button is clicked a file from the assets folder must be played. How can I set the source of the MediaElement to the file.
Use a Uri as the source which points to the file. Like, "Assets/MyMovie.mp4". This feature is described in better detail in the MediaElement documentation.
Related
I need the user to be able to upload an image, and then have the image be able to be accessed later for drawing it. I only know how to show an image in the Android Resources/drawable folder. I don't think it is possible for a user to upload an image there, so is there another place they can upload it, and then have the image to be used? I don't know how to have the user to be able to upload it either.
I only know how to show an image with the xaml code <Image Source="image.png"/>, where image.png is in the Android Resources/drawable folder
Since Resources contained in out raw directory of our project will be packaged inside our APK and will not be writeable at runtime.
So I highly recommend that you use Internal or External Data Storage to store your images and text file.
For more details, you can check: https://learn.microsoft.com/en-us/xamarin/android/platform/files/
And at the bottom of this page:External storage, there is a example which function is to save text file in External storage, it should be helpful for you.
The sample link is here: https://github.com/xamarin/monodroid-samples/tree/master/LocalFiles
If you want to choose Photos and Video, you can use MediaPlugin of jamesmontemagno. Of course , you can achieve this function yourself.
I have a C# program that I need to embed an image into or perhaps better stated make the exe file portable such that the image will open on any computer and I need the image to open up in the default picture viewer (not a form PictureBox). I do have the image in the resource folder with 'Embed Resource'
System.Diagnostics.Process.Start = WindowsFormsApplication5.Properties.Resources.MyImage;
I realize the above code is invalid, but I am just a coding hobbyist, so I don't know everything. If I could get a little push in the right direction, I would appreciate it.
This might do the trick for you but If you want a Default Image Viewer to open a picture, you need to store that image to somewhere on your disk, thus the Image Viewer could find and open your picture.
var bitmap = new Bitmap(WindowsFormsApplication5.Properties.Resources.MyImage);
bitmap.Save("YourImageLocation");
Process.Start("YourIamgeLocation");
I require to play a short video in my WP8 application. Unfortunately, there is no API available for playback from MediaLibrary.
The only API I know of is as per this link:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394041(v=vs.105).aspx
The above method works only if the VideoFile is stored in Isolated Storage.
While I understand that I can upload files to Isolated Storage using some tools, I would rather prefer to package the Video file inside the xap, and then copy the file to Isolated Storage during run-time.
Can someone please guide me on copying a VideoFile included in Application project to Isolated Storage during run-time.
You can add a video as an app asset the same way as you add an image. Add video to your project and mark it as Content. The video will be packaged with the app in xap.
You accomplish this with the MediaElement control. Here is a great sample on how to use it. The basics is to add it to your xaml and set the source to a file that is has the build action set to content.
<MediaElement x:Name="VidoPlayer" Source="/Assests/MyVideo.wma" AutoPlay="True" Volume="1"/>
So as long as you have a file MyVideo.wma located in the Assests folder and the Build Action is set to Content, you're golden!
i have the MediaElement and i want to play a video,
as i know the only way of doing so is to set this item Source
mediaElement1.Source = new Uri(fileName);
but now i have the resources file which i wanna play but i cant do so because it doesnt have a path.
so to make a long story short, i'm looking for a way to play video in the madiaElement from the resources file(without writing its byte first).
From first line in the "Remarks" section of the MediaElement docs: "When distributing media with your application, you cannot use a media file as a project resource. In your project file, you must instead set the media type to Content and set CopyToOutputDirectory to PreserveNewest or Always."
So you can't play video from a resource. You can play a file attached to a project as content.
Some alternate ways described here..
media-element-wont-play-a-video
Accessing the resources in the published application
Play embedded video resource as stream
How to play a video from WinForms resources in a axWindowsMediaPlayer?
Can you suggest something for changing the files icons in C#? What I means here is that does C# has any class that we can use to change the icons of files. For example, can I replace notepad file icon with doc file icon in c#?
I know we can extract the icon of a file, but I am looking for applying new icon to a file.
let me try to explain it in details. I am working on a windows app that process files. This app creates a special folder and user can create files and folders into this folders. Now when user creates a files, i want to apply custom icon which shows it as under processing. When processing is done, the file icon will be changed to processing complete. I hope this makes sense now.
Thanks
You will have to write custom shell extension for this. Which are known as "Icon Overlay Handlers". This is the same way by which applications like TortoiseSVN add icons in explorer.
See this MSDN article and this code example