我想使用MPMoviePlayerViewController在我的服务器上播放视频文件.但它不起作用.
我的iOS代码如下:
NSURL *mediaURL = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"http://127.0.0.1:3000/media/%@", @"sample_iTunes.mov"]];
self.player = [[MPMoviePlayerViewController alloc] initWithContentURL: mediaURL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.player.moviePlayer];
self.player.moviePlayer.shouldAutoplay = YES;
self.player.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentMoviePlayerViewControllerAnimated:self.player];
[self.player.moviePlayer prepareToPlay];
[self.player.moviePlayer play];
-(void)movieFinishedCallback:(NSNotification*)aNotification
{
NSLog(@"%@",[aNotification valueForKey:@"userInfo"]);
MPMoviePlayerViewController* theMovie = [aNotification object];
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误信息NSNotification是:
MPMoviePlayerPlaybackDidFinishReasonUserInfoKey = 1;
error = "Error Domain=MediaPlayerErrorDomain Code=-11850 \"Operation Stopped\" UserInfo=0x1d51b640 {NSLocalizedDescription=Operation Stopped}";
Run Code Online (Sandbox Code Playgroud)
然后我将URL更改为
http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov
Run Code Online (Sandbox Code Playgroud)
但它运作良好.由于这两个文件完全相同.我认为我的远程服务器一定有问题.这是我服务器的响应头:
HTTP/1.1 200 OK
Content-Length: 3284257
Date: Mon, 14 Jan 2013 06:06:12 GMT
Last-Modified: Sun, 13 Jan …Run Code Online (Sandbox Code Playgroud) 我想构建一个后端应用程序,将消息从服务器推送到Android设备.我发现有两种协议适合这种情况.我想为他们每个人使用RabbitMQ或mosquitto服务器(如果有其他好的选择请告诉我们我也是:-)).考虑到网络状况不佳,电池使用情况和服务器性能.哪种解决方案适合我?
我也找到了C2DM服务.但是我的情况有两个问题.首先它只支持Android 2.2及更高版本.其次,中国的服务并不总是稳定的.所以我想建立自己的推送服务.
我使用install:install-file将jar安装到我的本地repository.My pom.xml编写如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-paho</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/paho.jar</file>
<groupId>org.eclipse</groupId>
<artifactId>paho</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
你可以发现我将它绑定到阶段'generate-resources'.然后,我使用mvn eclipse:eclipseorder.It工作得很好,jar被复制到我的本地repository.But当我使用order mvn install:install-file我得到错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project xxx:
The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file are missing or invalid -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
使用时的错误消息 mvn compile
[ERROR] Failed to execute goal on project android-engine: Could not resolve dependencies for project com.youku.wireless:android-engine:jar:1.0-SNAPSHOT: Could not find artifact org.eclipse:paho:jar:1.0.0 in spring-milestone (http://maven.springframework.org/milestone) -> …Run Code Online (Sandbox Code Playgroud)