Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.MediaPlayer / Player / MediaUriSource.cs
1 /// Media Uri source
2 /*
3  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
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 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     public sealed class MediaUriSource : MediaSource
32     {
33         // TODO consider using Uri class.
34         /// <summary>
35         /// Initializes a new instance of the MediaUriSource class with the specified uri.</summary>
36         /// <param name="uri">The uri string.</param>
37         /// <remarks>For HTTP or RSTP, uri should start with "http://" or "rtsp://".
38         /// The default protocol is "file://".
39         /// If you provide an invalid uri, you won't receive an error until <see cref="Player.Start"/> is called.</remarks>
40         public MediaUriSource(string uri)
41         {
42             Uri = uri ?? throw new ArgumentNullException(nameof(uri));
43         }
44
45         /// <summary>
46         /// Gets the uri.
47         /// </summary>
48         public string Uri { get; }
49
50         internal override void OnAttached(Player player)
51         {
52             NativePlayer.SetUri(player.Handle, Uri).ThrowIfFailed("Failed to set the source with specified uri");
53         }
54     }
55 }
56