2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using System.ComponentModel;
21 namespace Tizen.Multimedia
23 public partial class Player
25 private static List<Action<Player, int, string>> _errorHandlers;
27 private static object _errorHandlerLock = new object();
30 /// This method supports the product infrastructure and is not intended to be used directly from application code.
32 /// <since_tizen> 4 </since_tizen>
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 protected static void AddErrorHandler(Action<Player, int, string> errorHandler)
36 if (errorHandler == null)
38 throw new ArgumentNullException(nameof(errorHandler));
41 lock (_errorHandlerLock)
43 if (_errorHandlers == null)
45 _errorHandlers = new List<Action<Player, int, string>>();
48 _errorHandlers.Add(errorHandler);
53 /// This method supports the product infrastructure and is not intended to be used directly from application code.
55 /// <since_tizen> 4 </since_tizen>
56 [EditorBrowsable(EditorBrowsableState.Never)]
57 protected static void RemoveErrorHandler(Action<Player, int, string> errorHandler)
59 lock (_errorHandlerLock)
61 _errorHandlers?.Remove(errorHandler);
65 internal static void NotifyError(Player player, int errorCode, string message)
67 if (_errorHandlers == null)
72 lock (_errorHandlerLock)
74 foreach (var handler in _errorHandlers)
76 handler(player, errorCode, message);