Why is MediaPlayerElement not playing video when hosted in a ContentView? - xamarin

I have a working example of my issue here. Basically: when I place the LibVLCSharp MediaPlayerElement into MainPage.xaml directly, I'm able to get playback. When I try to create a reusable control by hosting the MediaPlayerElement in a ContentView that I can use in several parts of my application, all I get is a black screen. The only difference appears to be hosting it inside a ContentView.
Ultimately, my goal is to create a single, reusable class that I can use in several parts of my Xamarin application to render video without copying and pasting code. I've found that it's most stable to set the properties I want to set (clearing the Play/Stop, etc. controls) in XAML. So I've gravitated to implementing my reusable component as a ContentView and just referencing it in multiple places.
Does anyone have any idea on why I get a black screen in this example?

See this line: https://github.com/kwende/LibVLCSharpContentView/blob/65fd9c2bf1afc97374a9052c86b9c066934f7b7d/LibVLCSharpContentView/LibVLCSharpContentView/VideoPlayer.xaml.cs#L28
Your MediaPlayer is not a Bindable property/does not raise PropertyChanged, so the VideoView is initialized with a null media player when it loads, and the never changed, even after the start.

Related

What AppKit controls / components were used to create the iMovie/FCP timeline scrubber?

I am interested in creating a video editor similar to iMovie on macOS. The scrubber is an interesting component, and I am wondering if anyone knows what control is used to create it.
My personal guess is that it is NSCollectionView.
It is a custom view. It is a subclass of TLKTimelineView called CETimelineView that is embedded in a custom scroll view called LKScrollView.
This makes sense as the video has to be in sync with the timeline, audio and video. Would require a highly optimized control. You can debug the view in xCode.

layer control in iWatch using Xamarin

Is there any way to layer a control on top of another. I wanted to put one label on top of another to build out a word. I am using Xamarin Studio and programming for the iWatch, watchOS2.
Unlike UIKit, there is no z-index, or hierarchy, in WatchKit for views. As far as I know, the closest you can get to this is to use a WKInterfaceGroup with a custom background. The hard way, which may get you the result you are looking for, is to render an image and display it.

Xamarin - how to center a launch screen image (iOS)?

I'm using Xamarin for Visual Studio, and am getting frustrated trying to do what I would think should be a very simple thing: creating a launch (splash) screen for iOS, that has a single image that is centered on the screen (vertically and horizontally centered).
I'm creating it the recommended way, using a storyboard (other methods, like using an assets catalog, are considered deprecated as of iOS 9). In the storyboard, I have a View Controller, which contains a View, which contains an Image View. In the Properties pane, I've tried messing with the Mode (in Widget tab), and I've tried playing around with contstraints - which I think might be the key, but it is difficult to understand how it all works together.
You need to add the Splash screen in the applications properties (Launch Images). You need to create the image and upload it via that section. I couldn't find anything saying that the use of Asset catalogues are depreciated.

Xamarin.Forms custom loading gif as activity indicator

I would just like to know of something is possible as I am very new to Xamarin and I am on a time limit for an assignment. I don't mind some trial and error, but don't want to waste the time if it isn't possible
I want to have an animated gif as an activity indicator (it is a logo).
I have it working in a WebView - is it possible, in Xamarin,Forms to have this appear as an overlay while waiting on long running methods?
For example. if user clicks on a button, the app gets some info from a webservice then displays in a page. While waiting I would like to show the webview (or any other way to show an animagted gif).
So I am not asking for the code, but just if it is posible.
Thanks in advance
I was able to work this out
With the animated(loading) gif running in the WebView page I called a couple of async methods using following
await Task.WhenAll(method1(), method2());
await Navigate.PushAsync(new NextPage(var1, var2));
The laoding gif (which is an animated logo) runs until the tasks are complete then navigates to the next page
Using an ImageView apparently this doesn't look like its possible to playback animated Gif's as can be seen here http://forums.xamarin.com/discussion/17448/animated-gif-in-image-view.
So i very much doubt the ActivityIndicator would, if it could. In the ActivityIndicator I can't see any functionality to change the content of the what is shown when it is busy.
You could always create your own animated image view by creating a custom renderer instead however. It isn't particularly hard to cycle images at pre-determined gaps if you have a list of the images split up.
GIF images can be used in Xamarin forms to show custom activity indicator, since in Xamarin forms it is not possible to show GIF images directly web-view must be used. For android image must be placed inside assets folder and Build Action must be set to AndroidAsset. For iOS image must be placed inside resources and Build Action must be set to BundleResource. AbsoluteLayout can used for placing the image to center, IsBusy property of mvvm helpers nuget can used for controlling the visibility of the activity indicator. Dependency service must used for getting the image path. You can check this https://github.com/LeslieCorrea/Xamarin-Forms-Custom-Activity-Indicator for example.
Xamarin.Forms now supports .GIF, from version 4.4-pre3 and up on iOS, Android and UWP. Before using, first add the .GIF to the platforms projects, or as an embedded resource in the shared project and then use it like a regular image. The API on the Image control has been extended with the IsAnimationPlaying bindable property.
For e.g., loader.gif is added in all platform projects, then below code make it animating.
<Image Source="loader" IsAnimationPlaying="True" WidthRequest="36" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" />

How do I scroll my Palm webOS application?

This feels like a dumb newbie question. I'm attempting to follow the Palm's online tutorial for developing a webOS app. I ran palm-generate and tried updating the generated index.html file to have a body with a bunch of content (the word "HELLO" repeated 400 times).
When I attempt to load that document in the emulator, I find that I'm unable to scroll the screen to read the rest of the text. I drag the screen, but nothing happens. The page scrolls just fine in the Palm web browser.
Is there a setting to allow users to drag my app to scroll it? I see documentation for a Mojo.Widget.Scroller, but that seems like it shouldn't be necessary for a simple web page with a bunch of text on it.
Thanks to arthurthornton:
You can take anything that would normally be inside the tags and put that inside the scene HTML file.
OR you could just make a basic scene with a webview widget inside it that has your site as the source.
Unfortunately, the Scroller widget is needed for scrolling. The standard WebKit view that's shown in a card has no native scrolling ability, so the Mojo scroller widget implements the logic for displaying more content that can fit.
You can try this out by making a new project in the Ares IDE. Just add a Scroller and use the Maximize button to make it fill the scene. Then, add a HTML object to it, and add your HTML content to that object. You'll then have a nice scene which allows you to scroll through a lot of content.

Resources