标签:err m3u get ports ring access change rtl adc
创建一个ijkplayer的播放器项目,需要三步设置:
一、在activity_main.xml中添加播放器标签
<com.smallart.myapplication.media.IjkVideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="match_parent"/>
二、在MainActivity.java中添加播放控制
package com.smallart.myapplication; import android.media.MediaPlayer; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.Toast; import com.smallart.myapplication.media.IRenderView; import com.smallart.myapplication.media.IjkVideoView; import com.smallart.myapplication.media.PlayerManager; import tv.danmaku.ijk.media.player.IMediaPlayer; import tv.danmaku.ijk.media.player.IjkMediaPlayer; public class MainActivity extends AppCompatActivity { private IjkVideoView mVideoView; private PlayerManager player; private String url5 = "http://stream1.grtn.cn/tvs2/sd/live.m3u8?_ts&time=1518428696629"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initVideo(); mVideoView = (IjkVideoView) findViewById(R.id.video_view); /** 普通播放 start **/ mVideoView.setAspectRatio(IRenderView.AR_ASPECT_FIT_PARENT); mVideoView.setVideoURI(Uri.parse(url5)); mVideoView.start(); /** 普通播放 end **/ } /** * 可左半屏滑动控制亮度 右半屏控制音量 双击切换比例 (无提示) */ private void initVideo() { player = new PlayerManager(this); player.setFullScreenOnly(true); player.live(true); player.setScaleType(PlayerManager.SCALETYPE_WRAPCONTENT); player.playInFullScreen(true); player.setPlayerStateListener(new PlayerManager.PlayerStateListener() { @Override public void onComplete() { Log.e(" player status :", "complete"); } @Override public void onError() { Log.e(" player status :", "error"); } @Override public void onLoading() { Log.e(" player status :", "loading"); } @Override public void onPlay() { Log.e(" player status :", "play"); } }); player.play(url5); IjkVideoView videoView = player.getVideoView(); videoView.setOnInfoListener(new IMediaPlayer.OnInfoListener() { @Override public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i1) { switch (i) { case MediaPlayer.MEDIA_INFO_BUFFERING_START: break; case MediaPlayer.MEDIA_INFO_BUFFERING_END: case MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING: break; } return false; } }); } }
三、在AndroidManifest.xml文件中设置权限
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.smallart.myapplication"> <uses-permission android:name="android.permission.NFC" /> <uses-feature android:name="android.hardware.nfc.hce" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 银联相关end --> <!-- 震动权限 --> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <!-- shareSDK start --> <!-- <uses-permission android:name="android.permission.READ_CONTACTS" /> --> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- <uses-permission android:name="android.permission.RECEIVE_SMS" /> --> <uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- shareSDK end --> <!-- 百度地图start --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!-- 百度地图end --> <!-- shareSDK start --> <!-- 蓝牙分享所需的权限 --> <!-- <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> --> <!-- shareSDK end --> <!-- 电话服务添加 --> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <!-- Ping++ 支付 --> <!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> --> <!-- 【必须】 信鸽SDK所需权限 --> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RESTART_PACKAGES" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> <uses-permission android:name="android.permission.READ_LOGS" /> <application android:configChanges="orientation|keyboardHidden" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:screenOrientation="sensorLandscape" android:configChanges="orientation|keyboardHidden"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
标签:err m3u get ports ring access change rtl adc
原文地址:https://www.cnblogs.com/alexliuzw/p/10030010.html