GitHub - ravensorb/XamVideoPlayer: Xamarin Cross Platform Video Player
おそらくコレがいい。
インストールはPackagesから行ける、 「Xamarin Plygin - Video Player」を選ぶべき。 上のは有料。
コレが依存しているのでこれも入れないといけないようだ。
PropertyChanged.Fordyというやつ。
入れないとのちほどのPropertyChanged
で怒られる。
まず、任意のContentPageのXAMLで新規作成。
VideoPlayerPage
で作った。
using System; using System.Collections.Generic; using Xamarin.Forms; namespace MyPackageName { public partial class VideoPlayerPage : ContentPage { public VideoPlayerPage() { InitializeComponent(); } } }
VideoPlayerViewModel.csを追加。
using System.Collections.Generic; using System.Collections.ObjectModel; namespace MyPackageName { [PropertyChanged.ImplementPropertyChanged] public class VideoPlayerViewModel { public VideoPlayerViewModel() { Videos = new ObservableCollection<VideoItem>(); Videos.Add(new VideoItem { Title = "Big Buck Bunny", PlaybackUrl = "http://download.openbricks.org/sample/H264/big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4" }); } public ICollection<VideoItem> Videos { get; set; } public VideoItem SelectedVideo { get; set; } } [PropertyChanged.ImplementPropertyChanged] public class VideoItem { public string Title { get; set; } public string PlaybackUrl { get; set; } } }
MyPackageNameは自分のパッケージ名を任意で。 いらないなら外す。
その後で、
this.MainPage = new VideoPlayerPage { BindingContext = new VideoPlayerViewModel() };
でMainPage
に追加。
Readmeにあったようにinfo.plist
に以下を追加。
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
を参考に。