[MediaPlayer] Added ErrorHandler registration methods for internal use. (#33)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.MediaPlayer / Player / MediaUriSource.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using static Interop;
19
20 namespace Tizen.Multimedia
21 {
22     /// <summary>
23     /// Represents a media source with a uri.
24     /// </summary>
25     /// <remarks>
26     /// The internet privilege(http://tizen.org/privilege/internet) must be added if any URLs are used to play from a network.
27     /// The mediastorage privilege(http://tizen.org/privilege/mediastorage) must be added if any video/audio files are used to play located in the internal storage.
28     /// The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any video/audio files are used to play located in the external storage.
29     /// </remarks>
30     /// <seealso cref="Player.SetSource(MediaSource)"/>
31     /// <since_tizen> 3 </since_tizen>
32     public sealed class MediaUriSource : MediaSource
33     {
34         // TODO consider using Uri class.
35         /// <summary>
36         /// Initializes a new instance of the MediaUriSource class with the specified uri.</summary>
37         /// <param name="uri">The uri string.</param>
38         /// <remarks>For HTTP or RSTP, uri should start with "http://" or "rtsp://".
39         /// The default protocol is "file://".
40         /// If you provide an invalid uri, you won't receive an error until <see cref="Player.Start"/> is called.</remarks>
41         /// <since_tizen> 3 </since_tizen>
42         public MediaUriSource(string uri)
43         {
44             Uri = uri ?? throw new ArgumentNullException(nameof(uri));
45         }
46
47         /// <summary>
48         /// Gets the uri.
49         /// </summary>
50         /// <since_tizen> 3 </since_tizen>
51         public string Uri { get; }
52
53         internal override void OnAttached(Player player)
54         {
55             NativePlayer.SetUri(player.Handle, Uri).
56                 ThrowIfFailed(player, "Failed to set the source with specified uri");
57         }
58     }
59 }
60