Exemplo n.º 1
0
            // Customize the appearance of table view cells.
            public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
            {
                string cellIdentifier = "QueueCell";
                var    cell           = tableView.DequeueReusableCell(cellIdentifier);

                if (cell == null)
                {
                    cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier);
                }



                LocalProgramHelper localProgram = new LocalProgramHelper(downloads[indexPath.Row]);

                cell.TextLabel.Text = localProgram.Program.Name;


                cell.DetailTextLabel.Text = localProgram.Program.Description;
                cell.DetailTextLabel.Font = UIFont.SystemFontOfSize(IplayerConst.DetailTextLabelSize);


                cell.ImageView.Image = localProgram.ThumbnailImageForTableView;
                cell.Accessory       = UITableViewCellAccessory.None;


                return(cell);
            }
            // Customize the appearance of table view cells.
            public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
            {
                string          cellIdentifier = "DownloadCell";
                UITableViewCell cell           = tableView.DequeueReusableCell(cellIdentifier);

                if (cell == null)
                {
                    cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier);
                }



                LocalProgramHelper localHelper = new LocalProgramHelper(downloads[indexPath.Row]);



                cell.TextLabel.Text       = localHelper.Program.Name;
                cell.DetailTextLabel.Text =

                    cell.TextLabel.Text = localHelper.Program.Name;
                cell.TextLabel.Font     = UIFont.BoldSystemFontOfSize(IplayerConst.TextLabelSize);

                cell.DetailTextLabel.Text          = string.Format("Expires: {0}", localHelper.Program.Expires.ToShortDateString());
                cell.DetailTextLabel.Font          = UIFont.SystemFontOfSize(IplayerConst.DetailTextLabelSize);
                cell.DetailTextLabel.TextAlignment = UITextAlignment.Right;

                if (DateTime.Now.AddDays(2) > localHelper.Program.Expires)
                {
                    cell.DetailTextLabel.TextColor = UIColor.Red;
                }
                else
                {
                    cell.DetailTextLabel.TextColor = UIColor.LightGray;
                }



                cell.ImageView.Image = localHelper.ThumbnailImageForTableView;
                cell.Accessory       = UITableViewCellAccessory.DisclosureIndicator;
                return(cell);
            }
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //Show an edit button

            //NavigationItem.RightBarButtonItem = EditButtonItem;

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            SelectedProgram.PopulateExtendedFields();



            this.Title              = SelectedProgram.Program.Name;
            this.TitleLabel.Text    = SelectedProgram.Program.Name;
            this.SubtitleLabel.Text = SelectedProgram.Program.Description;
            SubtitleLabel.Font      = UIFont.SystemFontOfSize(UIFont.SmallSystemFontSize);
            this.ImageView.Image    = SelectedProgram.GetFullsizeImage(ImageView.Bounds);

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

            if (SelectedProgram.DownloadedFileExists)
            {
                this.DownloadButton.SetTitle("Play", UIControlState.Normal);
            }

            this.WatchButton.TouchUpInside += delegate {
                // This is for when the user wants to stream the video
                string url = SelectedProgram.StreamingUrl;
                if (string.IsNullOrEmpty(url))
                {
                    using (UIAlertView alertView = new UIAlertView("Sorry.", "Sorry, this program is not available for streaming.", null, "OK"))
                    {
                        alertView.Show();
                        this.WatchButton.SetTitle("Not available", UIControlState.Normal);
                    }
                }
                else
                {
                    moviePlayer = new MPMoviePlayerViewController(new NSUrl(SelectedProgram.StreamingUrl));
                    PresentMoviePlayerViewController(moviePlayer);
                }
            };

            this.DownloadButton.TouchUpInside += delegate {
                if (SelectedProgram.DownloadedFileExists)
                {
                    // if we have the file, we can play it! yay!
                    Console.WriteLine("playing");
                    moviePlayer = new MPMoviePlayerViewController(new NSUrl(SelectedProgram.OutputFilename, false));
                    PresentMoviePlayerViewController(moviePlayer);
                }
                else
                {
                    //If you happen to be out of the UK, but want to see how the queueing works, you may want to remove this
                    // bit, as it checks if you can download and will not queue if it can't.
                    // you still can't download, obviously, but atleast you can see the workflow.

                    if (SelectedProgram.PrepareForQueue())
                    {
                        LocalProgram localQueueProgram = LocalProgramHelper.LocalProgramFromRemoteProgram(SelectedProgram.Program);

                        localQueueProgram.State = "Q";
                        AppDelegate.SessionDatabase.AddLocalProgram(localQueueProgram);

                        this.DownloadButton.SetTitle("Queued", UIControlState.Normal);
                    }
                    else
                    {
                        // could be that you are outside of the UK, on 3G, or just that the show isn't ready yet.
                        using (UIAlertView alertView = new UIAlertView("Sorry.", "Sorry, this program is not available for download.", null, "OK"))
                        {
                            alertView.Show();
                            this.DownloadButton.SetTitle("Not available", UIControlState.Normal);
                        }
                    }
                    this.DownloadButton.Enabled = false;
                }
            };
        }