小编efp*_*ies的帖子

在Android MediaPlayer中暂停和搜索

我有一个SeekBar和一个MediaPlayer.我想在它暂停时寻求,但似乎文档对我来说是谎言:

请注意,seekTo(int)也可以在其他状态中调用,例如Prepared,Paused和PlaybackCompleted状态.

像往常一样,在Android上我必须编写变通办法而不是代码(MediaPlayer此时我处于哪种状态我无法知道,所以这个表和状态机完全没用).因为而不是onSeekComplete onCompletion(超过9000次,我不是在开玩笑)方法被调用!onSeekComplete只有在seekToonPrepared(WHY,GOD,WHY ???)调用之后才会调用它.我甚至不知道该怎么做.我花了大约5个小时,没有修复.我能做什么?

UPD

这是我的代码.

private void setupMediaPlayer() {
    savedMediaPlayerState = null;

    mediaPlayer = application.getMediaPlayer();

    String mp3Path = "/path/to/mp3";

    mediaPlayer.setOnCompletionListener(this);
    mediaPlayer.setOnSeekCompleteListener(this);
    mediaPlayer.setOnErrorListener(this);

    mediaPlayer.setDataSource(mp3Path);
    mediaPlayer.prepare();
}

@Override
public void onProgressChanged(android.widget.SeekBar sb, int i, boolean b) {
    Log.i(TAG, String.format("Progress changed! %d", i));
    if (b) {
        mediaPlayer.seekTo(i);
        updateProgressBarAndDurationLabels(i, mediaPlayer.getDuration(), false);
    }
}

@Override
public void onStartTrackingTouch(android.widget.SeekBar sb) {
    handler.removeCallbacks(updateTimeTask);
    mediaPlayer.pause();
}

@Override
public void onStopTrackingTouch(android.widget.SeekBar sb) { …
Run Code Online (Sandbox Code Playgroud)

android android-mediaplayer

5
推荐指数
1
解决办法
4105
查看次数

具有自动故障转移功能的AWS ElastiCache Redis Multi-AZ是否有助于最大限度地减少定期维护的停机时间?

我们计划在AWS ElastiCache中使用Redis(已禁用集群模式).

具有自动故障转移功能的多可用区有助于在主节点出现故障时保持最短的停机时间.

但是,没有关于定期维护的说法.我知道不同的可用区域位于区域的不同位置,但是在维护时会进行故障转移工作吗?所有节点是同时还是一个接一个地自动故障转移?数据会保持不变吗?

文档不包括这些问题.他们只是说我应该选择一个维护间隔,他们没有说我的数据会发生什么.

amazon-ec2 amazon-web-services redis amazon-elasticache

5
推荐指数
1
解决办法
919
查看次数

layout.xml中的自定义RelativeLayouts

我有一个自定义RelativeLayout remote_image_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content">
    <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/placeholder"
        />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

好的,现在我想把它包含在main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical" android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <Button android:text="Start Download" android:id="@+id/button1"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:onClick="onClick" />
    <Button android:text="View Downloads" android:id="@+id/button2"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:onClick="showDownload" />
    <ScrollView
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        >
        <LinearLayout
                android:id="@+id/lay"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:orientation="vertical"
                >
            <include layout="@layout/remote_image_view" android:id="@+id/imageView1" />
            <include layout="@layout/remote_image_view" android:id="@+id/imageView2"/>
            <include layout="@layout/remote_image_view" android:id="@+id/imageView3"/>
            <include layout="@layout/remote_image_view" android:id="@+id/imageView4"/>
            <include layout="@layout/remote_image_view" android:id="@+id/imageView5"/>
            <include layout="@layout/remote_image_view" android:id="@+id/imageView6"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

非常好.所以我创建了一个类RemoteImage:

public …
Run Code Online (Sandbox Code Playgroud)

android relativelayout

1
推荐指数
1
解决办法
4192
查看次数

应用程序使用的内存大小非常快

写了一个简单的程序来填充我的驱动器上的所有空间.它有一个非常简单的逻辑:

  • 10创建一个文件
  • 20写N(在我的情况下为40)随机块大小为M(在我的情况下为100 MiB)
  • 30关闭文件
  • 40 GOTO 10

好吧,我刚从头创建了一个新的Cocoa项目,并将代码放入了applicationDidFinishLaunching.就这个.

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    fm = [NSFileManager new];

    unsigned long long size = 0;
    unsigned long long sizeMax = 0;

    NSString *path;
    NSData *data;
    NSFileHandle *myHandle;
    for (long i = 0; ; ++i) {
        if (i % 40L == 0) { // N = 40
            sizeMax = [self currentMaxSize];
            size = 0;

            path = [NSString stringWithFormat:@"/Users/user/Desktop/loltest/lol_%f.txt", [NSDate timeIntervalSinceReferenceDate]];

            [fm createFileAtPath:path contents:[NSData data] attributes:nil];
            [myHandle closeFile];
            myHandle = [NSFileHandle fileHandleForWritingAtPath:path]; …
Run Code Online (Sandbox Code Playgroud)

macos objective-c

0
推荐指数
1
解决办法
86
查看次数