万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    Xamarinでmpeg4

    GitHub - ravensorb/XamVideoPlayer: Xamarin Cross Platform Video Player

    おそらくコレがいい。

    インストールはPackagesから行ける、 「Xamarin Plygin - Video Player」を選ぶべき。 f:id:shinriyo:20160718201154p:plain 上のは有料。

    コレが依存しているのでこれも入れないといけないようだ。 PropertyChanged.Fordyというやつ。 f:id:shinriyo:20160718200742p:plain 入れないとのちほどの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>

    https://github.com/ravensorb/XamVideoPlayer/blob/master/samples/Xam.Plugins.VideoPlayer.Sample.iOS/Info.plist

    を参考に。