use*_*357 0 video objective-c dropbox mpmovieplayercontroller ios
嗨,我正在为一个需要我从服务器播放视频的 uni 项目创建一个应用程序。我决定使用 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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
您正在使用 URL https://www.dropbox.com/s/t05zdw2woogo4kh/ACW_3.mp4,但这不是视频链接......它是带有视频的页面的链接。
要将其转换为视频的直接链接,请更改www.dropbox.com为dl.dropboxuser.com,如下所示:https : //dl.dropboxusercontent.com/s/t05zdw2woogo4kh/ACW_3.mp4
| 归档时间: |
|
| 查看次数: |
1415 次 |
| 最近记录: |