Аудиозапись пользователя или группы. См. описание .
Inheritance: MediaAttachment
Esempio n. 1
0
File: Audio.cs Progetto: G-IT-ED/vk
        internal static Audio FromJson(VkResponse response)
        {
            var audio = new Audio();

            VkResponse id = response["id"] ?? response["aid"];

            audio.Id = Convert.ToInt64(id.ToString());
            audio.OwnerId = response["owner_id"];
            audio.Artist = response["artist"];
            audio.Title = response["title"];
            audio.Duration = response["duration"];
            audio.Url = response["url"];
            audio.LyricsId = Utilities.GetNullableLongId(response["lyrics_id"]);
            audio.AlbumId = Utilities.GetNullableLongId(response["album_id"]);
            audio.Genre = response["genre_id"] ?? response["genre"];

            return audio;
        }
Esempio n. 2
0
            public AudioInfo Create(long userId,
                int index,
                Audio audio,
                Uri url,
                PlayingStateChangedEventHandler handler = null)
            {
                var info = new AudioInfo(__Storage,
                    __Downloader,
                    audio.Id,
                    userId,
                    audio.Title,
                    audio.Artist,
                    audio.Duration,
                    index,
                    url);

                if (handler != null)
                {
                    info.Playable.PlayingStateChanged += handler;
                }
                return info;
            }
Esempio n. 3
0
File: Audio.cs Progetto: ProESM/vk
		/// <summary>
		/// Разобрать из json.
		/// </summary>
		/// <param name="response">Ответ сервера.</param>
		/// <returns></returns>
		internal static Audio FromJson(VkResponse response)
		{
			var audio = new Audio
			{
				Id = response["id"] ?? response["aid"],
				OwnerId = response["owner_id"],
				Artist = response["artist"],
				Title = response["title"],
				Duration = response["duration"],
				Url = response["url"],
				LyricsId = response["lyrics_id"],
				AlbumId = response["album_id"],
				Genre = response["genre_id"] ?? response["genre"],
				Date = response["date"]
			};
			return audio;
		}
Esempio n. 4
0
        public void Set_UserDisabledTrackNameBroadcast_ThrowAccessDeniedException()
        {
            const string url = "https://api.vk.com/method/status.set?audio=0_0&access_token=token";
            const string json =
                @"{
                    'error': {
                      'error_code': 221,
                      'error_msg': 'User disabled track name broadcast',
                      'request_params': [
                        {
                          'key': 'oauth',
                          'value': '1'
                        },
                        {
                          'key': 'method',
                          'value': 'status.set'
                        },
                        {
                          'key': 'audio',
                          'value': '0_0'
                        },
                        {
                          'key': 'access_token',
                          'value': 'token'
                        }
                      ]
                    }
                  }";

            var status = GetMockedStatusCategory(url, json);
            var audio = new Audio {Id = 0, OwnerId = 0};
            This.Action(() => status.Set("test test test", audio)).Throws<AccessDeniedException>()
                .Message.ShouldEqual("User disabled track name broadcast");
        }
Esempio n. 5
0
        public void Set_Audio_ReturnTrue()
        {
            const string url = "https://api.vk.com/method/status.set?audio=4793858_158073513&access_token=token";
            const string json =
                @"{
                    'response': 1
                  }";

            var status = GetMockedStatusCategory(url, json);

            var audio = new Audio { Id = 158073513, OwnerId = 4793858 };
            var result = status.Set("test test test", audio);

            Assert.That(result, Is.True);
        }
Esempio n. 6
0
        public void Set_UserDisabledTrackNameBroadcast_ThrowAccessDeniedException()
        {
            const string url = "https://api.vk.com/method/status.set?audio=0_0&v=" + VkApi.VkApiVersion + "&access_token=token";
            const string json =
                @"{
                    'error': {
                      'error_code': 221,
                      'error_msg': 'User disabled track name broadcast',
                      'request_params': [
                        {
                          'key': 'oauth',
                          'value': '1'
                        },
                        {
                          'key': 'method',
                          'value': 'status.set'
                        },
                        {
                          'key': 'audio',
                          'value': '0_0'
                        },
                        {
                          'key': 'access_token',
                          'value': 'token'
                        }
                      ]
                    }
                  }";

            var status = GetMockedStatusCategory(url, json);
            var audio = new Audio {Id = 0, OwnerId = 0};
            var ex = Assert.Throws<AccessDeniedException>(() => status.Set(audio));
            Assert.That(ex.Message, Is.EqualTo("User disabled track name broadcast"));
        }