Exemple #1
0
        private static void GetSupportedTypes()
        {
            if (_supportedAudioFormats == null && _supportedVideoFormats == null)
            {
                PlayerHandle _playerHandle;
                IntPtr       _handle;

                NativePlayer.Create(out _playerHandle).ThrowIfFailed(null, "Failed to create player");
                _handle = _playerHandle.DangerousGetHandle();
                Debug.Assert(_handle != IntPtr.Zero);

                try
                {
                    _supportedAudioFormats = new List <MediaFormatAudioMimeType>();
                    _supportedVideoFormats = new List <MediaFormatVideoMimeType>();

                    NativePlayer.SupportedMediaFormatCallback callback = (int format, IntPtr userData) =>
                    {
                        if (Enum.IsDefined(typeof(MediaFormatAudioMimeType), format))
                        {
                            Log.Debug(PlayerLog.Tag, "supported audio : " + ((MediaFormatAudioMimeType)format).ToString());
                            _supportedAudioFormats.Add((MediaFormatAudioMimeType)format);
                        }
                        else if (Enum.IsDefined(typeof(MediaFormatVideoMimeType), format))
                        {
                            Log.Debug(PlayerLog.Tag, "supported video : " + ((MediaFormatVideoMimeType)format).ToString());
                            _supportedVideoFormats.Add((MediaFormatVideoMimeType)format);
                        }
                        else
                        {
                            Log.Debug(PlayerLog.Tag, "skipped : " + format.ToString());
                        }

                        return(true);
                    };

                    NativePlayer.SupportedMediaStreamFormat(_handle, callback, IntPtr.Zero).
                    ThrowIfFailed(null, "Failed to get the list");
                }
                finally
                {
                    _playerHandle.Dispose();
                }
            }
        }
Exemple #2
0
        private IList <MediaFormatAudioMimeType> GetSupportedFormats()
        {
            List <MediaFormatAudioMimeType> audioFormats = new List <MediaFormatAudioMimeType>();

            NativePlayer.SupportedMediaFormatCallback callback = (int format, IntPtr userData) =>
            {
                if (!Enum.IsDefined(typeof(MediaFormatAudioMimeType), format))
                {
                    Log.Warn(PlayerLog.Tag, "not supported : " + format.ToString());
                    return(false);
                }

                Log.Debug(PlayerLog.Tag, "supported : " + ((MediaFormatAudioMimeType)format).ToString());
                audioFormats.Add((MediaFormatAudioMimeType)format);
                return(true);
            };

            NativePlayer.SupportedAudioOffloadFormat(_player.Handle, callback, IntPtr.Zero).
            ThrowIfFailed(_player, "Failed to get the supported formats for audio offload");

            return(audioFormats.AsReadOnly());
        }