incompatible hax module version 3 requires minimum version 4

안드로이드 에뮬을 실행하는데 위와 같은 에러가 발생될때

아래 링크로 들어가 haxm 을 최신버전으로 설치하면 된다.

https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm

haxm-windows_v7_2_0.zip

 

"java.exe"이(가) 종료되었습니다(코드:2)

위와 같은 에러가 발생되었다.

아래 처럼 프로젝트 속성의 Android 옵션 의  Multi-Dex 를 사용하도록 설정 을 체크해야한다.

Image 클릭시 이벤트 주는 방법은 아래와 같다

this.Image.GestureRecognizers.Add(new TapGestureRecognizer(메서드명));

this.ActionImage.GestureRecognizers.Add(new TapGestureRecognizer(OnTab));

private void OnTab(View sender, object e)
{
    ...
}

 

 

https://github.com/jsuarezruiz/xamarin-forms-customnavigationpage

 

깃헙을 최초에 만들때

username 을 잘못만들었다.;;

영어 순서가 뒤바뀌어 발음도 힘든 username 이 탄생되었다;;

방법은 깃헙에서 우측 상단의 내메뉴에서 Settings 로 진입한다.

여기에서 Account Change username 의 Change username 버튼을 클릭한다.

 

아래 처럼 경고 문장이 뜬다

이전에 사용했던 경로를 자동으로 연동해 주지 않고

연결되었던 프로젝트도 다시 연결을 해주어야한다.

바꿀 username 을 적는다.

혹 'Login is already taken' 이라는 메세지가 뜬다면 이미 사용중인 username 이므로 다른 username 으로 변경해야한다.

변경완료 까지는 조금 시간이 걸린다.

변경이 완료되었다.

 

심각도 코드 설명 프로젝트 파일 줄 비표시 오류(Suppression) 상태
오류 NU1107 Xamarin.Android.Support.Compat에 대한 버전 충돌이 검색되었습니다. 프로젝트에서 패키지를 직접 참조하여 이 문제를 해결하세요. 
Project.Android -> Xamarin.Android.Support.v7.MediaRouter 27.0.2.1 -> Xamarin.Android.Support.v7.Palette 27.0.2.1 -> Xamarin.Android.Support.Compat (= 27.0.2.1) 
 Project.Android -> MiGong -> Xamarin.Auth 1.6.0.2 -> Xamarin.Android.Support.CustomTabs 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2).    
오류  패키지 복원에 실패했습니다. 'MiGong.Android'에 대한 패키지 변경 내용을 롤백하고 있습니다.   0 
오류  Xamarin.Android.Support.Compat에 대한 버전 충돌이 검색되었습니다. 프로젝트에서 패키지를 직접 참조하여 이 문제를 해결하세요. 
 Project.Android -> Xamarin.Android.Support.v7.MediaRouter 27.0.2.1 -> Xamarin.Android.Support.v7.Palette 27.0.2.1 -> Xamarin.Android.Support.Compat (= 27.0.2.1) 
 Project.Android -> Xamarin.Auth 1.6.0 -> Xamarin.Android.Support.CustomTabs 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2).  

Xamarin.Auth 를 사용하려는데 위와 같은 에러가 발생되었다.

찾아보니 해결방법은 역시 에러 메세지에 있었다.

Android 프로젝트의 Nuget 에서

Xamarin.Android.Support.Compat 을 찾아 설치하고

그다음으로 Xamarin.Android.Support.v7.Palette 을 설치하면된다.

(순서가 바뀌면 설치되지 않는다.)

그리고 다시 android 프로젝트의 Nuget 에서  Xamarin.Auth 를 설치하면 설치가 제대로 된다.

Syncfusion 의 SfDataGrid 를 사용하는데 갑자기 앱 실행시 위와 같은 팝업이 뜨기 시작했다.;
커뮤니티 버전이라 신경을 안썼는데 언제부턴가 적용이 된건지 모르겠지만 버전을 내려도 동일한 증상이 발생되었다.
(신기하게도 기존 배포된 앱들은 팝업이 뜨지 않는다.;;)

해결방법은 아래 링크로 들어가서 키를 얻어야한다.
(먼저 Syncfusion 에 가입이 되어있어야한다.)
아래 링크도 들어가 LinkedIn login 으로 로그인을하면 키가 얻어진다.
https://www.syncfusion.com/downloads/communitylicense

이제 Syncfusion 의 내계정 정보로 들어가보자

위화면에서 Get License Key 를 클릭하면 키 정보를 얻어올수 있다
그리고 아래 링크를 참고하여 코드를 추가하면 된다.

https://help.syncfusion.com/common/essential-studio/licensing/license-key

xamarin forms

public App()
{
//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");

InitializeComponent();

MainPage = new App1.MainPage();
}

 

참고 : https://www.codeproject.com/Articles/1174042/Fullscreen-Video-Background-Control-for-Xamarin-Fo

요거한번해봐야겠다.

Fullscreen Video Background Control for Xamarin.Forms

How to play video as page background, like Spotify and Uber, using Xamarin.Forms with Android and iOS Custom Renderer.

One of the cool trend on mobile UI I've seen a lot is using video as View background. You can see it on some big mobile app products like Tumblr, Spotify, and Vine. As you can see, they have this cool Home View with sign in and sing up button with video playing in background. This feature is so cool and can make your app look more professional. This time, I'll show you how to implement it in Xamarin.Forms app. All we need is to implement two custom renderers for Android and iOS each.

Note: Please be aware on implementing this feature. It can make your app freeze, draining phone battery, or even make the phone lag. It shouldn't be a problem for the latest devices as long as the video file is in reasonable resolution and file size. Also see some guides on encoding the video into h.264, also mentioned in this tutorial.

Creating Video View Control for Xamarin.Forms

Let's create a new Xamarin.Forms PCL project first and name it BackgroundVideo. Now let's head to the PCL library and create a new class called Video inherited from Xamarin.Forms.View.

using System;
using Xamarin.Forms;

namespace BackgroundVideo.Controls
{
  public class Video : View
  {
  }
}
Video View Class.

For the sake of the tutorial, we're going to make this control with simple requirements.

We need a bindable property to point which video to be displayed. I'm going to call it Source property. It's a string to locate which video file to be played. On iOS, Source property is relative to Resources directory as for Android, it is relative to Assets directory.

public static readonly BindableProperty SourceProperty =
    BindableProperty.Create(
    nameof(Source),
    typeof(string),
    typeof(Video),
    string.Empty,
    BindingMode.TwoWay);

public string Source
{
    get { return (string)GetValue(SourceProperty); }
    set { SetValue(SourceProperty, value); }
}
Video Source Property snippet.

Next thing we need is a boolean to define if we want the video in loop or not. Let's call this property Loop. By default, I set this value as true so when you set a video Source property, it would be looped by default.

Finally, we're going to need a callback fired when video is finished. For simplicity, I use Action class called OnFinishedPlaying. You can modify it to event or anything you comfortable with.

public static readonly BindableProperty LoopProperty =
    BindableProperty.Create(
    nameof(Loop),
    typeof(bool),
    typeof(Video),
    true,
    BindingMode.TwoWay);

public bool Loop
{
    get { return (bool)GetValue(LoopProperty); }
    set { SetValue(LoopProperty, value); }
}

public Action OnFinishedPlaying { get; set; }
Video Loop Property and OnFinishedPlaying callback snippet.

After we created this class, next thing to do is to implement custom renderers for both iOS and Android.

Video View Control iOS Custom Renderer

First thing to do is to create a custom renderer class called VideoRenderer inherited from ViewRenderer<Video, UIView>. The idea is to use iOS native video player with the help of MPMoviePlayerController class and set its native control to our Video custom view. Also we're going to need an NSObject to listen the event from video player wether it is ended or not.

using System;
using System.IO;
using BackgroundVideo.Controls;
using BackgroundVideo.iOS.Renderers;
using Foundation;
using MediaPlayer;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(Video), typeof(VideoRenderer))]
namespace BackgroundVideo.iOS.Renderers
{
  public class VideoRenderer : ViewRenderer<Video, UIView>
  {
    MPMoviePlayerController videoPlayer;
    NSObject notification = null;
  }
}
VideoRenderer for iOS.

To start iOS video player, we need to check wether the video from Source property exists in Resources budnle or not. If it doesn't exist, we'll display an empty view.

If the video file exists, we need to create MPMoviePlayerController and parse the location of the video file as NSUrl. To make our custom control clear, without border or anything, we need to set ControlStyle to MPMovieControlStyle.None and background color to UIColor.Clear.

Also, we probably will have one video file for any resolution. You don't want it to look stretched on some device, right? To make the video resolution looks consistent, we need to set video player ScalingMode to MPMovieScalingMode.AspectFill.

We also have this Loop property to define wether the video playing will be looped or not. To set it to loop, we need to change video player RepeatMode to MPMovieRepeatMode.One. Otherwise, set it to MPMovieRepeatMode.None.

Finally, to make video player play the file, we call PrepareToPlay() function. To display the video to our custom control, we need to use SetNativeControl() function.

void InitVideoPlayer()
{
    var path = Path.Combine(NSBundle.MainBundle.BundlePath, Element.Source);

    if (!NSFileManager.DefaultManager.FileExists(path))
    {
      Console.WriteLine("Video not exist");
      videoPlayer = new MPMoviePlayerController();
      videoPlayer.ControlStyle = MPMovieControlStyle.None;
      videoPlayer.ScalingMode = MPMovieScalingMode.AspectFill;
      videoPlayer.RepeatMode = MPMovieRepeatMode.One;
      videoPlayer.View.BackgroundColor = UIColor.Clear;
      SetNativeControl(videoPlayer.View);
      return;
    }

    // Load the video from the app bundle.
    NSUrl videoURL = new NSUrl(path, false);

    // Create and configure the movie player.
    videoPlayer = new MPMoviePlayerController(videoURL);

    videoPlayer.ControlStyle = MPMovieControlStyle.None;
    videoPlayer.ScalingMode = MPMovieScalingMode.AspectFill;
    videoPlayer.RepeatMode = Element.Loop ? MPMovieRepeatMode.One : MPMovieRepeatMode.None;
    videoPlayer.View.BackgroundColor = UIColor.Clear;
    foreach (UIView subView in videoPlayer.View.Subviews)
    {
      subView.BackgroundColor = UIColor.Clear;
    }

    videoPlayer.PrepareToPlay();
    SetNativeControl(videoPlayer.View);
}
Initialization Video Player for iOS.

The rest of the code is to override OnElementChanged and OnElementPropertyChanged function so it can be functionally working from Xamarin.Forms project. Under OnElementChanged, we need to listen to video player playback finish event and invoke OnFinishedPlaying action. The following snippet is the simplest code necessary to make it work.

protected override void OnElementChanged(ElementChangedEventArgs<Video> e)
{
    base.OnElementChanged(e);

    if (Control == null)
    {
      InitVideoPlayer();
    }
    if (e.OldElement != null)
    {
      // Unsubscribe
      notification?.Dispose();
    }
    if (e.NewElement != null)
    {
      // Subscribe
      notification = MPMoviePlayerController.Notifications.ObservePlaybackDidFinish((sender, args) =>
      {
        /* Access strongly typed args */
        Console.WriteLine("Notification: {0}", args.Notification);
        Console.WriteLine("FinishReason: {0}", args.FinishReason);

        Element?.OnFinishedPlaying?.Invoke();
      });
    }
}

protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
    base.OnElementPropertyChanged(sender, e);
    if (Element == null || Control == null)
      return;

    if (e.PropertyName == Video.SourceProperty.PropertyName)
    {
      InitVideoPlayer();
    }
    else if (e.PropertyName == Video.LoopProperty.PropertyName)
    {
      var liveImage = Element as Video;
      if (videoPlayer != null)
        videoPlayer.RepeatMode = Element.Loop ? MPMovieRepeatMode.One : MPMovieRepeatMode.None;
    }
}
VideoRenderer for iOS.

Now that iOS implementation is completed, let's head to our Android project.

Video View Custom Renderer for Android

Create a new custom renderer on Android project and let's name it VideoRenderer, too. We'll inherit this renderer with ViewRenderer<Video, FrameLayout>, meaning it will be displayed as FrameLayout in native Android control.

One thing that made Android implementation a bit complicated is that we need two kind of views if you want to cover old Android versions. If you just want to cover modern Android OS from Ice Cream Sandwich or more, you can just focus on TextureView implementation, if not you'll also need to implement it using VideoView.

Please note that VideoView implementation here is not optimal. Maybe you'll notice some flickering. That's why I add view called _placeholder. This is just an empty view. It'll be displayed when no video playing or when in video source changed transition. If the video file ready to play and display, _placeholder will be hidden.

using System;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.Media;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using BackgroundVideo.Controls;
using BackgroundVideo.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(Video), typeof(VideoRenderer))]
namespace BackgroundVideo.Droid.Renderers
{
  public class VideoRenderer : ViewRenderer<Video, FrameLayout>,
                 TextureView.ISurfaceTextureListener,
                 ISurfaceHolderCallback
  {
    private bool _isCompletionSubscribed = false;

    private FrameLayout _mainFrameLayout = null;

    private Android.Views.View _mainVideoView = null;
    private Android.Views.View _placeholder = null;

  }
}
VideoRenderer class for Android.

Now before we thing about what video container to use, we need to implement the video player itself. Android already provide us with their MediaPlayer class. We'll need to use this object and make sure it only created once. We can reuse the same object if we change the video source.

We need to set Completion event to implement our OnFinishedPlaying callback. We also need to set Looping property to our custom Loop property.

There is one thing that different from our iOS implementation, there is no easy property set to display video resolution as aspect fill! That means we need to implement our own method into custom function called AdjustTextureViewAspect(). This function will be called on VideoSizeChanged callback. We'll talk about this implementation later.

private MediaPlayer _videoPlayer = null;
internal MediaPlayer VideoPlayer
{
  get
  {
    if (_videoPlayer == null)
    {
      _videoPlayer = new MediaPlayer();

      if (!_isCompletionSubscribed)
      {
        _isCompletionSubscribed = true;
        _videoPlayer.Completion += Player_Completion;
      }

      _videoPlayer.VideoSizeChanged += (sender, args) =>
      {
        AdjustTextureViewAspect(args.Width, args.Height);
      };

      _videoPlayer.Info += (sender, args) =>
      {
        Console.WriteLine("onInfo what={0}, extra={1}", args.What, args.Extra);
        if (args.What == MediaInfo.VideoRenderingStart)
        {
          Console.WriteLine("[MEDIA_INFO_VIDEO_RENDERING_START] placeholder GONE");
          _placeholder.Visibility = ViewStates.Gone;
        }
      };

      _videoPlayer.Prepared += (sender, args) =>
      {
        _mainVideoView.Visibility = ViewStates.Visible;
        _videoPlayer.Start();
        if (Element != null)
          _videoPlayer.Looping = Element.Loop;
      };
    }

    return _videoPlayer;
  }
}

private void Player_Completion(object sender, EventArgs e)
{
  Element?.OnFinishedPlaying?.Invoke();
}
Video player implementation for Android.

Now that we have our video player object, next thing is to create function that play video from Source property. Please remember that video file on Android need to be stored under Assets directory. We can open this file by using Assets.OpenFd(fullPath) function.

If the file doesn't exist, it'll throw Java.IO.IOException. That means we don't need to display anything on our video container.

If the file exists, we just need to reset our video player, then set data source based on previous step. We can't just play the video directly, so we need to prepare it first. When preparation complete, it'll trigger Prepared event and display the video to one of our implemented video view from previous step.

private void PlayVideo(string fullPath)
{
  Android.Content.Res.AssetFileDescriptor afd = null;

  try
  {
    afd = Context.Assets.OpenFd(fullPath);
  }
  catch (Java.IO.IOException ex)
  {
    Console.WriteLine("Play video: " + Element.Source + " not found because " + ex);
    _mainVideoView.Visibility = ViewStates.Gone;
  }
  catch (Exception ex)
  {
    Console.WriteLine("Error openfd: " + ex);
    _mainVideoView.Visibility = ViewStates.Gone;
  }

  if (afd != null)
  {
    Console.WriteLine("Lenght " + afd.Length);
    VideoPlayer.Reset();
    VideoPlayer.SetDataSource(afd.FileDescriptor, afd.StartOffset, afd.Length);
    VideoPlayer.PrepareAsync();
  }
}
Play video implementation for Android.

As previously mentioned, Android doesn't provide us easy property to scale our video to aspect fill. You know it yourself that Android devices have so many screen resolution so keep the video like it is is not an option. We need to scale it properly so it won't look stretched.

Good news is, we can do that if we use TextureView. Bad news is for now I don't know how to implement it with VideoView. But it's better than nothing right?

The idea to make video scale properly is to use matrix to scale the content of TextureView. It is scaled up or down based on video size and view size. Then, after it's scaled, it is positioned at the center of the view.

private void AdjustTextureViewAspect(int videoWidth, int videoHeight)
{
  if (!(_mainVideoView is TextureView))
    return;

  if (Control == null)
    return;

  var control = Control;

  var textureView = _mainVideoView as TextureView;

  var controlWidth = control.Width;
  var controlHeight = control.Height;
  var aspectRatio = (double)videoHeight / videoWidth;

  int newWidth, newHeight;

  if (controlHeight <= (int)(controlWidth * aspectRatio))
  {
    // limited by narrow width; restrict height
    newWidth = controlWidth;
    newHeight = (int)(controlWidth * aspectRatio);
  }
  else
  {
    // limited by short height; restrict width
    newWidth = (int)(controlHeight / aspectRatio);
    newHeight = controlHeight;
  }

  int xoff = (controlWidth - newWidth) / 2;
  int yoff = (controlHeight - newHeight) / 2;

  Console.WriteLine("video=" + videoWidth + "x" + videoHeight +
      " view=" + controlWidth + "x" + controlHeight +
      " newView=" + newWidth + "x" + newHeight +
      " off=" + xoff + "," + yoff);

  var txform = new Matrix();
  textureView.GetTransform(txform);
  txform.SetScale((float)newWidth / controlWidth, (float)newHeight / controlHeight);
  txform.PostTranslate(xoff, yoff);
  textureView.SetTransform(txform);
}
Adjust resolution to Aspect Fill video for Android.

As mentioned earlier, if we want to support a wide range of Android OS, we need to implement it into TextureView and VideoView. This will be implemented under OnElementChanged function. Both implementation have some same properties. We will make their Background color to transparent and layout parameters to match parent. This way it won't have any color to display when there is no video, and it'll fill entire container.

Following snippet is how to implement it on our Video custom renderer. You see it's similar with our iOS implementation, except for container creation and video playing.

protected override void OnElementChanged(ElementChangedEventArgs<Video> e)
{
  base.OnElementChanged(e);

  if (Control == null)
  {
    _mainFrameLayout = new FrameLayout(Context);

    _placeholder = new Android.Views.View(Context)
    {
      Background = new ColorDrawable(Xamarin.Forms.Color.Transparent.ToAndroid()),
      LayoutParameters = new LayoutParams(
        ViewGroup.LayoutParams.MatchParent,
        ViewGroup.LayoutParams.MatchParent),
    };

    if (Build.VERSION.SdkInt < BuildVersionCodes.IceCreamSandwich)
    {
      Console.WriteLine("Using VideoView");

      var videoView = new VideoView(Context)
      {
        Background = new ColorDrawable(Xamarin.Forms.Color.Transparent.ToAndroid()),
        Visibility = ViewStates.Gone,
        LayoutParameters = new LayoutParams(
          ViewGroup.LayoutParams.MatchParent,
          ViewGroup.LayoutParams.MatchParent),
      };

      ISurfaceHolder holder = videoView.Holder;
      if (Build.VERSION.SdkInt < BuildVersionCodes.Honeycomb)
      {
        holder.SetType(SurfaceType.PushBuffers);
      }
      holder.AddCallback(this);

      _mainVideoView = videoView;
    }
    else
    {
      Console.WriteLine("Using TextureView");

      var textureView = new TextureView(Context)
      {
        Background = new ColorDrawable(Xamarin.Forms.Color.Transparent.ToAndroid()),
        Visibility = ViewStates.Gone,
        LayoutParameters = new LayoutParams(
          ViewGroup.LayoutParams.MatchParent,
          ViewGroup.LayoutParams.MatchParent),
      };

      textureView.SurfaceTextureListener = this;

      _mainVideoView = textureView;
    }

    _mainFrameLayout.AddView(_mainVideoView);
    _mainFrameLayout.AddView(_placeholder);

    SetNativeControl(_mainFrameLayout);

    PlayVideo(Element.Source);
  }
  if (e.OldElement != null)
  {
    // Unsubscribe
    if (_videoPlayer != null && _isCompletionSubscribed)
    {
      _isCompletionSubscribed = false;
      _videoPlayer.Completion -= Player_Completion;
    }
  }
  if (e.NewElement != null)
  {
    // Subscribe
    if (_videoPlayer != null && !_isCompletionSubscribed)
    {
      _isCompletionSubscribed = true;
      _videoPlayer.Completion += Player_Completion;
    }
  }
}

protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
  base.OnElementPropertyChanged(sender, e);
  if (Element == null || Control == null)
    return;

  if (e.PropertyName == Video.SourceProperty.PropertyName)
  {
    Console.WriteLine("Play video: " + Element.Source);
    PlayVideo(Element.Source);
  }
  else if (e.PropertyName == Video.LoopProperty.PropertyName)
  {
    Console.WriteLine("Is Looping? " + Element.Loop);
    VideoPlayer.Looping = Element.Loop;
  }
}
VideoRenderer for Android.

Since we're using TextureView and VideoView, there is some function from interfaces need to be implemented. One of them is to remove video when texture or surface is destroyed. To do that, we're going to need to set >_placeholder visibility to visible.

private void RemoveVideo()
{
  _placeholder.Visibility = ViewStates.Visible;
}
Display placeholder to hide video.

When using TextureView, we need to implement TextureView.ISurfaceTextureListener interface. We set video player's surface when texture available and hide it when texture destroyed. Following snippet shows you how to implement it.

#region Surface Texture Listener

public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
{
  Console.WriteLine("Surface.TextureAvailable");
  VideoPlayer.SetSurface(new Surface(surface));
}

public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
{
  Console.WriteLine("Surface.TextureDestroyed");
  RemoveVideo();
  return false;
}

public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
{
  Console.WriteLine("Surface.TextureSizeChanged");
}

public void OnSurfaceTextureUpdated(SurfaceTexture surface)
{
  Console.WriteLine("Surface.TextureUpdated");
}

#endregion
Texture listener implementation.

When using VideoView, we need to implement ISurfaceHolderCallback interface. Similar with TextureView, we set video player's display when surface created and hide it when surface destroyed. The complete implementation of this interface can be see on following snippet.

#region Surface Holder Callback

public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
{
  Console.WriteLine("Surface.Changed");
}

public void SurfaceCreated(ISurfaceHolder holder)
{
  Console.WriteLine("Surface.Created");
  VideoPlayer.SetDisplay(holder);
}

public void SurfaceDestroyed(ISurfaceHolder holder)
{
  Console.WriteLine("Surface.Destroyed");
  RemoveVideo();
}

#endregion
Texture and Surface listener implementation.

That's all we need for Android. Now that we all have everything needed, we can test this control to Xamarin.Forms Page.

Testing to Xamarin.Forms Page

Before we create a test page, I recommend you to prepare your own video file. It is recommended as vertical video so a lot of space won't be wasted.

But, if you don't have any video to test, don't worry. You can download free videos to use from Coverr. They don't have any vertical videos, we can still use it. You can either crop it into vertical video or you can just use it as it is since we already handle scaling to aspect fill on our code.

So use any video you like. I recommend any file as long as it's mp4 video with h264 encoding. In this tutorial, I use video from Coverr called Orchestra. You can download it from here.

Note: For some Android and iOS devices, especially the old products, they probably can't play some mp4 files. This is mostly caused by not-supported baseline profile. To fix that, you can re-encode the video using a tool like ffmpeg and change its baseline profile based on your preferences. See following table to check baseline profile compatibility with iOS. See Supported Media Formats from official Android guide, too.

Profile Level Devices Options
Baseline 3.0 All devices -profile:v baseline -level 3.0
Baseline 3.1 iPhone 3G and later, iPod touch 2nd generation and later -profile:v baseline -level 3.1
Main 3.1 iPad (all versions), Apple TV 2 and later, iPhone 4 and later -profile:v main -level 3.1
Main 4.0 Apple TV 3 and later, iPad 2 and later, iPhone 4s and later -profile:v main -level 4.0
High 4.0 Apple TV 3 and later, iPad 2 and later, iPhone 4s and later -profile:v high -level 4.0
High 4.1 iPad 2 and later, iPhone 4s and later, iPhone 5c and later -profile:v high -level 4.1
High 4.2 iPad Air and later, iPhone 5s and later -profile:v high -level 4.2
h.264 baseline profiles for iOS. Source: ffmpeg

After you get your video file, place it to the folders for each OS. On Android, you should put it under Assets directory. On iOS, you should put it under Resources directory. For this tutorial I put the file under Assets/Videos on Android and Resources/Videos on iOS.

Once you put them all to correct folder, we need to create our Page on Xamarin.Forms PCL project.

This is a simple page with smallest components. We'll create a Home Page, with video background, two text boxes for username and password, and to buttons for sign in and sign up. There is no logic in this page, I just want to show you how to make a beautiful home page.

For better controls placement, I use Grid as container. See following snippet for the complete XAML.

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 

    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 

    xmlns:local="clr-namespace:BackgroundVideo" 

    xmlns:controls="clr-namespace:BackgroundVideo.Controls" 

    x:Class="BackgroundVideo.BackgroundVideoPage">
  <Grid Padding="0" RowSpacing="0" ColumnSpacing="0">
    <controls:Video x:Name="video" Source="Videos/Orchestra.mp4" Loop="true" 

      HorizontalOptions="Fill" VerticalOptions="Fill" />
    <StackLayout VerticalOptions="Center" HorizontalOptions="FillAndExpand" Padding="20,10,10,20">
      <Entry Placeholder="username" FontSize="Large" 

        FontFamily="Georgia" HeightRequest="50">
        <Entry.PlaceholderColor>
          <OnPlatform x:TypeArguments="Color" Android="Silver" />
        </Entry.PlaceholderColor>
        <Entry.TextColor>
          <OnPlatform x:TypeArguments="Color" Android="White" />
        </Entry.TextColor>
      </Entry>
      <Entry Placeholder="password" FontSize="Large" 

        FontFamily="Georgia" HeightRequest="50" IsPassword="true">
        <Entry.PlaceholderColor>
          <OnPlatform x:TypeArguments="Color" Android="Silver" />
        </Entry.PlaceholderColor>
        <Entry.TextColor>
          <OnPlatform x:TypeArguments="Color" Android="White" />
        </Entry.TextColor>
      </Entry>
      <BoxView Color="Transparent" HeightRequest="10" />
      <Button Text="sign in" BackgroundColor="#3b5998" TextColor="#ffffff" 

        FontSize="Large" />
      <Button Text="sign up" BackgroundColor="#fa3c4c" TextColor="#ffffff" 

        FontSize="Large" />
    </StackLayout>
  </Grid>
</ContentPage>
Sample of Home Page with Background Video.

That's it. If you don't want the video to be looped, just change its Loop property. If you want to do something when video ended, just set OnFinishedPlaying from C# code. Now let's see how it runs.

See it in Action

If you set everything correctly, The following figure is how it run on iOS device or emulator. As you can see, there are two text boxes and two buttons. The video is playing as the page background smoothly.

Xamarin iOS Background Video Demo

Similar with iOS version, the following animated gif image shows how it looks on Android device or emulator. See that text box style difference from iOS version. But let's care about it later, the point is video background consistently work just like iOS.

 

Xamarin Android Background Video Demo

All you need to do the rest is to make styling more consistent through any platforms.

Summary

Once again, all I can say is you can make any cross platform control you want by using Custom Renderer. As long as you understand how to code in native language (well, you can Google it though), you can create anything.

As for performance, I believe I said it earlier, you probably see some flickering on old Android devices. For now I don't have any idea to optimize it.

If you have any idea and suggestion, feel free to leave a comment below.

You can download completed project on GitHub.

Xamarin Forms 으로 모바일 개발을 하다보면

xaml 에 대한 화면을 미리 보고 싶을때가 있다. (아니 미리보는게 편하다.)

다행히 Xamarin.Forms Previewer 가 있어 사용해 봤는데 너무 느려서

사용을 안해왔다;; 코딩을 바꾸는데도 버벅인다;;

차라리 디바이스에 계속 배포해서 확인하는게 더 빠르다.

그런데 가끔 유투브 동영상을 보면 고릴라 플레이어로 디자인을 미리 보기 하면서 코딩하는걸 봐왔다..

그런데 고릴라 플레이어 셋팅하는게 그리 간단하지 않아 보여

계속 미루다가 드디어 오늘 셋팅을 완료했다.

그래서 과정을 정리해본다.

 

일단 아래 블로그는 mac 환경에서 환경 셋팅을 한 내용이다.

http://picory.com/entry/Forns-XAML-Previewer-Gorilla-Player

난 Window10 으로 시도했다.

 

1. 고릴라 플레이어 사이트에서 계정을 만든다.

아래링크로 들어가 REGISTER NOW 를 클릭한다.

https://grialkit.com/gorilla-player/

계정을 만든다. 암호는 대문자가 포함되어야한다. (특수문자는 없어도 됨)

 

계정을 만들었으면 계정 메일로 아래와 같이 메일이 오고 링크를 클릭하여 메일 인증을 한다.

메일 인증 완료!

 

2. 고릴라 플레이어(Gorilla Player)를 다운로드 한다.

아래 링크로 들어가서

https://grialkit.com/gorilla-download/

Windows 버전을 다운로드 하고 설치를 한다.

가끔사이트가 먹통이 될때가 있어 설치파일을 첨부한다.

설치 과정은 아래와 같다. 특별한 건 없다.

 

3. 고릴라 플레이어를 실행한다.

고릴라 플레이어 실행 과정이다.

아래 그림에서는 당연히 동의를....

설치할걸 체크해야하는데 기본적으로 알아서 잘 체크가 되어있다.

체크 추가 없이 다음.. (Install addin for Visual Studio, Install Player + Sample)

설치 진행중...

설치 완료!!

아래 처럼 고릴라 아이콘이 시계표시줄에 표시되어있으면 일단 정상적으로 설치 및 실행이 된것이다.

 

4. 시뮬레이터 셋팅

실행(Continue)을 하면 아래와 같은 화면이 나온다.

친절하게 설명이 잘되어있다.

아래 부분이 조금 헷깔리는데 구글 플레이에서 고릴라플레이어앱을 다운받거나 직접 소스를 열어서 설치를 할수 있다.

시뮬레이터에 설치할것이므로 소스를 열어서 직접 설치를해야한다.

아래 화면에서 빨간색 버튼을 클릭한다. 그러면  Player.sln 솔루션 이 열린다.

아래와 같이 솔루션이 열리면 구동하고자 하는 시뮬레이터를 선택한 후 Run 한다.

그럼 아래 처럼 시뮬레이터에 고릴라 플레이어앱이 설치가 된다.

설치된 앱을 구동해 보자.

앱을 구동하면 Connecting 을 기다리고 있다.

 

5. xaml 파일 보기

이제 xaml 파일을 열어 디자인이 보여지는지 확인해보자.

Visual Studio 를 열고 도구>Gorilla Player 에서 아래 그림과 같이 Disconnect From Gorilla  으로 되어있는지 확인한다.

만약 안되어있다면 Connect From Gorilla 를 실행해야된다.

이제 xaml 파일을 하나 선택하고 마우스 우측 버튼의 메뉴에서

Stick Gorilla to this XAML 를 클릭한다.

그럼 아래 처럼 시뮬레이터에서 먼가 연결이 진행된다.

엇 에러가 발생되었다.

xaml 에 에러가 있거나 하면 아래 처럼 에러가 표시된다.

마스터 디테일 페이지(MasterDetailPage) 인 경우는 아직 표현하지 못하는것 같다.

아래처럼 xaml 페이지가 정상적으로 시뮬레이터에 표시가 된다.

xaml 의 내용이 시뮬레이터에 보여지고 있다면 아래처럼 우측 상단에 고릴라 아이콘이 나타난다.

xaml 파일을 변경하면 실시간으로 시뮬레이터에 반영된다. (아래 동영상참고)

* 참고

도움말 : https://github.com/UXDivers/Gorilla-Player-Support

* 추가

혹 비쥬얼 스튜디오에 addin 이 제대로 되지 않았다면 직접 addin 쪽만 아래 링크나 첨부파일로 설치를 진행하면된다.

https://marketplace.visualstudio.com/items?itemName=UXDivers.GorillaPlayerVisualStudioddin

UXDivers.Artina.Player.VSAddin.vsix

 

 

출처 : https://github.com/jsuarezruiz/xamarin-forms-goodlooking-UI

Xamarin.Forms goodlooking UI Samples

A curated list of awesome Xamarin.Forms samples to show how to create goodlooking UI with Xamarin.Forms.

Work in progress. Contributions are always welcome!

Would you like to see a list of published applications made with Xamarin.Forms?. Thank you David Ortinau for the list!

ConferenceVision

Sample Xamarin.Forms 3.0 Phone App showed in Microsoft Build 2018. Use your camera during a conference to capture your experience. Let Vision do the heavy lifting of identifying known products and scan your images to text for easier searching.

Platforms

Android, iOS & UWP.

Features:

  • Xamarin.Forms 3.0
  • FlexLayout
  • CSS
  • VisualStateManager
  • Custom Vision
  • Computer Vision API

More information:

SmartHotel

Travelers are always on the go, so SmartHotel360 offers a beautiful fully-native cross-device mobile app for guests and business travelers built with Xamarin.

Platforms

Android, iOS & UWP.

Features:

  • Custom animations from XAML.
  • Custom Map.
  • SkiaSharp Charts.
  • Xamarin.Forms Native Forms.
  • Live Player.
  • NFC.

More information:

BikeSharing

BikeSharing360 is a fictitious example of a smart bike sharing system with 10,000 bikes distributed in 650 stations located throughout New York City and Seattle. Their vision is to provide a modern and personalized experience to riders and to run their business with intelligence. Was a demo in the Connect(); 2016.

Platforms

Android, iOS & UWP.

Features:

  • Custom animations from XAML.
  • Custom Map.

More information:

Bikr

A bike activity App. Sample to show Microcharts usage.

Platforms

Android, iOS & UWP.

Features:

  • SkiaSharp charts.

More information:

Evolve

Xamarin Evolve 2016 Mobile App.

This app is around 15,000 lines of code. The iOS version contains 93% shared code, the Android version contains 90% shared code, the UWP has 99% shared code, and our Azure backend contains 23% shared code with the clients!

Platforms

Android, iOS & UWP.

Features:

  • Azure + Online/Offline Sync
  • Barcode Scanning
  • Calendar Integration
  • Maps & Navigation
  • Push Notifications
  • Phone Dialer
  • Wi-Fi configuration
  • URL Navigation (Universal Links + Google App Indexing)

More information:

GreatPlaces

ListView with transparent background and a purple gradient behind.

Platforms

Android, iOS & UWP.

Features:

  • Custom ViewCells.

More information:

InAnger

Samples to show that Xamarin.Forms is capable of creating something that looks really good.

Platforms

Android & iOS.

Samples

  • Find a Vet
  • Phoenix Peaks
  • Jobbberr
  • Woofer
  • HeatMap
  • Hot Sauce
  • Findr
  • MallDash

More information:

Instagram

Platforms

Android, iOS & UWP.

Features:

More information:

Social Media

This sample show how to recreate a beautifull Social Network profile type page in Xamarin.Forms.

Features:

  • Curved header Image.
  • Profile Image that overlaps the header.

More information:

KickassUI.FancyTutorial

A simple (but beautiful) Xamarin.Forms tutorial screen.

Platforms

Android & iOS.

Features

More information:

KickassUI.Runkeeper

A Xamarin.Forms version of the Runkeeper App.

Platforms

Android & iOS.

Features:

  • Custom Tabs.
  • Custom fonts in the page header.
  • Custom logo in page header.
  • Carousel.
  • Custom Map.

More information:

KickassUI.Spotify

A Xamarin.Forms version of the Spotify App.

Platforms

Android & iOS.

Features:

  • Translucent navigation bar.
  • Blurred fullscreen background.
  • Custom Slider.

More information:

KickassUI.Twitter

A Xamarin.Forms version of the Twitter App.

Platforms

Android & iOS.

Features:

  • Android floating action button.
  • MasterDetailPage custom icon.
  • Custom Tabs (colors).

More information:

Timeline

A timeline of activities. This is useful for things like transportation schedules or class times.

Platforms

Android, iOS & UWP.

Features:

  • ListView Header and Footer.
  • Custom ViewCell.

More information:

Xamarin.Netflix

A Xamarin.Forms version of the Netflix App.

Choose Profile Home Main Menu Movie Detail

Platforms

Android & iOS.

Features:

  • Horizontal List.
  • Transparent NavigationBar on Android and iOS.
  • Parallax effect.
  • Multi-column List.

More information:

Facebook

A Xamarin.Forms version of the Facebook App.

Platforms

Android, iOS & UWP.

Features:

  • Right Slide Bar.
  • Disappearing NavigationBar.
  • Like Animations.

More information:

Movies

Movies is a Xamarin.Forms GTK backend application that makes use of The Movie Database (TMDb) API to demonstrate the possibilities of the new backend making use of a great variety of functionality.

Platforms

Android, iOS, Linux (GTK), macOS, UWP and Windows (WPF).

Features:

  • MasterDetailPage.
  • Maps.
  • Gtk Themes.
  • Desktop Apps for Linux, macOS and Windows.

More information:

WalkthroughApp

WalkthroughApp is a Xamarin.Forms application that makes use CarouselView and Lottie, to demonstrate the possibilities of creating a fluid and powerful Walkthrough without requiere Custom Renderers.

Platforms

Android, iOS.

Features:

  • CarouselView
  • Lottie
  • Animations

More information:

+ Recent posts

티스토리 툴바