Pregunta

Estoy tratando de descargar un vídeo/audio en el iphone y el almacén en el iPhone sistema de paquete, y reproducir el archivo de vídeo/audio de paquete.

He descargado correctamente el archivo de vídeo/audio utilizando NSURLConnection.y tengo la tienda como "de la muestra.mov"

pero yo no era capaz de reproducir el vídeo de paquete.es porque el archivo no se ha registrado en el paquete?!

Aquí está el código:

escribir en el archivo, cuando termine de descargar

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"sample.mov"];

    [VideoData writeToFile:path atomically:YES];
}

entonces me reproducir el vídeo de paquete

MoviePlayerAppDelegate *appDelegate = (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];

    // play the movie
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"a" ofType:@"mov"];
    NSURL *movURL = [NSURL fileURLWithPath:moviePath];

    [appDelegate initAndPlayMovie:movURL];


-(void)initAndPlayMovie:(NSURL *)movieURL
{
    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    if (mp)
    {
        // save the movie player object
        self.moviePlayer = mp;
        [mp release];

        // Apply the user specified settings to the movie player object
        [self setMoviePlayerUserSettings];

        // Play the movie!
        [self.moviePlayer play];
    }
}
¿Fue útil?

Solución

A mi conocimiento no se puede guardar correctamente los archivos de recursos carpeta de paquete.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top