我有一个包含三个按钮的应用程序,播放,暂停和停止.viewDidLoad我在做以下事情:
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:songName ofType:@"mp3"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
[playBtn addTarget:self action:@selector(playSong) forControlEvents:UIControlEventTouchUpInside];
[pauseBtn addTarget:self action:@selector(pauseSong) forControlEvents:UIControlEventTouchUpInside];
[stopBtn addTarget:self action:@selector(stopSong) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)
playSong功能是:
-(void) playSong
{
[player play];
}
Run Code Online (Sandbox Code Playgroud)
如果按下播放按钮,则在文件加载时按住约3秒钟,然后开始播放音乐.当我按下播放按钮时,有没有办法让背景音乐立即播放?
我想使用泛型制作通用堆栈.
public class UniversalStack<E> implements StackInterface<E> {
private E[] stack;
private int dim;
private int index;
@SuppressWarnings("unused")
public UniversalStack(int dim)
{
this.dim=dim;
this.index=0;
@SuppressWarnings("unchecked")
E[] stack = (E[]) new Object[dim];
}
@Override
public void push(E el) {
// TODO Auto-generated method stub
if(index+1<dim)
{
stack[index] = el;
index=index+1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
一切都成功编译.当我调用以下内容时会出现问题:
UniversalStack<Integer> integerStack = new UniversalStack<>(10);
integerStack.push(new Integer(1));
Run Code Online (Sandbox Code Playgroud)
我明白了
Exception in thread "main" java.lang.NullPointerException
at com.java.lab4.UniversalStack.push(UniversalStack.java:41)
at com.java.lab4.testStack.main(testStack.java:14)
Run Code Online (Sandbox Code Playgroud)
你能解释一下我做错了什么吗?如果我犯了一个愚蠢的错误,不要对我很苛刻,我是初学者,所以我真的不太懂.
我有一个browser_action扩展,用户可以按下start并stop为了捕捉到一些音频输入.记录文件后,我想将其url转储到控制台中.问题是我无法访问麦克风.这是我到目前为止所尝试的:
navigator.webkitGetUserMedia- 不起作用,navigator.webkitGetUserMedia({ audio: true },...);使用MediaDeviceFailedDueToShutdown调用错误回调.我试着调查那个错误,但我发现没有什么有用的.这个错误无处可寻.
你能指导我走正确的道路吗?谢谢.
我想在注释视图中添加一个按钮并为其指定一个动作.我有点想通了,只有我的代码有一个小问题.
// so when I touch the pin , and the annotation view is displayed , I create a button and add it to the view
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
view.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
// when the button is pressed , go to another view
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
ArticleViewController *det = [[ArticleViewController alloc]init];
det.leTitle = view.annotation.title;
det.link = @"http://en.wikipedia.org/wiki/San_Francisco";
[self.navigationController pushViewController:det animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
现在,问题是我第一次触摸注释并创建了按钮
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control …Run Code Online (Sandbox Code Playgroud) 我想生成一个符合以下格式的随机密码:
我想了想,唯一能想到的就是一些很长很丑的函数。你们能给我提供一种更简单、更有效的方法吗?
PS:我不是在客户端使用这个函数,而是在服务器端,在我的 Node.js Web 应用程序上。
ios ×2
javascript ×2
audio ×1
generics ×1
java ×1
mkannotation ×1
node.js ×1
passwords ×1
random ×1