分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
本文来自http://blog.youkuaiyun.com/hellogv/ ,引用必须注明出处!
以前曾经地介绍过MediaPlayer的基本用法,这里就深入地讲解MediaPlayer的在线播放功能。本文主要实现MediaPlayer在线播放音频的功能,由于在线视频播放比在线音频播放复杂,因此先介绍在线音频播放的实现,这样可以帮助大家逐步深入了解MediaPlayer的在线播放功能。先来看看本文程序运行的结果:
main.xml的源码如下:
- <?xml version="1.0" encoding="utf-8"?>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="fill_parent" android:layout_width="fill_parent">
- <LinearLayout android:layout_height="wrap_content"
- android:layout_width="fill_parent" android:orientation="vertical"
- android:layout_gravity="top">
- <LinearLayout android:orientation="horizontal"
- android:layout_gravity="center_horizontal" android:layout_marginTop="4.0dip"
- android:layout_height="wrap_content" android:layout_width="wrap_content">
- <Button android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:id="@+id/btnPlayUrl"
- android:text="播放网络音频"></Button>
- <Button android:layout_height="wrap_content" android:id="@+id/btnPause"
- android:text="暂停" android:layout_width="80dip"></Button>
- <Button android:layout_height="wrap_content"
- android:layout_width="80dip" android:text="停止" android:id="@+id/btnStop"></Button>
- </LinearLayout>
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:layout_marginBottom="20dip">
- <SeekBar android:paddingRight="10dip" android:layout_gravity="center_vertical"
- android:paddingLeft="10dip" android:layout_weight="1.0"
- android:layout_height="wrap_content" android:layout_width="wrap_content"
- android:id="@+id/skbProgress"