예제 #1
0
        private void AddItemToPlaylist(string index, MediaControlMetadata metadata)
        {
            void AddMetadataToNative(string idx, MediaControllerNativeAttribute attribute, string value)
            {
                // This API doesn't save playlist to the storage. So we need to call MediaControlServer.SavePlaylist()
                // after all items are updated.
                NativePlaylist.UpdatePlaylist(Handle, idx, attribute, value)
                .ThrowIfError("Failed to update playlist");
            }

            AddMetadataToNative(index, MediaControllerNativeAttribute.Album, metadata.Album);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Artist, metadata.Artist);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Author, metadata.Author);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Copyright, metadata.Copyright);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Date, metadata.Date);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Description, metadata.Description);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Duration, metadata.Duration);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Genre, metadata.Genre);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Picture, metadata.AlbumArtPath);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Title, metadata.Title);
            AddMetadataToNative(index, MediaControllerNativeAttribute.TrackNumber, metadata.TrackNumber);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Season, metadata.EncodedSeason);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Episode, metadata.EncodedEpisode);
            AddMetadataToNative(index, MediaControllerNativeAttribute.Resolution, metadata.EncodedResolution);
        }
예제 #2
0
        /// <summary>
        /// Sets the metadata to the playlist.
        /// </summary>
        /// <param name="index">The index of media in the playlist.</param>
        /// <param name="metadata">The metadata of media.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="index"/> or <paramref name="metadata"/> is null.
        /// </exception>
        /// <since_tizen> 5 </since_tizen>
        public void AddMetadata(string index, MediaControlMetadata metadata)
        {
            if (index == null)
            {
                throw new ArgumentNullException(nameof(index));
            }
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            AddItemToPlaylist(index, metadata);
            _metadata.Add(index, metadata);

            MediaControlServer.SavePlaylist(Handle);
        }
예제 #3
0
        /// <summary>
        /// Updates metadata information.
        /// </summary>
        /// <param name="metadata">The metadata to update.</param>
        /// <exception cref="ArgumentNullException"><paramref name="metadata"/> is null.</exception>
        /// <exception cref="InvalidOperationException">
        ///     The server is not running .<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <since_tizen> 4 </since_tizen>
        public static void SetMetadata(MediaControlMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            SetMetadata(MediaControllerNativeAttribute.Title, metadata.Title);
            SetMetadata(MediaControllerNativeAttribute.Artist, metadata.Artist);
            SetMetadata(MediaControllerNativeAttribute.Album, metadata.Album);
            SetMetadata(MediaControllerNativeAttribute.Author, metadata.Author);
            SetMetadata(MediaControllerNativeAttribute.Genre, metadata.Genre);
            SetMetadata(MediaControllerNativeAttribute.Duration, metadata.Duration);
            SetMetadata(MediaControllerNativeAttribute.Date, metadata.Date);
            SetMetadata(MediaControllerNativeAttribute.Copyright, metadata.Copyright);
            SetMetadata(MediaControllerNativeAttribute.Description, metadata.Description);
            SetMetadata(MediaControllerNativeAttribute.TrackNumber, metadata.TrackNumber);
            SetMetadata(MediaControllerNativeAttribute.Picture, metadata.AlbumArtPath);

            Native.UpdateMetadata(Handle).ThrowIfError("Failed to set metadata.");
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataUpdatedEventArgs"/> class.
 /// </summary>
 /// <param name="metadata">The updated <see cref="MediaControlMetadata"/>.</param>
 /// <since_tizen> 4 </since_tizen>
 public MetadataUpdatedEventArgs(MediaControlMetadata metadata)
 {
     Metadata = metadata;
 }