Its possible to play video in xamarin forms?. (Not in separate native code)
I want to play video using portable project.. Its possible in official code or any other 3rd parties available?
Any one suggest me..
Its possible to play video in xamarin forms?. (Not in separate native code)
I want to play video using portable project.. Its possible in official code or any other 3rd parties available?
Any one suggest me..
Dears,
I have a Label inside listview-viewcell, to show time in UI. The date is received as a number like 1510822596449 (Java timestamp). I want to show the date in strings like "n days ago". How can I achieve this?
<StackLayout>
<ListView>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding createdTime}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
I try IValueConverter in the following link, but it is not working.
https://stackoverflow.com/questions/32814176/how-to-format-date-and-time-in-xaml-in-xamarin-application
Anybody, please suggest a solution with working code. Thanks in advance.
I am trying to get a video player working in my Xamarin.Forms app on Android. I have implemented the iOS version using a ScrollViewRenderer where I add the MPMoviePlayerController (code at bottom, file attach not working). For Android, I consulted the library for playing a video in straight Android (http://developer.xamarin.com/recipes/android/media/video/play_video/), and attempted two different tacks:
- create the VideoView and add it using AddView on the renderer itself, or the inside horizontal scrollview
- use the PageRenderer, create the XAML from the video recipe, use this.Context as Activity, and SetContentView to the XAML.
Needless to say, both versions failed, leaving just a blank screen.
Does anyone have a sample that is working in .Forms, or ideas for other approaches I might attempt? Nearing the end of my rope here.
Thanks...
public class VideoScrollViewRenderer : ScrollViewRenderer
{
protected override void OnElementChanged (VisualElementChangedEventArgs e)
{
base.OnElementChanged (e);
if (e.OldElement == null)
{
VideoScrollView thisView = (VideoScrollView)Element;
RectangleF dispRect = new RectangleF (0, 0, (float)thisView.ParentView.Width,(float)thisView.ParentView.Height);
var view = GetView (dispRect);
ShowMovie (thisView.videoName, view);
}
}
UIView GetView (RectangleF dispRect)
{
var view = NativeView;
view.Bounds = dispRect;
return view;
}
static void ShowMovie (string videoName, UIView view)
{
string fileDir = string.Format ("video/{0}", videoName);
string localDocUrl = Path.Combine (NSBundle.MainBundle.BundlePath, fileDir);
var moviePlayer = new MPMoviePlayerController (new NSUrl (localDocUrl, false));
moviePlayer.View.Frame = view.Bounds;
view.Add (moviePlayer.View);
moviePlayer.Play ();
}
}
Hello,
I need to embed a YouTube video in my Xamarin.Forms app. I have tried various methods with the WebView control, including passing the embed URL and trying to port this code https://gist.github.com/rais38/4683817 etc. However, the WebView doesn't show the webpage. Is there a good way to get a YouTube video in a Xamarin.Forms app?
EDIT: Just to clarify the situation a little bit further. I am trying to add a WebView to a StackLayout under existing content. I have also tried just using <h1>Test</h1>
, and this still doesn't show the content, so it might be that I am using the WebView incorrectly.
Here is my code:
public class XamarinVideoElementViewGenerator : IPageElementViewGenerator
{
public global::Xamarin.Forms.View GenerateElementView(PageElement pageElement)
{
// Check if the page element is null.
if (pageElement == null)
{
return new Label();
}
// Create the video via the page element details.
var element = (VideoPageElement) pageElement;
if (!string.IsNullOrEmpty(element.VideoSource))
{
WebView webView = new WebView();
HtmlWebViewSource htmlWebViewSource = new HtmlWebViewSource();
htmlWebViewSource.Html = BuildFinalHtml("<h1>Hello</h1>");
webView.Source = htmlWebViewSource;
return webView;
}
// If all fails, return a blank label.
return new Label();
}
private string BuildEmbedUrl(string videoSource)
{
var iframeURL = string.Format("<iframe width=\"320\" height=\"600\" src=\"{0}\" frameborder=\"0\" allowfullscreen></iframe>", videoSource);
return iframeURL;
}
private string BuildFinalHtml(string embedUrl)
{
string finalUrl = string.Format("<html><body>{0}</body></html>", embedUrl);
return finalUrl;
}
}
Note: I am writing a library that generates Xamarin pages dynamically from either JSON or HTML page sources (for an educational app that requires easy updates of content/page layout).
Thanks,
Richard Bosworth
Not sure what the cause is but I get a message saying "If playback doesn't being shortly, try restarting your device." It shows the image of the youtube video but when you click play it just stays black and doesn't play...
Here is a sample of what I'm doing:
var videoHTML = "<body style="background-color:black;"><center><iframe width="270" height="205" src="https://www.youtube.com/embed/VRnNc4a0XJE?showinfo=0" frameborder="0" allowfullscreen></iframe><br><div style="padding:15px;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;font-size: 10px;color:white"><b>CELEB P.O.V. - Guys Choice Awards with Mackenzie Stith</b></font></div><br>";
var youtubeSource = new HtmlWebViewSource();
youtubeSource.Html = videoHTML;
Webview.Source = youtubeSource;
This works perfectly on iOS and Windows Phone...
I even tried making a custom renderer for the webview and setting is a ChromeClient and still doesn't play. I have tried the emulator and a phone with different Android versions and still no go.
i want to stream video in xamarin.forms how can i implement that can u give me the working demo?
We use Xamarin.Forms web view to show videos in our app. Our app user captured video(using xLab.MediaPicker) using their phone camera and that one is uploaded to azure blob storage. We used HTML5 Video tag to render video inside the web view. Video is playing fine on iOS but it does not play in Android.
I have an app where i want to play a video file when a user navigates to a form. What is the best way to incorporate playing a media file on xamarin forms? Is there a control for this purposes? (i.e. i want to autostart when the user navigates to a form and also let the user stop/start/restart the video/media).
thx-dave
We are trying to obtain the IP address of a WiFi device that is broadcasting it's IP address to 255.255.255.255 to port 15000.
In UWP, the following code works
Task<UdpReceiveResult> task = udpClient.ReceiveAsync();
task.Wait();
UdpReceiveResult result = task.Result;
However, on iOS, the exact same code hangs and never returns a result.
In both cases, the WiFi device is connected to a hotspot (on the UWP & iOS devices).
I've also tried using this plugin, with the same outcome.
Although, when I did get it working on UWP, I was unable to also tie a TcpClient in with the GUI for the same reason. Seems to be something strange going on with threads, but am not entirely sure what or why. I can only get both (udp & tcp) to work reliably on UWP when called from the App() constructor in the PCL project.
We really only need to get this working on iOS.
Can anybody shed some light on the situation?
Much appreciated...cheers
Hello,
After much googling, I remained stumped on how to change the default text size of a toast. I found the following code:
ViewGroup group = (ViewGroup) toast.getView(); TextView messageTextView = (TextView) group.getChildAt(0); messageTextView.setTextSize(25);
Apparently this is all I need to do. However, in Xamarin when I type this code, I immediately get an error that says "the name 'toast' does not exist in the current context".
I imagine what I am trying to do is relatively simple, but I am (pathetically) quite stuck!
Any help would be greatly appreciated!
Dustin
I want to set a button with an underscore;I have created a button inheritance and ButtonRenderer on the iOS and Android projects, but I can't set the underscore. Can anyone tell me how to do this?Thank you very much!
I connected asmx web service to my project.
I want to get json data from the web service.
How can do that?
Have you used the JobScheduler
API yet?
If you haven't, read our blog for a quick primer on JobScheduler
and let us know what you think!
Feel free to discuss this post below.
I want to send SMS of length of 500 characters, some one help me in doing sooo
I am using Windows 10 Professional with visual studio community edition 2017 ,Microsoft sql server 2014 to access database using Web API(web services) using xamarin cross plateform app. I using tutorials of Houssem Dellai on topic "Login to asp.net identity on xamarin forms". My application projects build successfully but when I am inserting data for registration and try insert it into database table I cought System.Net.HttpExecption . Application break and no comapitble code issue.
Hi,
I have some html pages that is working fine in WebView Xamarin forms (iOS/Android).
I have one c# method that i need call from Html page javascript function.
please give me any example or any solution code.
Thanks
Hello,
in my App I added the Permissions
READ_EXTERNAL_STORAGE"
WRITE_EXTERNAL_STORAGE"
On the internal Storage I can make my Folders and write my Data (/Storage/emulated/0/TestDir).
Now I want to write the Backup of the Data on the external Storage (/mnt/media_rw/sdcard1/BackupTest).
When I try to Create the Folder or write Data on the external Storage I get the Error:
System.UnauthorizedAccessException: Access to the path "/mnt/media_rw/sdcard1/BackupTest" is denied.
How do I get writing permissions on the external SDCard.
Android 4.4.4
Hi, i have implemented Local Notifications in Xamarin.Forms using Xam.Plugins.Notifier. I have added the Nuget Package in PCL, iOS and Android.
below code is displaying the notification. i wrote the below chunk of code in my PCL
CrossLocalNotifications.Current.Show("test" + " " + " New test", "Some Notification", 5,DateTime.Now.AddSeconds(8));
I have added the below code in AppDelegate.CS
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// iOS 10.0+
UNUserNotificationCenter.Current.RequestAuthorization(
UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
(approved, error) => { });
UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
}
I am able to get the notification in iOS but am not getting the notification in Android. Do i need add any code in MainActivity.cs
can someone help me to fix this?
We have now opened GitHub Issues and ask that any new proposals and discussions be opened there.
Existing conversations may remain here, though you are free to migrate them as you see fit to GitHub.
We are building app in which we need to have feature like virtual room planner, in which we can show the camera and add an object view to it we can move the object by gestures . attached the images
How we add that feature in xamarin from app ? Is ARKit will help ?