private void CreateRealTimePlayer()
        {
            Debug.Log("RealtimeVideoPlayer::CreateRealTimePlayer");

            // Only initialize if we have a connection and don't already have a player
            if (this.networkConnection == null || isPlayerCreated)
            {
                Debug.Log("RealtimeVideoPlayer::CreateRealTimePlayer - Connection=null or isPlayerCreated");
                return;
            }

            this.onCreatedCallback      = new PlayerPlugin.PlayerCreatedCallback(Player_PluginCallbackWrapper.OnCreated_Callback);
            this.onStateChangedCallback = new PlayerPlugin.StateChangedCallback(Player_PluginCallbackWrapper.OnStateChanged_Callback);

            IntPtr thisObjectPtr = GCHandle.ToIntPtr(this.thisObject);

            // Create our RealtimePlayer at the Plugin C++ layer
            PluginUtils.CheckHResult(PlayerPlugin.exCreatePlayer(
                                         this.networkConnection.Handle,
                                         this.onStateChangedCallback,
                                         this.onCreatedCallback,
                                         thisObjectPtr,
                                         ref this.playerHandle
                                         ), "RealtimeVideoPlayer::exCreatePlayer()");

            if (!isPlayerCreated)
            {
                Shutdown();
                return;
            }
        }
        public Registration(PlayerPlugin[] _types)
        {
            InitializeComponent();
            this.types = new List<PlayerPlugin>(_types);
            this.types.Insert(0, new PlayerPlugin() { ID="",Name= "Human"});
            PlayerType0.ItemsSource = types;
            PlayerType2.ItemsSource = types;
            PlayerType3.ItemsSource = types;
            PlayerType4.ItemsSource = types;
            PlayerType0.SelectedIndex = 0;
            PlayerType2.SelectedIndex = 3;
            PlayerType3.SelectedIndex = 3;
            PlayerType4.SelectedIndex = 3;

            lst_Rounds.ItemsSource = (from i in new[] { 1, 2, 5, 10, 15, 20, 50, 100, 200, 1000 }
                                     select new StamItem() { Value = i, Name = i.ToString() }).ToArray();
            lst_Rounds.DisplayMemberPath = "Name";
            lst_Rounds.SelectedIndex = 3;

            lst_Speed.ItemsSource = new[] { new StamItem { Value = 100, Name = "Super Fast" }, new StamItem { Value = 500, Name = "Fast" },
                new StamItem { Value = 1000, Name = "Ahh" }, new StamItem { Value = 5000, Name = "Slow" }};

            lst_Speed.DisplayMemberPath = "Name";
            lst_Speed.SelectedIndex = 1;
            img_background.Source = new BitmapImage(
                new Uri("http://" + MainApp.SERVICE_ADDRESS.Host + ":" + MainApp.SERVICE_ADDRESS.Port + "/Wist/Images/wood-table-texture-3.jpg", UriKind.Absolute)
                );
            if (MainApp.viewMode == App.ViewMode.Facebook)
            {
                lbl_facebook_login.Content = String.Format("Hi {0}", MainApp.firstName) ;
                PlayerName.Text = MainApp.firstName;
                PlayerName.Visibility = System.Windows.Visibility.Collapsed;
                lbl_facebook_login.Visibility = System.Windows.Visibility.Visible;
            }
        }
        /// <summary>
        /// Callback from the Native plugin when a realtime player has been created at the c++ level
        /// </summary>
        /// <param name="result">HRESULT from creation</param>
        /// <param name="width">streaming texture width</param>
        /// <param name="height">streaming texture height</param>
        private void OnCreated(long result, uint width, uint height)
        {
            this.plugin.QueueAction(() =>
            {
                Debug.Log("RealtimeVideoPlayer::OnCreated");
                PluginUtils.CheckHResult(result, "RealtimeVideoPlayer::OnCreated");

                // Weird bug seen on ARM. width/height parameters passed into this function are invalid values
                PluginUtils.CheckHResult(PlayerPlugin.exGetStreamResolution(this.playerHandle, ref width, ref height),
                                         "RealtimeVideoPlayer::exGetStreamResolution");

                if (!IsValidResolution(width, height))
                {
                    Debug.LogError("RealtimeVideoPlayer::OnCreated() Invalid streaming resolution width=" + width + " - height=" + height);
                    Shutdown();
                    return;
                }

                this.TextureWidth          = width;
                this.TextureHeight         = height;
                IntPtr nativeTexturePtr_L  = IntPtr.Zero;
                IntPtr nativeTexturePtr_UV = IntPtr.Zero;

                // It is more performant to utilize YUV texture for video streaming/rendering
                // https://docs.microsoft.com/en-us/windows/desktop/medfound/recommended-8-bit-yuv-formats-for-video-rendering

                // Get pointers to the Luma/Chroma textures being used by MediaFoundation in the native plugin
                PluginUtils.CheckHResult(PlayerPlugin.exCreateExternalTexture(this.playerHandle,
                                                                              this.TextureWidth, this.TextureHeight,
                                                                              out nativeTexturePtr_L, out nativeTexturePtr_UV),
                                         "RealtimeVideoPlayer::exCreateExternalTexture");

                this.Texture_Luma = Texture2D.CreateExternalTexture((int)this.TextureWidth,
                                                                    (int)this.TextureHeight,
                                                                    TextureFormat.RG16,
                                                                    false,
                                                                    true,
                                                                    nativeTexturePtr_L);

                this.Texture_Chroma = Texture2D.CreateExternalTexture((int)this.TextureWidth,
                                                                      (int)this.TextureHeight,
                                                                      TextureFormat.R8,
                                                                      false,
                                                                      true,
                                                                      nativeTexturePtr_UV);

                if (AutoPlay)
                {
                    Play();
                }
            });
        }
        public void Stop()
        {
            if (!this.isPlayerCreated)
            {
                return;
            }

            Debug.Log("RealTimePlayer::Stop");

            // Run plugin command on background thread and not UI thread. Weird bug where MF locks the thread
            Task task = new Task(() =>
            {
                PluginUtils.CheckHResult(PlayerPlugin.exStop(this.playerHandle), "RealTimePlayer::exStop");
                this.plugin.QueueAction(() => this.PlayerState = PlaybackState.Ended);
            });

            task.Start();
        }
        public void Shutdown()
        {
            Debug.Log("RealtimeVideoPlayer::Shutdown");

            if (this.connector != null)
            {
                this.StopConnector();
            }

            if (this.isPlayerCreated)
            {
                Stop();

                CloseNetworkConnection();

                PluginUtils.CheckHResult(PlayerPlugin.exReleasePlayer(this.playerHandle), "RealtimeVideoPlayer::exReleasePlayer()");
                this.Texture_Luma           = this.Texture_Chroma = null;
                this.onCreatedCallback      = null;
                this.onStateChangedCallback = null;
                this.playerHandle           = PluginUtils.InvalidHandle;

                PlayerState = PlaybackState.None;
            }
        }
Esempio n. 6
0
 public static string GetBicFileName(this NwPlayer player)
 => PlayerPlugin.GetBicFileName(player);
Esempio n. 7
0
 public static void DisplayFloatingTextStringOnCreature(this NwPlayer player, NwCreature creature, string text)
 => PlayerPlugin.FloatingTextStringOnCreature(player, creature, text);
Esempio n. 8
0
 public static void SetRestDuration(this NwPlayer player, int durationMs)
 {
     PlayerPlugin.SetRestDuration(player, durationMs);
 }
Esempio n. 9
0
 public static void SetPlaceableNameOverride(this NwPlayer player, NwPlaceable placeable, string name)
 {
     PlayerPlugin.SetPlaceableNameOverride(player, placeable, name);
 }
Esempio n. 10
0
 public static void ForceOpenInventory(this NwPlayer player, NwPlaceable target)
 {
     PlayerPlugin.ForcePlaceableInventoryWindow(player, target);
 }
Esempio n. 11
0
 public static QuickBarSlot GetQuickBarSlot(this NwPlayer player, int slot)
 {
     return(PlayerPlugin.GetQuickBarSlot(player, slot));
 }
Esempio n. 12
0
 public static void SetQuickBarSlot(this NwPlayer player, int slot, QuickBarSlot data)
 {
     PlayerPlugin.SetQuickBarSlot(player, slot, data);
 }
Esempio n. 13
0
 void LoadRegistration(PlayerPlugin[] types)
 {
     mainPanel.Child = new Registration(types);
 }