有谁知道是否有可能检测到VideoView何时缓冲?
我想在视频缓冲时显示ProgressDialog.
到目前为止,我尝试使用OnPreparedListener,但这仅在首次加载视频时才有效.如果正在播放视频并且用户将擦洗条移动到不同的点,则视频仍然"准备好",即使它正在缓冲.
我也试过(我知道这很糟糕)AsyncThread只是忙等待isPlaying():
private class BufferTask extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void...voids) {
final VideoView videoView = (VideoView)findViewById(R.id.video);
while (!videoView.isPlaying()) { }
return null;
}
protected void onPostExecute(Void v) {
// Hide the dialog here...
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为只要你调用start(),即使它正在缓冲,VideoView似乎也被认为是在播放.
我能想到的唯一解决方案是构建一个自定义的VideoView类型类,以便我可以访问它的MediaPlayer实例.
有任何想法吗?谢谢阅读.
我正在开发一个应用程序,我想将Last.fm应用程序集成到其中.基本上,当有人在我的应用程序中查看艺术家时,我想要一个按钮,他们可以点击以打开Last.fm应用程序和艺术家的信息.
这个意图有效,但它会加载一个菜单,询问我想使用哪个应用程序(Browser或Last.fm):
Intent i = new Intent();
i.setData(Uri.parse("http://last.fm/music/" + headliner));
i.setAction("android.intent.action.VIEW");
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
但是,我只是想启动Last.fm应用程序并跳过询问使用哪个应用程序的对话框,我想可能使用setPackage()方法会像这样工作:
i.setPackage("fm.last.android");
Run Code Online (Sandbox Code Playgroud)
但它导致应用程序崩溃:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://last.fm/music/Rihanna pkg=fm.last.android }
Run Code Online (Sandbox Code Playgroud)
是否可以启动Last.fm应用程序?这是Last.fm的AndroidManifest.xml的副本供参考.
谢谢你的阅读,托尼
我正在尝试实现内置的iOS 5人脸检测API.我正在使用一个UIImagePickerController允许用户拍照的实例,然后我试图CIDetector用来检测面部特征.不幸的是,featuresInImage总是返回一个大小为0的数组.
这是代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage* picture = [info objectForKey:UIImagePickerControllerOriginalImage];
NSNumber *orientation = [NSNumber numberWithInt:
[picture imageOrientation]];
NSDictionary *imageOptions =
[NSDictionary dictionaryWithObject:orientation
forKey:CIDetectorImageOrientation];
CIImage *ciimage = [CIImage imageWithCGImage:[picture CGImage]
options:imageOptions];
NSDictionary *detectorOptions =
[NSDictionary dictionaryWithObject:CIDetectorAccuracyLow
forKey:CIDetectorAccuracy];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil
options:detectorOptions];
NSArray *features = [detector featuresInImage:ciimage];
NSLog(@"Feature size: %d", features.count);
}
Run Code Online (Sandbox Code Playgroud)
这总是返回0个功能.但是,如果我从应用程序内置的文件中使用UIImage,则人脸检测效果很好.
我正在使用这篇Pragmatic Bookshelf文章中的代码.
对于它的价值,我认为错误是当我将UIImage从相机转换为CIImage时,但它可能是任何东西.
我的Xcode项目中的很多文件都被"卡住"在我的项目之外,我无法删除它们.创建新文件时偶尔会发生这种情况(可能有50%的时间).
这是发生的事情的屏幕截图:

有任何想法吗?
谢谢.
在我的音频播放器的视图控制器中,我添加了这个:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
这会将播放器控件中的图标从iPod图标切换到我自己的应用程序,它还会将小回放图标放在状态栏中.
接下来,我将此添加到我的视图控制器来处理远程事件:
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
NSLog(@"REMOTE EVENT!");
switch (event.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[streamer pause];
break;
case UIEventSubtypeRemoteControlPlay:
[streamer start];
break;
case UIEventSubtypeRemoteControlPause:
[streamer pause];
break;
case UIEventSubtypeRemoteControlStop:
[streamer stop];
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这从未被调用过.我试着在应用程序运行时调出播放控件,我尝试回到主屏幕并点击一些播放控件,然后我尝试了我的耳塞控件.一切都没有运气.
有没有人对我可能出错的地方有任何指示?
谢谢.
android ×3
ios ×2
audio ×1
background ×1
core-image ×1
listview ×1
media-player ×1
orientation ×1
xcode ×1
xcode4 ×1