Example #1
0
        private void NativeSetPlayPosition(long position, bool accurate, bool nanoseconds,
                                           NativePlayer.SeekCompletedCallback cb)
        {
            //Check if it is nanoseconds or milliseconds.
            var ret = !nanoseconds?NativePlayer.SetPlayPosition(Handle, (int)position, accurate, cb, IntPtr.Zero) :
                          NativePlayer.SetPlayPositionNanoseconds(Handle, position, accurate, cb, IntPtr.Zero);

            //Note that we assume invalid param error is returned only when the position value is invalid.
            if (ret == PlayerErrorCode.InvalidArgument)
            {
                throw new ArgumentOutOfRangeException(nameof(position), position,
                                                      "The position is not valid.");
            }
            if (ret != PlayerErrorCode.None)
            {
                Log.Error(PlayerLog.Tag, "Failed to set play position, " + (PlayerError)ret);
            }
            ret.ThrowIfFailed(this, "Failed to set play position");
        }