我正在为uni项目创建一个应用程序,它要求我从服务器播放视频。 我决定使用Dropbox。但它不会播放文件,有什么办法让我这样做吗?或者我是否需要从其他地方获取视频。
我尝试过另一个完美无缺的链接。 (但不是Dropbox)
http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v
我的编码
AnimeWatchViewController.m
//
// AnimeWatchViewController.m
// VideoPlayer
//
// Created by Alex Lee on 27/04/2014.
// Copyright (c) 2014 Alex Lee. All rights reserved.
//
#import "AnimeWatchViewController.h"
@interface AnimeWatchViewController ()
@end
@implementation AnimeWatchViewController
@synthesize moviePlayer;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(IBAction)playMovie{
NSURL * url =[[NSURL alloc] initWithString:@"https://www.dropbox.com/s/t05zdw2woogo4kh/ACW_3.mp4"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[moviePlayer.view setFrame:CGRectMake(20, 100, 275, 150)];
[self.view addSubview:moviePlayer.view];
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
moviePlayer.shouldAutoplay = YES;
moviePlayer.controlStyle = MPMovieControlModeDefault;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
AnimeWatchViewController.h
//
// AnimeWatchViewController.h
// VideoPlayer
//
// Created by Alex Lee on 27/04/2014.
// Copyright (c) 2014 Alex Lee. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface AnimeWatchViewController : UIViewController
@property(nonatomic,strong) MPMoviePlayerController * moviePlayer;
-(IBAction)playMovie;
@end
答案 0 :(得分:4)
您正在使用网址https://www.dropbox.com/s/t05zdw2woogo4kh/ACW_3.mp4,但这不是指向视频的链接...它是指向包含视频的网页的链接。
要将其转换为视频的直接链接,请将www.dropbox.com
更改为dl.dropboxuser.com
,如下所示:https://dl.dropboxusercontent.com/s/t05zdw2woogo4kh/ACW_3.mp4
答案 1 :(得分:0)
为此您必须先获得直接下载链接,然后才能直接从Dropbox服务器播放视频