标签: prepare

MediaPlayer.setDataSource()和prepare()无法正常工作 - android

我在使用MediaPlayer对象时遇到了麻烦,并没有取得多大成功.如果我将一个声音资源添加到我的原始文件夹并使用R中的int值调用它,它可以正常工作.但是我希望能够从网址中删除内容.

根据我读过的所有文档,setDataSource()应该接受带有文件url的字符串参数.

我在prepare()语句中不断收到IO异常.我甚至试过在本地复制文件,但仍然没有骰子.

有人有主意吗?

MediaPlayer mp = new MediaPlayer();
try {
        mp.setDataSource("http://www.urltofile.com/file.mp3");
        mp.prepare();
        mp.start();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

android media-player prepare

15
推荐指数
2
解决办法
4万
查看次数

AndroId MediaPlayer prepareAsync方法

我有一个奇怪的问题.我使用了prepareAsync方法MediaPlayer,但我声明的监听器永远不会被触发.我尝试.mp3从互联网(电台)流式传输实时信息.我为侦听器使用内联方法,但我也尝试实现接口而没有任何成功.这是我的代码的一部分:

在会员部分:

String url = "http://<my_url>.mp3";
MediaPlayer mediaPlayer = new MediaPlayer();
Run Code Online (Sandbox Code Playgroud)

在活动中onCreate():

ToggleButton playButton = (ToggleButton) findViewById(R.id.playToggleButton);
playButton.setOnClickListener(this);
playButton.clearFocus();
playButton.setClickable(false);

mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
    public void onPrepared(MediaPlayer mp) {
        ToggleButton playButton = (ToggleButton) findViewById(R.id.playToggleButton);
        playButton.setClickable(true);
        mp.start();
    }
});

preparePlayer();
Run Code Online (Sandbox Code Playgroud)

然后,这是preparePlayer()方法:

private void preparePlayer() {
    if (mediaPlayer == null) {
        mediaPlayer = new MediaPlayer();
    }
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    try {
        mediaPlayer.setDataSource(url);
        mediaPlayer.prepareAsync();

    } catch (IllegalArgumentException e) {
        Toast.makeText(
                MyStreamActivity.this,
                getResources().getString(R.string.erreurIllegalArgument),
                Toast.LENGTH_LONG).show();
        e.printStackTrace();
    } catch (IllegalStateException e) …
Run Code Online (Sandbox Code Playgroud)

android asynchronous prepare android-mediaplayer

11
推荐指数
1
解决办法
2万
查看次数

Android从内部存储播放资源文件会导致MediaPlayer.prepare提供IOException

我的应用程序从为我的应用程序指定的内部目录(/ data/data/com ...)播放音频资源文件.它似乎将文件下载到该位置没关系,setDataSource(String path)不会抛出任何异常,但MediaPlayer.prepare()会抛出IOException.相同的代码在SD卡上运行.为什么会这样?

编辑:

我们假设这是代码; 它比我的代码更简单,并抛出相同的异常:

package com.app.MediaPlayerTest;

public class MediaTest extends Activity {
    MediaPlayer mp;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        DownloadFiles();
        MusicPlay();
    }

    public void DownloadFiles() {
        //Downloads Files
    }

    public void MusicPlay()
    {
            try {
                mp.setDataSource("/data/data/com.app.pronounce/winds.mp3");
            } catch (IllegalArgumentException e1) {
                e1.printStackTrace();
            } catch (IllegalStateException e1) {
                e1.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        try {
            mp.prepare();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        mp.setLooping(true);
        mp.start();
    } …
Run Code Online (Sandbox Code Playgroud)

resources android ioexception media-player prepare

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

可以Maven发布:以批处理模式准备更新快照版本到发布版本

mvn发布:准备

它经常要求我解决快照依赖关系.有没有办法在批处理模式下执行此操作,以便maven自动使用关联的版本.即如果一个依赖是1.0.0-SNAPSHOT它会自动更新这个依赖到1.0.0版本?

[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.: Do you want to resolve them now?     (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Resolve Project Dependency Snapshots.: 'com.my.project' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.2-SNAPSHOT) 0.0.2-SNAPSHOT: : 0.0.2-SNAPSHOT
Run Code Online (Sandbox Code Playgroud)

release version maven prepare

10
推荐指数
2
解决办法
9884
查看次数

Android MediaPlayer准备失败:status = 0x1

我正在构建一个需要播放录制声音的录音机.我在播放音频时遇到了很多麻烦.我知道该文件存在是因为我将其隔离到SD卡上的文件夹中,但由于某种原因它无法播放.

这是我的代码:

public class RecorderEditActivity extends SherlockActivity implements
    DatabaseHelper.MetadataListener {

private long position;

private Button playButton = null;
private TextView date = null;
private EditText title = null;
private EditText notes = null;
private Button saveButton = null;

private MediaPlayer mediaPlayer = null;
private boolean isPlaying = false;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.edit_item);

    position = getIntent().getExtras().getLong(DatabaseHelper.KEY_ROWID);

    playButton = (Button) findViewById(R.id.play);
    date = (TextView) findViewById(R.id.recording_date);
    title = (EditText) findViewById(R.id.edit_title);
    notes = (EditText) findViewById(R.id.edit_notes);
    saveButton = (Button) findViewById(R.id.save_edit_button);

    mediaPlayer …
Run Code Online (Sandbox Code Playgroud)

android media-player prepare

9
推荐指数
1
解决办法
3万
查看次数

Cordova插件替代<source-file>标记以复制整个目录内容

有没有办法在plugin.xml中指定使用一个目录复制语句将插件源文件夹中的每个文件复制到目标平台目录,或者自动复制src目录中的每个文件.

使用被复制作为大插件的一部分是噩梦,因为我们看到在大规模重构期间需要手动更改.

plugins prepare cordova

9
推荐指数
2
解决办法
4776
查看次数

PHP PDO准备查询

我在PDO上阅读并在StackOverFlow上搜索了关于pdo和prepare语句的内容.我想知道什么是好处或使用准备声明.例如:

$sql = 'SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour';
$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute(array(':calories' => 150, ':colour' => 'red'));
$red = $sth->fetchAll();
Run Code Online (Sandbox Code Playgroud)

VS

$sql = "SELECT name, colour, calories FROM fruit WHERE calories < $calories AND colour = $colour";
$result = $connection->query($query);
$row = $result->fetch(PDO::FETCH_ASSOC);
Run Code Online (Sandbox Code Playgroud)

两个查询都会返回相同的结果,所以为什么要使用prepare,对我来说看起来它会慢一点,因为你必须执行一个额外的步骤.

谢谢

php pdo prepare

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

postgresql.conf max_prepared_transactions不起作用

我打开了postgres数据文件夹中的postgresql.conf文件,并将max_prepared_connections的值更改为非零值。

但是,每次我尝试使用“ PREPARE TRANSACTION'foo';”命令时,都会收到一条错误消息,指出max_prepared_connections设置为零。

我做错什么了吗?我只希望能够使用prepare transaction命令。

postgresql transactions prepare

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

PDO MYSQL仅在更新时才更新

我有一个网络程序,允许管理员更新用户的信息......话虽如此,我只想要更新的列确实已经'更新'...

我已经对此进行了相当多的研究,似乎所有方法都使用过时的查询,它们没有利用prepare语句来逃避输入......

有人可以帮我说说吗?

基本上在伪代码中: Update FIRSTNAME if $editedUserdata['firstname'] != FIRSTNAME, LASTNAME if $editedUserData['lastname']!= LASTNAME ...等...

这是我对邮政编码的看法......

        $password = sha1($password);
        $editedUserData = array(
              'firstname' => $firstname,
              'lastname' => $lastname,
              'username' => $username,
              'password' => $password,
              'cellphone' => $cellphone,
              'security_level' => $seclvl,
              'email' => $email,
              'direct_phone' => $direct,
              'ext_num' => $extension,
              'is_active' => $userflag
            );
Run Code Online (Sandbox Code Playgroud)

那应该是这样的

$query = $this->db->prepare('UPDATE FIRSTNAME if(?) IS NOT FIRSTNAME, LASTNAME if(?) IS NOT LASTNAME, USERNAME if (?) IS NOT USERNAME.... VALUES (:firstname, :lastname, :username).....' …
Run Code Online (Sandbox Code Playgroud)

php mysql sql pdo prepare

6
推荐指数
2
解决办法
9559
查看次数

在maven发布时提交一些文件:准备

mvn release:prepare可以提交一些文件(没有pom.xml)吗?

在My MultiModul项目中,我使用prepareGoals配置了rlease插件,以更改sql文件中的Version.

<preparationGoals>clean verify org.codehaus.mojo:build-helper-maven-plugin:1.5:parse-version com.google.code.maven-replacer-plugin:replacer:1.5.0:replace</preparationGoals>
Run Code Online (Sandbox Code Playgroud)

一切正常,但更改的SQL文件将不会被提交.

sql文件位于父文件夹的子目录中.没有pom.xml

release commit maven prepare

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