* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.IO;
using Tizen.Internals.Errors;
ServiceDisconnected = PlayerErrorClass | 0x0d,
NotSupportedAudioCodec = PlayerErrorClass | 0x0e,
NotSupportedVideoCodec = PlayerErrorClass | 0x0f,
- NotSupportedSubtitle = PlayerErrorClass | 0x10
+ NotSupportedSubtitle = PlayerErrorClass | 0x10,
+ NotAvailable = PlayerErrorClass | 0x12
}
internal static class PlayerErrorCodeExtensions
{
- internal static void ThrowIfFailed(this PlayerErrorCode err, string message)
+ internal static void ThrowIfFailed(this PlayerErrorCode errorCode, Player player, string message)
{
- if (err == PlayerErrorCode.None)
+ if (errorCode == PlayerErrorCode.None)
{
return;
}
- throw err.GetException(message);
+ var ex = errorCode.GetException(message);
+
+ if (ex == null)
+ {
+ // Notify only when it can't be handled.
+ player?.NotifyError((int)errorCode, message);
+
+ throw new InvalidOperationException($"{message} : Unknown error({errorCode.ToString()}).");
+ }
+
+ throw ex;
}
- internal static Exception GetException(this PlayerErrorCode err, string message)
+ internal static Exception GetException(this PlayerErrorCode errorCode, string message)
{
- if (err == PlayerErrorCode.None)
+ if (errorCode == PlayerErrorCode.None)
{
return null;
}
- string msg = $"{ (message ?? "Operation failed") } : { err.ToString() }.";
+ string msg = $"{ (message ?? "Operation failed") } : { errorCode.ToString() }.";
- switch (err)
+ switch (errorCode)
{
case PlayerErrorCode.InvalidArgument:
case PlayerErrorCode.InvalidUri:
case PlayerErrorCode.NotSupportedVideoCodec:
throw new CodecNotSupportedException(CodecKind.Video);
+ case PlayerErrorCode.NotAvailable:
+ throw new NotAvailableException(msg);
+
+ default:
+ Log.Info(PlayerLog.Tag, "Unknow error: " + errorCode);
+ break;
}
- throw new InvalidOperationException(msg);
+ return null;
}
}
/// <summary>
/// The exception that is thrown when there is no available space in a buffer.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class NoBufferSpaceException : InvalidOperationException
{
/// <summary>
/// Initializes a new instance of the NoBufferSpaceException class with a specified error message.
/// </summary>
/// <param name="message">Error description.</param>
+ /// <since_tizen> 3 </since_tizen>
public NoBufferSpaceException(string message) : base(message)
{
}
/// <summary>
/// The exception that is thrown when there is no available resource for internal use.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ResourceLimitException : InvalidOperationException
{
/// <summary>
/// Initializes a new instance of the ResourceLimitException class with a specified error message.
/// </summary>
/// <param name="message">Error description.</param>
+ /// <since_tizen> 3 </since_tizen>
public ResourceLimitException(string message) : base(message)
{
}
}
+
+ /// <summary>
+ /// The exception that is thrown when it is not available.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class NotAvailableException : Exception
+ {
+ /// <summary>
+ /// Initializes a new instance of the NotAvailableException class with a specified error message.
+ /// </summary>
+ /// <param name="message">Error description.</param>
+ /// <since_tizen> 6 </since_tizen>
+ public NotAvailableException(string message) : base(message)
+ {
+ }
+ }
}