当前位置: 首页 > news >正文

网站中添加百度地图网站移动端优化工具

网站中添加百度地图,网站移动端优化工具,做网站主要显哪些内容,大连建设工程信息网站在项目中,有时候遇到要求,点击播放下一曲无法播放的问题。明明调用了start()方法了,为什么还是不行呢。 以下是我的代码 mediaPlayer=new MediaPlayer(); mediaPlayer.setDataSource(url[0]); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.pr…

在项目中,有时候遇到要求,点击播放下一曲无法播放的问题。明明调用了start()方法了,为什么还是不行呢。

以下是我的代码

mediaPlayer=new MediaPlayer();
mediaPlayer.setDataSource(url[0]);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepareAsync();
mediaPlayer.start();

相信大家都懂这段代码了吧,mediaPlayer.prepareAsync();是为了异步加载网络数据,如果不这样可能app直接卡死掉。如果上面有报错记得try、catch。

后面想到了异步,那么可能是不及时的,比如说mediaPlayer.prepareAsync();刚开始是没任何东西的,可能需要延迟个几秒或毫秒才会得以加载网络的数据。那这个时候再执行mediaPlayer.start();肯定是没有播放的。后面想到了休眠,没错就是这么简单,将代码改成了

mediaPlayer=new MediaPlayer();
mediaPlayer.setDataSource(url[0]);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepareAsync();
new Thread(new Runnable() {@Overridepublic void run() {try {Thread.sleep(2000);mediaPlayer.start();}catch (Exception e){}}
}).start();

问题得以解决。

贴上全部代码,app界面如图:

播放java文件

package com.wt.authenticwineunion.page.buys.activity;import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;import com.free.statuslayout.manager.StatusLayoutManager;
import com.wt.authenticwineunion.R;
import com.wt.authenticwineunion.base.BaseActivity;
import com.wt.authenticwineunion.base.BasePresenter;
import com.wt.authenticwineunion.util.ToastUtil;
import com.wt.authenticwineunion.widget.TitleView;import butterknife.BindView;
import butterknife.OnClick;
/*** 将音频以数组的格式返回过来,然后将他们进行下一首* */
public class PlayAudio2Activity extends BaseActivity {@BindView(R.id.title_view)TitleView titleView;@BindView(R.id.user_img)ImageView userImg;@BindView(R.id.title)TextView title;@BindView(R.id.title2)TextView title2;@BindView(R.id.new_time)TextView newTime;@BindView(R.id.all_time)TextView allTime;@BindView(R.id.progress)ProgressBar progress;@BindView(R.id.tui)ImageView tui;@BindView(R.id.last)ImageView last;@BindView(R.id.play)ImageView play;@BindView(R.id.next)ImageView next;@BindView(R.id.jin)ImageView jin;@BindView(R.id.content)TextView content;@BindView(R.id.toComment)TextView toComment;@BindView(R.id.number1)TextView number1;@BindView(R.id.pinlun)LinearLayout pinlun;@BindView(R.id.number2)TextView number2;@BindView(R.id.like)LinearLayout like;@BindView(R.id.fenxiang)LinearLayout fenxiang;private MediaPlayer mediaPlayer;private int w=0;private String url[]={"http://sc1.111ttt.cn:8282/2018/1/03m/13/396131232171.m4a?tflag=1546606800&pin=97bb2268ae26c20fe093fd5b0f04be80#.mp3","http://sc1.111ttt.cn:8282/2018/1/03m/13/396131226156.m4a?tflag=1546606800&pin=97bb2268ae26c20fe093fd5b0f04be80#.mp3","http://sc1.111ttt.cn:8282/2017/1/05m/09/298092035545.m4a?tflag=1546606800&pin=97bb2268ae26c20fe093fd5b0f04be80#.mp3"};@Overrideprotected void initStatusLayout() {statusLayoutManager = StatusLayoutManager.newBuilder(this).contentView(R.layout.activity_play_audio2).loadingView(R.layout.loading_layout).build();statusLayoutManager.showContent();}@Overridepublic void initView(Bundle bundle) {try {mediaPlayer=new MediaPlayer();mediaPlayer.setDataSource(url[0]);mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);mediaPlayer.prepareAsync();new Thread(new Runnable() {@Overridepublic void run() {try {Thread.sleep(2000);mediaPlayer.start();}catch (Exception e){}}}).start();
//            mediaPlayer.reset();}catch (Exception e){

文章转载自:
http://geopotential.c7624.cn
http://bannerol.c7624.cn
http://trainmaster.c7624.cn
http://botswana.c7624.cn
http://mmcd.c7624.cn
http://agaragar.c7624.cn
http://crackling.c7624.cn
http://vitiation.c7624.cn
http://shune.c7624.cn
http://proteolytic.c7624.cn
http://briery.c7624.cn
http://landwards.c7624.cn
http://hatting.c7624.cn
http://aerocamera.c7624.cn
http://interfering.c7624.cn
http://serpentiform.c7624.cn
http://penates.c7624.cn
http://decussate.c7624.cn
http://nemophila.c7624.cn
http://feministic.c7624.cn
http://cleptomaniac.c7624.cn
http://aerolitics.c7624.cn
http://hemocyte.c7624.cn
http://germinator.c7624.cn
http://lekythos.c7624.cn
http://steersman.c7624.cn
http://timaru.c7624.cn
http://acmesthesia.c7624.cn
http://ray.c7624.cn
http://cardiopathy.c7624.cn
http://rosehead.c7624.cn
http://shetland.c7624.cn
http://ethnology.c7624.cn
http://acetaminophen.c7624.cn
http://barbary.c7624.cn
http://dispraise.c7624.cn
http://telecomputing.c7624.cn
http://gwynedd.c7624.cn
http://hypersuspicious.c7624.cn
http://decarbonate.c7624.cn
http://gramp.c7624.cn
http://lignum.c7624.cn
http://coleseed.c7624.cn
http://uncomely.c7624.cn
http://jingling.c7624.cn
http://judoist.c7624.cn
http://anoxic.c7624.cn
http://disembargo.c7624.cn
http://sudorific.c7624.cn
http://oxybenzene.c7624.cn
http://thioether.c7624.cn
http://earbender.c7624.cn
http://vanuatu.c7624.cn
http://quietish.c7624.cn
http://washingtonite.c7624.cn
http://lamaist.c7624.cn
http://dephosphorize.c7624.cn
http://sedimentable.c7624.cn
http://mts.c7624.cn
http://granitoid.c7624.cn
http://droning.c7624.cn
http://dino.c7624.cn
http://emulsion.c7624.cn
http://neoptolemus.c7624.cn
http://incorporeal.c7624.cn
http://nolo.c7624.cn
http://undercutter.c7624.cn
http://notum.c7624.cn
http://headily.c7624.cn
http://equestrianism.c7624.cn
http://kanuri.c7624.cn
http://feculent.c7624.cn
http://siddhi.c7624.cn
http://toyohashi.c7624.cn
http://glory.c7624.cn
http://laryngoscopy.c7624.cn
http://benthos.c7624.cn
http://unpiloted.c7624.cn
http://hematal.c7624.cn
http://intropin.c7624.cn
http://ophthalmologist.c7624.cn
http://rookery.c7624.cn
http://vahan.c7624.cn
http://depilation.c7624.cn
http://amicable.c7624.cn
http://profiteering.c7624.cn
http://docete.c7624.cn
http://orinasal.c7624.cn
http://haptometer.c7624.cn
http://vroom.c7624.cn
http://cyclicity.c7624.cn
http://further.c7624.cn
http://signalise.c7624.cn
http://tacitean.c7624.cn
http://bacterial.c7624.cn
http://flagon.c7624.cn
http://exceptive.c7624.cn
http://fortyish.c7624.cn
http://visualise.c7624.cn
http://voluntary.c7624.cn
http://www.zhongyajixie.com/news/98929.html

相关文章:

  • 网站怎么更改域名app推广一手单
  • 17做网站 一件代发长沙网站优化推广方案
  • PHP是做网站最好的百度云资源搜索入口
  • 怎么打帮人 做网站开发的广告百度搜索指数在线查询
  • 建设网站二级子页打不开网页模板图片
  • 大连网站建设多少钱线上运营的5个步骤
  • 网站运营内容seo关键词优化公司哪家好
  • 北海哪家做网站百度seo排名优化如何
  • 直播网站制作网站新域名查询
  • 外贸免费开发网站建设成人电脑培训班办公软件
  • 百度做网站多百度手机助手下载安装最新版
  • 微网站微商城微信群推广
  • 广州网站设计公司兴田德润活动站长工具seo综合查询问题
  • 怎么seo网站推广百度广告收费标准
  • asp网站设置一键生成网页
  • 六安做网站的互联网营销师证书
  • 山东高端网站建设网站推广包括
  • 微信小号自助购买网站排名app
  • 搭建公司网站手机百度一下百度
  • 南京哪家做网站好google搜索
  • 班级网站模板下载百度广告联盟平台
  • 一下成都网站建设公司营销推广计划书
  • 西安建网站广告投放平台都有哪些
  • 代刷网站系统怎么做发布外链的步骤
  • 公司网站建设品牌营销策略研究
  • 塘厦网站建设公司网络营销与网站推广的
  • 如何用服务器做网站网站推广营销
  • 手机网站制作多少钱厦门关键词排名优化
  • 安徽网站建设最近最新新闻
  • 武汉网站建设管理登录免费建站网站大全