我正在尝试在a里面播放视频UIView,所以我的第一步是为该视图添加一个类,并使用以下代码开始在其中播放电影:
- (IBAction)movie:(id)sender{
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];
}
Run Code Online (Sandbox Code Playgroud)
但是当它在自己的类中使用这个方法时,这只是崩溃应用程序,但在其他地方很好.有谁知道如何在视图中播放视频?并避免全屏?
我正在尝试在我正在开发的应用程序中实现心跳录音功能.
这样做的首选方法是使用iPhone的相机打开灯,让用户将手指放在镜头上,并检测视频输入中与用户心脏相对应的波动.
我发现了一个非常好的起点,这里有以下堆栈溢出问题
该问题提供了绘制心跳时间图的有用代码.
它显示了如何启动AVCaptureSession并打开相机的指示灯,如下所示:
session = [[AVCaptureSession alloc] init];
AVCaptureDevice* camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([camera isTorchModeSupported:AVCaptureTorchModeOn]) {
[camera lockForConfiguration:nil];
camera.torchMode=AVCaptureTorchModeOn;
// camera.exposureMode=AVCaptureExposureModeLocked;
[camera unlockForConfiguration];
}
// Create a AVCaptureInput with the camera device
NSError *error=nil;
AVCaptureInput* cameraInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:&error];
if (cameraInput == nil) {
NSLog(@"Error to create camera capture:%@",error);
}
// Set the output
AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init];
// create a queue to run the capture on
dispatch_queue_t captureQueue=dispatch_queue_create("catpureQueue", NULL);
// setup …Run Code Online (Sandbox Code Playgroud) 我试图在我的应用程序中围绕iphone屏幕拖动UIImageView.
目前我设置的拖动功能很好,拖动图像确实会在屏幕上移动它,麻烦的是你不必拖动图像视图来移动它,你也可以拖动到屏幕上的任何地方它会移动图像.我是这个平台的新手,所以我无法真正思考如何解决这个问题.我当前拖动图片的代码是:
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint pt = [[touches anyObject] locationInView:pig];
startLocation = pt;
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint pt = [[touches anyObject] locationInView:pig];
CGRect frame = [pig frame];
frame.origin.x += pt.x - startLocation.x;
frame.origin.y += pt.y - startLocation.y;
[pig setFrame: frame];
}
Run Code Online (Sandbox Code Playgroud)
任何帮助赞赏.顺便说一下,猪是UIImageView.另外我注意到,如果我将图像视图"pig"的用户交互设置为启用,则图像不再可拖动,但是当它未设置为启用时它是.
我一直在为这个代码愚弄代码,如果有人能提供从服务器http://www.archive.org/download/june_high/june_high_512kb.mp4下载此文件的代码示例,我将非常感激.,(顺便说一下,它实际上不是这个文件,它只是一个试图帮助我的人的完美例子),然后从文档目录中播放它.我知道这对我来说似乎很懒,但我尝试了很多不同的NSURLConnection变种,这让我发疯了.此外,如果我确实设法下载了视频文件,我会认为这个代码会成功播放它是正确的:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"june_high_512kb.mp4"];
NSURL *movieURL = [NSURL fileURLWithPath:path];
self.theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[_theMovie play];
Run Code Online (Sandbox Code Playgroud)
如果上面的代码可以在文档目录中播放视频文件,那么我想我唯一需要知道的是,如何从服务器下载视频文件.这似乎是我的主要问题.任何帮助是极大的赞赏.
我正在为Windows Phone 8的visual studio express编写一个C++应用程序.
我正在尝试使用flite,一个用c编写的文本到语音库,到目前为止我已经添加了它的源文件和头文件,并且我已经设置了在所有单个c文件上使用预编译头文件的选项,但是源文件仍然没有编译,而是编译器抱怨(很多次):
error C2059: syntax error : '.'
error C2059: syntax error : '}'
Run Code Online (Sandbox Code Playgroud)
它在flite源代码中为这段代码抱怨这些问题:
DEF_STATIC_CONST_VAL_STRING(ffeature_default_val,"0");
Run Code Online (Sandbox Code Playgroud)
DEF_STATIC_CONST_VAL_STRING的定义是:
#define DEF_CONST_VAL_STRING(N,S) const cst_val N = {{.a={.type=CST_VAL_TYPE_STRING,.ref_count=-1,.v={.vval= (void *)S}}}}
Run Code Online (Sandbox Code Playgroud)
在这里你可以看到"." 和编译器抱怨的"}".我还没有修改过c源代码,它是为iOS和Android项目构建的,所以我假设我没有掌握如何在visual express中包含C文件.另外,在Visual Express中,.c文件旁边的图标是"++":/
任何帮助是极大的赞赏.
iphone ×3
ios ×2
objective-c ×2
algorithm ×1
c ×1
c++ ×1
camera ×1
cocos2d-x ×1
download ×1
draggable ×1
media-player ×1
touch ×1
uiimageview ×1
xcode ×1