Ejemplo n.º 1
0
        /// <summary>
        /// Convert a PlaybackQuality value from the typed value to string.
        /// </summary>
        /// <returns>A string value to be used in the JavaScript bridge.</returns>
        /// <param name="quality">PlaybackQuality Parameter.</param>
        private string GetStringFromPlaybackQuality(PlaybackQuality quality)
        {
            switch (quality)
            {
            case PlaybackQuality.Small:
                return(SmallQuality);

            case PlaybackQuality.Medium:
                return(MediumQuality);

            case PlaybackQuality.Large:
                return(LargeQuality);

            case PlaybackQuality.HD720:
                return(HD720Quality);

            case PlaybackQuality.HD1080:
                return(HD1080Quality);

            case PlaybackQuality.HighRes:
                return(HighResQuality);

            default:
                return(UnknownQuality);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Load Playlist helper method
 /// </summary>
 /// <param name="cueString">Cue string.</param>
 /// <param name="index">Index.</param>
 /// <param name="startSeconds">Start seconds.</param>
 /// <param name="suggestedQuality">Suggested quality.</param>
 private void LoadPlaylistFromCueStr(string cueString, int index, double startSeconds, PlaybackQuality suggestedQuality)
 {
     EvaluateJavascript(string.Format("player.loadPlaylist({0}, {1}, {2},'{3}');", cueString, index, startSeconds,
                                      GetStringFromPlaybackQuality(suggestedQuality)));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the playlist with specified Video Ids.
        /// </summary>
        /// <param name="videoIds">Video identifiers.</param>
        /// <param name="index">Index.</param>
        /// <param name="startSeconds">Start seconds.</param>
        /// <param name="suggestedQuality">Suggested quality.</param>
        public void LoadPlaylist(List <string> videoIds, int index, double startSeconds, PlaybackQuality suggestedQuality)
        {
            //TODO: Test YouTubeAPI Expectation
            var videoIdJsonArray = JsonConvert.SerializeObject(videoIds);

            this.LoadPlaylistFromCueStr(videoIdJsonArray, index, startSeconds, suggestedQuality);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the playback quality.
        /// </summary>
        /// <param name="suggestedQuality">Suggested quality.</param>
        public void SetPlaybackQuality(PlaybackQuality suggestedQuality)
        {
            var playBackQltyString = GetStringFromPlaybackQuality(suggestedQuality);

            EvaluateJavascript(string.Format("player.setPlaybackQuality('{0}');", playBackQltyString));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Loads the playlist with specified Playlist Id
 /// </summary>
 /// <param name="playlistId">Playlist identifier.</param>
 /// <param name="index">Index.</param>
 /// <param name="startSeconds">Start seconds.</param>
 /// <param name="suggestedQuality">Suggested quality.</param>
 public void LoadPlaylist(string playlistId, int index, double startSeconds, PlaybackQuality suggestedQuality)
 {
     this.LoadPlaylistFromCueStr(string.Format("'{0}'", playlistId), index, startSeconds, suggestedQuality);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads video by URL.
        /// </summary>
        /// <param name="videoUrl">Video URL.</param>
        /// <param name="startSeconds">Start seconds.</param>
        /// <param name="endSeconds">End seconds.</param>
        /// <param name="suggestedQuality">Suggested quality.</param>
        public void LoadVideoByUrl(string videoUrl, double startSeconds, double endSeconds, PlaybackQuality suggestedQuality)
        {
            var command = string.Format("'{0}', {1}, {2}, '{3}'",
                                        videoUrl, startSeconds, endSeconds, GetStringFromPlaybackQuality(suggestedQuality));

            EvaluateJavascript(string.Format("player.loadVideoByUrl({0});", command));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Loads video by URL.
 /// </summary>
 /// <param name="videoUrl">Video URL.</param>
 /// <param name="startSeconds">Start seconds.</param>
 /// <param name="suggestedQuality">Suggested quality.</param>
 public void LoadVideoByUrl(string videoUrl, double startSeconds, PlaybackQuality suggestedQuality)
 {
     EvaluateJavascript(string.Format("player.loadVideoByUrl('{0}', {1}, '{2}');", videoUrl, startSeconds,
                                      GetStringFromPlaybackQuality(suggestedQuality)));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Loads the video.
        /// </summary>
        /// <param name="videoId">Video identifier.</param>
        /// <param name="startSeconds">Start seconds.</param>
        /// <param name="endSeconds">End seconds.</param>
        /// <param name="suggestedQuality">Suggested quality.</param>
        public void LoadVideoById(string videoId, double startSeconds, double endSeconds, PlaybackQuality suggestedQuality)
        {
            var command = string.Format("{{'videoId': '{0}', 'startSeconds': {1}, 'endSeconds': {2}, 'suggestedQuality': '{3}'}}",
                                        videoId, startSeconds, endSeconds, GetStringFromPlaybackQuality(suggestedQuality));

            EvaluateJavascript(string.Format("player.loadVideoById({0});", command));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Cues the specified video in the player.
 /// </summary>
 /// <param name="videoId">Video identifier.</param>
 /// <param name="startSeconds">Start seconds.</param>
 /// <param name="suggestedQuality">Suggested quality.</param>
 public void CueVideoById(string videoId, double startSeconds, PlaybackQuality suggestedQuality)
 {
     EvaluateJavascript(string.Format("player.cueVideoById('{0}', {1}, '{2}');", videoId, startSeconds,
                                      GetStringFromPlaybackQuality(suggestedQuality)));
 }