IjkMediaPlayer
来源:互联网 发布:linux 文件引用计数 编辑:程序博客网 时间:2024/06/10 19:58
、、依赖
compile 'com.github.leifzhang:IjkLib:0.4.3'
、、ACtivity
package com.bwie.ShiPinDemo;import android.content.pm.ActivityInfo;import android.content.res.Configuration;import android.net.Uri;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import tv.danmaku.ijk.media.player.IjkMediaPlayer;import tv.danmaku.ijk.media.widget.media.AndroidMediaController;import tv.danmaku.ijk.media.widget.media.IjkVideoView;public class MainActivity extends AppCompatActivity { IjkVideoView videoView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button) findViewById(R.id.fullscreen); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setOrientation(getResources().getConfiguration().orientation); } }); IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); videoView = (IjkVideoView) findViewById(R.id.ijkPlayer); AndroidMediaController controller = new AndroidMediaController(this, false); videoView.setMediaController(controller); String url = "https://wdl.wallstreetcn.com/41aae4d2-390a-48ff-9230-ee865552e72d"; // String url = "http://o6wf52jln.bkt.clouddn.com/演员.mp3"; videoView.setVideoURI(Uri.parse(url)); videoView.start(); } private void setOrientation(int orientation) { if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } @Override protected void onPause() { super.onPause(); videoView.pause(); } @Override protected void onDestroy() { super.onDestroy(); IjkMediaPlayer.native_profileEnd(); } @Override protected void onResume() { super.onResume(); videoView.resume(); }}//布局<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.bwie.ShiPinDemo.MainActivity"> <tv.danmaku.ijk.media.widget.media.IjkVideoView android:id="@+id/ijkPlayer" android:layout_width="match_parent" android:layout_height="match_parent" /> <Button android:id="@+id/fullscreen" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="fullscreen" /></RelativeLayout>
阅读全文
0 0
- IjkMediaPlayer
- IJKMediaPlayer静态库制作
- 使用IjkMediaPlayer结合surface
- 使用IjkMediaPlayer结合surface
- IjkMediaPlayer.reset()耗时的一个解决方案
- 使用IjkMediaPlayer结合surfaceView播放视频,自己写的播放和暂停按钮(四)
- Maven实战
- webview运用和传值
- 多线程下载
- HDU 1257 最少拦截系统
- 数组中只出现一次的数字(数组)
- IjkMediaPlayer
- Smallest Difference(最小差值)三种角度求解
- Java基础总结第(3)天
- spring+mybatis的配置用法
- 第13周项目1-(1)验证折半查找算法
- 6. 二维数组和面向对象
- shell script中read的用法
- 设计模式系列-面向对象葵花宝典-面向对象实战
- Python微框架web.py初印象