Exemple #1
0
        public async Task <List <VideoViewModel> > Search(string searchText)
        {
            HttpWebRequest request = WebRequest.Create("https://api.dailymotion.com/videos?fields=id,title,description&search=" + searchText) as HttpWebRequest;

            using (HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());

                string stringJson = reader.ReadToEnd();
                List <VideoViewModel> videoViewModels = new List <VideoViewModel>();

                dynamic dynamicJson = JObject.Parse(stringJson);
                dynamic videos      = dynamicJson["list"];
                foreach (dynamic video in videos)
                {
                    VideoViewModel videoViewModel = new VideoViewModel();
                    dynamic        title          = video["title"];
                    videoViewModel.Title = title.Value;
                    dynamic id = video["id"];
                    videoViewModel.VideoID = id.Value;
                    videoViewModel.Host    = Host.DailyMotion;
                    videoViewModels.Add(videoViewModel);
                }

                return(videoViewModels);
            }
        }
Exemple #2
0
        public async Task <List <VideoViewModel> > Search(string searchText)
        {
            var youtubeService = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey          = "REPLACE_ME_WITH_YOUR_YOUTUBE_KEY",
                ApplicationName = this.GetType().ToString()
            });

            var searchListRequest = youtubeService.Search.List("snippet");

            searchListRequest.Q          = searchText;
            searchListRequest.MaxResults = 10;

            var searchListResponse = await searchListRequest.ExecuteAsync();

            List <VideoViewModel> videoViewModels = new List <VideoViewModel>();

            foreach (var searchResult in searchListResponse.Items)
            {
                VideoViewModel videoViewModel = new VideoViewModel();
                videoViewModel.Host        = Host.YouTube;
                videoViewModel.Title       = searchResult.Snippet.Title;
                videoViewModel.Description = searchResult.Snippet.Description;
                videoViewModel.VideoID     = searchResult.Id.VideoId;
                videoViewModels.Add(videoViewModel);
            }

            return(videoViewModels);
        }
Exemple #3
0
        public async Task <List <VideoViewModel> > Search(string searchText)
        {
            string         accessToken = "REPLACE_ME_WITH_YOUR_VIMEO_ACCESS_TOKEN";
            HttpWebRequest request     = WebRequest.Create("https://api.vimeo.com/videos?access_token=" + accessToken + "&query=" + searchText) as HttpWebRequest;

            using (HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());

                string stringJson = reader.ReadToEnd();
                List <VideoViewModel> videoViewModels = new List <VideoViewModel>();

                dynamic dynamicJson = JObject.Parse(stringJson);
                dynamic videos      = dynamicJson["data"];
                foreach (dynamic video in videos)
                {
                    VideoViewModel videoViewModel = new VideoViewModel();
                    dynamic        title          = video["name"];
                    videoViewModel.Title = title.Value;
                    dynamic uri     = video["uri"];
                    string  videoID = uri.ToString().Replace("/videos/", "");
                    videoViewModel.VideoID = videoID;
                    videoViewModel.Host    = Host.Vimeo;
                    videoViewModels.Add(videoViewModel);
                }

                return(videoViewModels);
            }
        }
Exemple #4
0
        public void OnItemTapped(object sender, EventArgs e)
        {
            ItemTappedEventArgs itemTappedEventArgs = e as ItemTappedEventArgs;
            VideoViewModel      videoViewModel      = itemTappedEventArgs.Item as VideoViewModel;
            WebPlayerPage       playerPage          = new WebPlayerPage(videoViewModel);

            Navigation.PushAsync(playerPage);
        }
Exemple #5
0
        public Uri GetEmbedUri(VideoViewModel videoViewModel, bool autoPlay = true)
        {
            string uriString = "http://www.youtube.com/embed/" + videoViewModel.VideoID;

            uriString += "?&rel=0&autoplay=" + ((autoPlay) ? "1" : "0");
            Uri uri = new Uri(uriString);

            return(uri);
        }
Exemple #6
0
        public Uri GetEmbedUri(VideoViewModel videoViewModel, bool autoPlay = true)
        {
            string uriString = "http://www.dailymotion.com/embed/video/" + videoViewModel.VideoID;

            uriString += "&autoPlay=" + ((autoPlay) ? "1" : "0");
            Uri uri = new Uri(uriString);

            return(uri);
        }
Exemple #7
0
        internal Uri GetEmbedUri(VideoViewModel videoViewModel, bool autoPlay = true)
        {
            string uriString = "http://player.vimeo.com/video/" + videoViewModel.VideoID;

            uriString += "?autoplay=" + ((autoPlay) ? "1" : "0");
            Uri uri = new Uri(uriString);

            return(uri);
        }
Exemple #8
0
 public WebPlayerPage(VideoViewModel videoViewModel)
 {
     InitializeComponent();
     _videoViewModel     = videoViewModel;
     this.webView.Source = videoViewModel.GetEmbedUri().ToString();
 }