private void setMastheadLoadingPlaceholder(ContentItemEx previous, ContentItemEx next)
        {
            try
            {
                if ((next != null) && (previous != null))
                {
                    if ((previous != null) && (previous.Children != null) && !previous.Children.Contains(next))
                    {
                        return;
                    }

                    if (next.IsRoot)
                    {
                        return;
                    }

                    var configuration = FFImageLoading.ImageService.Instance.Config;
                    if (!configuration.DiskCache.ExistsAsync(configuration.MD5Helper.MD5(next.LargeThumbnailMastheadUrl)).Result&&
                        configuration.DiskCache.ExistsAsync(configuration.MD5Helper.MD5(previous.LargeThumbnailMastheadUrl)).Result)
                    {
                        MastheadLoadingPlaceholder = previous.LargeThumbnailMastheadUrl;
                        return;
                    }
                }

                if (selectedChannel is ChannelEx)
                {
                    MastheadLoadingPlaceholder = (selectedChannel as ChannelEx).MastheadUrl;
                }
            }
            catch (Exception ex)
            {
                LoggerService.Instance.Log("ERROR: setMastheadLoadingPlaceholder: " + ex);
            }
        }
        public override async Task Init()
        {
            await base.Init();

            SelectedChannel = null;
            SelectedFolder  = null;
            SelectedItem    = null;

            if (Root != null)
            {
                Root = null;
            }

            Root = new ContentItemEx()
            {
                ID   = "",
                Name = "Channels",
            };

            SelectedItem = Root;
            if (!Initialized)
            {
                FacebookToolsService.Instance.LogCustomEvent("ChannelsRootLoaded");
            }

            if (!productsViewModel.Initialized)
            {
                await TaskQueue.EnqueueAsync(async() => await productsViewModel.Init());
            }
        }
Example #3
0
        public async Task AddToQueue(ContentItemEx item)
        {
            Mark mark = MarkManager.GetMark();

            if (mark.HasFlag(Mark.Hulu) || mark.HasFlag(Mark.Netflix))
            {
                await Application.Current.MainPage.DisplayAlert("Error", "We're sorry but there is currently an issue with the PlayOn Cloud service. Please try again later.", "OK");

                return;
            }

            if (!SharedSettingsService.Instance.GetBoolValue("IsLegalDisclaimerAccepted"))
            {
                if (await MessagingCenterManager.ShowPopup(new LegalDisclaimer()))
                {
                    SharedSettingsService.Instance.SetBoolValue("IsLegalDisclaimerAccepted", true);
                }
                else
                {
                    return;
                }
            }

            if (await addToQueue(item))
            {
                await Update();
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Queue Error", "There was an error queueing the video for recording.", "OK");
            }

            await accountViewModel.FetchUserCreditsAsync();
        }
 private async void InAppPurchase_OnTransactionFailed(object sender, string localizedDescription)
 {
     lastPurchasedItem = null;
     IsLoading         = false;
     if (!string.IsNullOrEmpty(localizedDescription))
     {
         await Application.Current.MainPage.DisplayAlert("Error", localizedDescription, "OK");
     }
 }
        private async Task performSearch(string searchTerms, bool isDeepLink = false)
        {
            IEnumerable <IContentItem> children = null;

            try
            {
                if (isDeepLink)
                {
                    children = await ContentClient.DeepLink(selectedChannel.ID, searchTerms);
                }
                else
                {
                    children = await ContentClient.Search(selectedChannel.ID, searchTerms);
                }
            }
            catch (SessionExpiredException)
            {
                await getItemChildren(selectedChannel, true);

                if (isDeepLink)
                {
                    children = await ContentClient.DeepLink(selectedChannel.ID, searchTerms);
                }
                else
                {
                    children = await ContentClient.Search(selectedChannel.ID, searchTerms);
                }
            }

            var name = searchTerms;

            if (isDeepLink)
            {
                name = "Videos";
            }

            ContentItemEx searchResults = new ContentItemEx
            {
                Type         = ContentType.Folder,
                ID           = searchTerms,
                Parent       = selectedChannel,
                Name         = name,
                IsFromSearch = !isDeepLink,
                IsDeepLink   = isDeepLink
            };

            if (children != null)
            {
                searchResults.Children = new ObservableCollection <IContentItem>(children);
            }

            selectedItem = searchResults;
            updateBreadcrumbs();
            SelectedFolder = selectedItem;
            OnPropertyChanged("SelectedItem");
        }
        private async Task loadSelectedItemDetailsAsync()
        {
            if (selectedMediaItem == null)
            {
                return;
            }

            try
            {
                IsDetailsLoading = true;
                ContentItemEx details = null;

                if (selectedMediaItem.Expired)
                {
                    await renewItemID(selectedMediaItem);
                }

                try
                {
                    details = await ContentClient.GetDetails(selectedMediaItem.ID);

                    if ((details == null) && await renewItemID(selectedMediaItem))
                    {
                        details = await ContentClient.GetDetails(selectedMediaItem.ID);
                    }
                }
                catch (SessionExpiredException)
                {
                    if (await renewItemID(selectedMediaItem))
                    {
                        markAllExpired();
                        details = await ContentClient.GetDetails(selectedMediaItem.ID);
                    }
                }

                if ((details != null) && (selectedMediaItem is ContentItemEx))
                {
                    (selectedMediaItem as ContentItemEx).UpdateFromDetails(details);
                }
            }
            catch (Exception ex)
            {
                //XXX : Handle error
                LoggerService.Instance.Log("ERROR: MediaContent.loadSelectedItemDetailsAsync: " + ex);
            }
            finally
            {
                IsDetailsLoading = false;
            }
        }
        private async Task purchaseContentItem(IContentItem item)
        {
            if ((item == null) || (inAppPurchase == null) || !(item is ContentItemEx))
            {
                return;
            }

            if ((item as ContentItemEx).InQueue)
            {
                cloudViewModel.SelectedItem = CloudItem.Queue;
                if ((Application.Current.MainPage as NavigationPage).CurrentPage is DetailsPage)
                {
                    await Application.Current.MainPage.Navigation.PopAsync();
                }

                return;
            }

            if (!accountViewModel.SignedIn)
            {
                (Application.Current.BindingContext as PlayOnCloud.ViewModel.Cloud).Register.View = Model.RegisterViewMode.None;
                (Application.Current.BindingContext as PlayOnCloud.ViewModel.Cloud).Register.Type = RegisterViewType.Queue;

                await Application.Current.MainPage.Navigation.PushAsync(new PlayOnCloud.Register()
                {
                    BindingContext = Application.Current.BindingContext, SkipMainPageInitialization = true
                });

                return;
            }

            IsLoading = true;
            try
            {
                await accountViewModel.FetchUserCreditsAsync();

                if (accountViewModel.UserInfo.Credits > 0)
                {
                    await queueViewModel.AddToQueue(item as ContentItemEx);

                    IsLoading = false;
                }
                else if (RecordingProduct != null)
                {
                    if (!CanMakePayments)
                    {
                        IsLoading = false;
                        await Application.Current.MainPage.DisplayAlert("Purchasing Disabled", "In-App Purchases are disabled on this device. If you want to buy this recording, you must first enable In-App Purchases under Settings > General > Restrictions, and then try again.", "OK");

                        return;
                    }

                    lastPurchasedItem = item as ContentItemEx;
                    inAppPurchase.PurchaseProduct(RecordingProduct, lastPurchasedItem);
                }
            }
            catch
            {
                IsLoading = false;
            }
        }
 private async void InAppPurchase_OnRequestFailed(object sender, string localizedDescription)
 {
     lastPurchasedItem = null;
     IsLoading         = false;
     await Application.Current.MainPage.DisplayAlert("Error", localizedDescription, "OK");
 }
Example #9
0
        private async Task <bool> addToQueue(ContentItemEx item)
        {
            try
            {
                registerForNotifications();

                if (mediaContentViewModel != null)
                {
                    mediaContentViewModel.IsDetailsLoading = true;
                }

                var recordToken = await ContentClient.GetRecordToken(item.ID);

                var smallThumbUrl = ContentClient.GetSmallImageUrl(item.ID, 192, 128);
                var smallThumb    = await ImageToolsService.Instance.GetImageFromCache(smallThumbUrl);

                if (smallThumb == null)
                {
                    smallThumb = await ContentClient.GetImageFromUrl(smallThumbUrl);
                }

                var largeThumbUrl = ContentClient.GetLargeImageUrl(item.ID, 720, 480);
                var largeThumb    = await ImageToolsService.Instance.GetImageFromCache(largeThumbUrl);

                if (largeThumb == null)
                {
                    largeThumb = await ContentClient.GetImageFromUrl(largeThumbUrl);
                }

                var isSmallThumbValid = isValidImage(smallThumb);
                var isLargeThumbValid = isValidImage(largeThumb);
                if (!isSmallThumbValid || !isLargeThumbValid)
                {
                    var channelThumbUrl = item.ChannelThumbnailUrl;
                    if (!string.IsNullOrEmpty(channelThumbUrl))
                    {
                        var channelThumb = await ContentClient.GetImageFromUrl(channelThumbUrl);

                        if (!isSmallThumbValid)
                        {
                            smallThumb = channelThumb;
                        }

                        if (!isLargeThumbValid)
                        {
                            largeThumb = channelThumb;
                        }
                    }
                }

                var response = await QueueClient.Add(recordToken, smallThumb, largeThumb);

                if ((response != null) && response.Success)
                {
                    item.InQueue = true;
                    if (mediaContentViewModel.SelectedItem is ContentItemEx)
                    {
                        (mediaContentViewModel.SelectedItem as ContentItemEx).InQueue = true;
                    }

                    FacebookToolsService.Instance.LogCustomEvent("AddToQueue");

                    NewItemsCount++;
                    return(true);
                }

                return(false);
            }
            finally
            {
                if (mediaContentViewModel != null)
                {
                    mediaContentViewModel.IsDetailsLoading = false;
                }
            }
        }