Exemplo n.º 1
0
        /// <summary>
        /// Gets the language code for the specified index, or null if the language is undefined.
        /// </summary>
        /// <returns>The number of tracks.</returns>
        /// <remarks>
        ///     <para>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>,
        ///     <see cref="PlayerState.Playing"/>, or <see cref="PlayerState.Paused"/> state.</para>
        ///     <para>The language codes are defined in ISO 639-1.</para>
        /// </remarks>
        /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <paramref name="index"/> is less than zero.<br/>
        ///     -or-<br/>
        ///     <paramref name="index"/> is equal to or greater than <see cref="GetCount()"/>.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public string GetLanguageCode(int index)
        {
            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            if (index < 0 || GetCount() <= index)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index,
                                                      $"Valid index range is 0 <= x < {nameof(GetCount)}(), but got { index }.");
            }

            IntPtr code = IntPtr.Zero;

            try
            {
                NativePlayer.GetTrackLanguageCode(_owner.Handle, _streamType, index, out code).
                ThrowIfFailed(_owner, "Failed to get the selected language of the player");

                string result = Marshal.PtrToStringAnsi(code);

                if (result == "und")
                {
                    Log.Error(PlayerLog.Tag, "not defined code");
                    return(null);
                }
                Log.Info(PlayerLog.Tag, "get language code : " + result);
                return(result);
            }
            finally
            {
                LibcSupport.Free(code);
            }
        }
Exemplo n.º 2
0
        private string GetCodecInfo(bool audioInfo)
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            IntPtr audioPtr = IntPtr.Zero;
            IntPtr videoPtr = IntPtr.Zero;

            try
            {
                NativePlayer.GetCodecInfo(Player.Handle, out audioPtr, out videoPtr).
                ThrowIfFailed("Failed to get codec info");

                if (audioInfo)
                {
                    Log.Debug(PlayerLog.Tag, "it is audio case");
                    return(Marshal.PtrToStringAnsi(audioPtr));
                }
                else
                {
                    Log.Debug(PlayerLog.Tag, "it is video case");
                    return(Marshal.PtrToStringAnsi(videoPtr));
                }
            }
            finally
            {
                LibcSupport.Free(audioPtr);
                LibcSupport.Free(videoPtr);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the metadata with the specified key.
        /// </summary>
        /// <returns>A string that represents the value of the specified key.</returns>
        /// <param name="key">The key to query.</param>
        /// <remarks>
        /// The <see cref="Multimedia.Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>,
        /// <see cref="PlayerState.Playing"/>, or <see cref="PlayerState.Paused"/> state.</remarks>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed of.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public string GetMetadata(StreamMetadataKey key)
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            ValidationUtil.ValidateEnum(typeof(StreamMetadataKey), key);

            IntPtr ptr = IntPtr.Zero;

            try
            {
                NativePlayer.GetContentInfo(Player.Handle, key, out ptr).
                ThrowIfFailed($"Failed to get the meta data with the key '{ key }'");

                return(Marshal.PtrToStringAnsi(ptr));
            }
            finally
            {
                LibcSupport.Free(ptr);
            }
        }