0

Hi could anyone help me , im trying to populate my *URL with the contents of the picker view so i can use selected pickerview row to link to play the selected video . i.e.: if pickerview is showing "vid 1" then pressing the UIRecbutton labelled "play vid" would play vid 1, ect.. any help greatly appreciated , anyone who helps automatically goes on my mental "who gets some money if i win the lottery" list lol. cheers franco

PS: i have all code set up apart from how to get picker view info from the pickerview to vid player. the default is:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Video1" ofType:@"MOV"]];

just to give a path name, if the row in pickerview reads Video1, video2 ect.. how to i get this info to the pathforresource & have it default to movie type, i.e.: mov, mpeg4 .

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164

1 Answers1

0

I think you're looking for selectedRowInComponent. It will return which row is currently selected in your picker. Then run an if block on the return value, and set up your url filename and path from that (actually, a switch would prob be better for lots of items in your picker). Assuming you only have 1 segment in your UIPickerView (as in only 1 wheel to spin, whereas a date picker would have 3 segments, one for month, one for day, one for year), what you want might look something like:

- (IBAction)buttonClicked:(id)sender
{
    NSString *fileName;
    NSString *fileType;
    switch ([myPicker selectedRowInComponent:0])
    {
        case 0:
            fileName = @"Video1";
            fileType = @"mov";
            break;
        case 1:
            fileName = @"Video2";
            fileType = @"mpeg4";
            break;
        //more cases here depending on how many items are in your UIPickerView

        default:
            break;

    }
    NSURL *myURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:fileName ofType:fileType]];

    //put in your code to play the video in myURL here
}
GeneralMike
  • 2,951
  • 3
  • 28
  • 56