2

Android アプリで動画をストリーミングするための簡単なコードを作成しました。私は Vitamio Library を使用し、プロジェクトに統合するために必要なすべての手順に従いました。ビデオが再生されず、ロード時にアプリがクラッシュします。

package com.test.bufferapp;

import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;


public class MainActivity extends Activity {

    private String path = "rtsp://184.72.239.149/vod/mp4:sample.mp4";
    private VideoView mVideoView;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        setContentView(R.layout.activity_main);
        mVideoView = (VideoView) findViewById(R.id.video_view);
        if (path == "") {
            // Tell the user to provide a media file URL/path.
            Toast.makeText(this.getApplicationContext(), "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
            return;
        } else {
                    mVideoView.setVideoPath("rtsp://184.72.239.149/vod/mp4:sample.mp4");
//                  MediaController mc = new MediaController(getApplicationContext());
//                  mVideoView.setMediaController(mc);
                    mVideoView.requestFocus();

                    mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                        @Override
                        public void onPrepared(MediaPlayer mediaPlayer) {
                            // optional need Vitamio 4.0
                            mediaPlayer.setPlaybackSpeed(1.0f);
                        }
                    });
                }

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

以下はLogcatです

09-05 04:40:42.650: D/Vitamio[Player](1072): CPU implementer:0x41
09-05 04:40:42.650: D/Vitamio[Player](1072): Serial:0000000000000000
09-05 04:40:42.660: D/Vitamio[Player](1072): CPU architecture:7
09-05 04:40:42.660: D/Vitamio[Player](1072): Hardware:Goldfish
09-05 04:40:42.660: D/Vitamio[Player](1072): CPU revision:0
09-05 04:40:42.660: D/Vitamio[Player](1072): CPU variant:0x0
09-05 04:40:42.660: D/Vitamio[Player](1072): CPU part:0xc08
09-05 04:40:42.660: D/Vitamio[Player](1072): Revision:0000
09-05 04:40:42.660: D/Vitamio[Player](1072): BogoMIPS:368.64
09-05 04:40:42.660: D/Vitamio[Player](1072): Features:swp half thumb fastmult vfp edsp neon vfpv3 tls
09-05 04:40:42.660: D/Vitamio[Player](1072): Processor:ARMv7 Processor rev 0 (v7l)
09-05 04:40:42.660: D/Vitamio[Player](1072): CPU architecture: 7
09-05 04:40:42.660: D/Vitamio[Player](1072): GET CPU FATURE: V5TE V6 VFP V7A VFPV3 NEON 
09-05 04:40:42.750: D/dalvikvm(1072): Trying to load lib /data/app-lib/com.test.bufferapp-2/libvinit.so 0xb3dcea40
09-05 04:40:42.750: D/dalvikvm(1072): Added shared lib /data/app-lib/com.test.bufferapp-2/libvinit.so 0xb3dcea40
09-05 04:40:42.840: I/Vitamio[Player](1072): isNativeLibsInited, APP VERSION: 1, Vitamio Library version: 1
09-05 04:40:43.650: I/Vitamio[Player](1072): isNativeLibsInited, APP VERSION: 1, Vitamio Library version: 1
09-05 04:40:43.710: I/Vitamio[Player](1072): LIB ROOT: /data/data/com.test.bufferapp/libs/
09-05 04:40:43.710: D/dalvikvm(1072): Trying to load lib /data/data/com.test.bufferapp/libs/libstlport_shared.so 0xb3dcea40
09-05 04:40:43.740: D/dalvikvm(1072): Added shared lib /data/data/com.test.bufferapp/libs/libstlport_shared.so 0xb3dcea40
09-05 04:40:43.740: D/dalvikvm(1072): No JNI_OnLoad found in /data/data/com.test.bufferapp/libs/libstlport_shared.so 0xb3dcea40, skipping init
09-05 04:40:43.740: D/dalvikvm(1072): Trying to load lib /data/data/com.test.bufferapp/libs/libvplayer.so 0xb3dcea40
09-05 04:40:43.760: D/dalvikvm(1072): Added shared lib /data/data/com.test.bufferapp/libs/libvplayer.so 0xb3dcea40
09-05 04:40:43.760: I/Vitamio[4.2.1][Player](1072): Copyright (c) YIXIA (http://yixia.com).
09-05 04:40:43.760: I/Vitamio[4.2.1][Player](1072): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
09-05 04:40:43.760: I/Vitamio[4.2.1][Player](1072): LOAD FFMPEG START: /data/data/com.test.bufferapp/libs/libffmpeg.so
09-05 04:40:43.760: W/linker(1072): libffmpeg.so has text relocations. This is wasting memory and is a security risk. Please fix.
09-05 04:40:43.800: I/Vitamio[4.2.1][Player](1072): LOAD FFMPEG END: /data/data/com.test.bufferapp/libs/libffmpeg.so
09-05 04:40:43.800: I/Vitamio[4.2.1][Player](1072): LOAD VVO START: /data/data/com.test.bufferapp/libs/libvvo.9.so
09-05 04:40:43.800: E/Vitamio[4.2.1][Player](1072): FIND_NAME_SYM vvo, render_yuv
09-05 04:40:43.800: I/Vitamio[4.2.1][Player](1072): LOAD VVO END: /data/data/com.test.bufferapp/libs/libvvo.9.so
09-05 04:40:43.800: I/Vitamio[4.2.1][Player](1072): LOAD VAO START: /data/data/com.test.bufferapp/libs/libvao.0.so
09-05 04:40:43.830: I/Vitamio[4.2.1][Player](1072): LOAD VAO END: /data/data/com.test.bufferapp/libs/libvao.0.so
09-05 04:40:43.830: I/Vitamio[4.2.1][Player](1072): VPLAYER INIT BEGIN
09-05 04:40:43.830: I/Vitamio[4.2.1][Player](1072): Application package name: com.test.bufferapp
09-05 04:40:43.910: I/Vitamio[4.2.1][Player](1072): VPLAYER INIT END
09-05 04:40:43.910: I/Vitamio[4.2.1][Player](1072): Copyright (c) YIXIA (http://yixia.com).
09-05 04:40:43.910: I/Vitamio[4.2.1][Player](1072): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): Application package name: com.test.bufferapp
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): Copyright (c) YIXIA (http://yixia.com).
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): Application package name: com.test.bufferapp
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): PREPARE SIG: 0
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): THREAD PREPARE START
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): THREAD PREPARE ATTACHED
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): Copyright (c) YIXIA (http://yixia.com).
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
09-05 04:40:43.920: I/Vitamio[4.2.1][Player](1072): OPEN FILE rtsp://184.72.239.149/vod/mp4:sample.mp4
09-05 04:40:44.000: I/Choreographer(1072): Skipped 58 frames!  The application may be doing too much work on its main thread.
09-05 04:40:44.150: D/gralloc_goldfish(1072): Emulator without GPU emulation detected.
09-05 04:41:02.646: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] Missing reference picture, default is 0
09-05 04:41:02.646: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] decode_slice_header error
09-05 04:41:02.676: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] Missing reference picture, default is 65538
09-05 04:41:02.696: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] Missing reference picture, default is 65540
09-05 04:41:03.836: I/Vitamio[4.2.1][Player](1072): META AUDIO: 0. und, META SUBTITLE: 
09-05 04:41:03.836: I/Vitamio[4.2.1][Player](1072): OOPS: ONLY 1
09-05 04:41:03.886: I/Vitamio[4.2.1][Player](1072): OPEN STREAM AUDIO BEGIN
09-05 04:41:03.886: I/Vitamio[4.2.1][Player](1072): Copyright (c) YIXIA (http://yixia.com).
09-05 04:41:03.886: I/Vitamio[4.2.1][Player](1072): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
09-05 04:41:03.886: I/Vitamio[4.2.1][Player](1072): Application package name: com.test.bufferapp
09-05 04:41:03.886: I/Vitamio[4.2.1][Player](1072): 2, 48000, 0
09-05 04:41:03.906: E/android.media.AudioTrack(1072): getMinBufferSize(): error querying hardware
09-05 04:41:03.926: E/Vitamio[Player](1072): audioTrackInit
09-05 04:41:03.926: E/Vitamio[Player](1072): java.lang.IllegalArgumentException: Invalid audio buffer size.
09-05 04:41:03.926: E/Vitamio[Player](1072):    at android.media.AudioTrack.audioBuffSizeCheck(AudioTrack.java:477)
09-05 04:41:03.926: E/Vitamio[Player](1072):    at android.media.AudioTrack.<init>(AudioTrack.java:317)
09-05 04:41:03.926: E/Vitamio[Player](1072):    at android.media.AudioTrack.<init>(AudioTrack.java:265)
09-05 04:41:03.926: E/Vitamio[Player](1072):    at io.vov.vitamio.MediaPlayer.audioTrackInit(MediaPlayer.java:1211)
09-05 04:41:03.926: E/Vitamio[Player](1072):    at dalvik.system.NativeStart.run(Native Method)
09-05 04:41:03.926: I/Vitamio[4.2.1][Player](1072): CLOSE STREAM AUDIO BEGIN
09-05 04:41:03.926: I/Vitamio[4.2.1][Player](1072): CLOSE STREAM AUDIO END
09-05 04:41:03.936: I/Vitamio[4.2.1][Player](1072): OPEN STREAM AUDIO END
09-05 04:41:03.936: I/Vitamio[4.2.1][Player](1072): Copyright (c) YIXIA (http://yixia.com).
09-05 04:41:03.936: I/Vitamio[4.2.1][Player](1072): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
09-05 04:41:03.936: I/Vitamio[4.2.1][Player](1072): Application package name: com.test.bufferapp
09-05 04:41:03.936: I/Vitamio[4.2.1][Player](1072): OOPS: ONLY 1
09-05 04:41:03.936: I/Vitamio[4.2.1][Player](1072): OPEN STREAM VIDEO BEGIN
09-05 04:41:03.946: I/Vitamio[4.2.1][Player](1072): OPEN STREAM VIDEO END
09-05 04:41:03.966: I/Vitamio[4.2.1][Player](1072): THREAD PREPARE DETTACHED, ret = 0
09-05 04:41:03.966: I/Vitamio[4.2.1][Player](1072): THREAD PREPARE END
09-05 04:41:04.016: I/Vitamio[4.2.1][Player](1072): CC: ARMYUV420 0
09-05 04:41:04.036: D/Vitamio[Player](1072): onVideoSizeChanged: (424x240)
09-05 04:41:04.106: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] Missing reference picture, default is 0
09-05 04:41:04.106: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] decode_slice_header error
09-05 04:41:04.106: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] Missing reference picture, default is 65538
09-05 04:41:04.196: D/Vitamio[Player](1072): VIDEO: 424x240x1.766667, Surface: 424x240, LP: 768x434, Window: 768x1184x0.648649
09-05 04:41:04.196: D/Vitamio[Player](1072): onPrepared
09-05 04:41:04.246: E/Vitamio[4.2.1][Player](1072): [h264 @ 0xb88994c0] Missing reference picture, default is 65540
09-05 04:41:04.266: D/Vitamio[Player](1072): VIDEO: 424x240x1.766667, Surface: 424x240, LP: 768x434, Window: 768x1184x0.648649
09-05 04:41:04.276: I/Vitamio[Player](1072): Info (701, 0)
09-05 04:41:04.276: D/Vitamio[Player](1072): onInfo: (701, 0)
09-05 04:41:04.806: D/dalvikvm(1072): GC_FOR_ALLOC freed 242K, 9% free 3143K/3448K, paused 75ms, total 76ms
09-05 04:41:05.086: W/dalvikvm(1072): JNI WARNING: JNI function EnsureLocalCapacity called with exception pending
09-05 04:41:05.086: W/dalvikvm(1072):              in Ldalvik/system/NativeStart;.run:()V (EnsureLocalCapacity)
09-05 04:41:05.086: W/dalvikvm(1072): Pending exception is:
09-05 04:41:05.126: I/dalvikvm(1072): java.lang.SecurityException: ConnectivityService: Neither user 10056 nor current process has android.permission.ACCESS_NETWORK_STATE.
09-05 04:41:05.126: I/dalvikvm(1072):   at android.os.Parcel.readException(Parcel.java:1465)
09-05 04:41:05.126: I/dalvikvm(1072):   at android.os.Parcel.readException(Parcel.java:1419)
09-05 04:41:05.126: I/dalvikvm(1072):   at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:813)
09-05 04:41:05.136: I/dalvikvm(1072):   at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:560)
09-05 04:41:05.136: I/dalvikvm(1072):   at io.vov.vitamio.utils.Device.getIdentifiers(Device.java:58)
09-05 04:41:05.136: I/dalvikvm(1072):   at io.vov.vitamio.utils.Device.getDeviceFeatures(Device.java:42)
09-05 04:41:05.136: I/dalvikvm(1072):   at dalvik.system.NativeStart.run(Native Method)
09-05 04:41:05.136: I/dalvikvm(1072): "Thread-82" prio=5 tid=12 NATIVE
09-05 04:41:05.136: I/dalvikvm(1072):   | group="main" sCount=0 dsCount=0 obj=0xb3e30f38 self=0xb886b498
09-05 04:41:05.136: I/dalvikvm(1072):   | sysTid=1144 nice=0 sched=0/0 cgrp=apps handle=-1198133984
09-05 04:41:05.136: I/dalvikvm(1072):   | state=R schedstat=( 190000000 790000000 432 ) utm=14 stm=5 core=0
09-05 04:41:05.196: D/Vitamio[Player](1072): onVideoSizeChanged: (424x240)
09-05 04:41:05.256: D/Vitamio[Player](1072): VIDEO: 424x240x1.766667, Surface: 424x240, LP: 768x434, Window: 768x1184x0.648649
09-05 04:41:05.266: D/Vitamio[Player](1072): onVideoSizeChanged: (424x240)
09-05 04:41:05.266: D/Vitamio[Player](1072): VIDEO: 424x240x1.766667, Surface: 424x240, LP: 768x434, Window: 768x1184x0.648649
09-05 04:41:05.336: I/dalvikvm(1072):   #00  pc 0000132e  /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
09-05 04:41:05.336: I/dalvikvm(1072):   #01  pc 000603ea  /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+33)
09-05 04:41:05.336: I/dalvikvm(1072):   #02  pc 000543e4  /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+395)
09-05 04:41:05.336: I/dalvikvm(1072):   #03  pc 00054452  /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
09-05 04:41:05.346: I/dalvikvm(1072):   #04  pc 0003871c  /system/lib/libdvm.so
09-05 04:41:05.346: I/dalvikvm(1072):   #05  pc 00040ea0  /system/lib/libdvm.so
09-05 04:41:05.356: I/dalvikvm(1072):   #06  pc 00019130  /data/data/com.test.bufferapp/libs/libvplayer.so
09-05 04:41:05.356: I/dalvikvm(1072):   #07  pc 000195b8  /data/data/com.test.bufferapp/libs/libvplayer.so
09-05 04:41:05.356: I/dalvikvm(1072):   #08  pc 0000d060  /system/lib/libc.so (__thread_entry+72)
09-05 04:41:05.356: I/dalvikvm(1072):   #09  pc 0000d1f8  /system/lib/libc.so (pthread_create+240)
09-05 04:41:05.356: I/dalvikvm(1072):   at dalvik.system.NativeStart.run(Native Method)
09-05 04:41:05.356: E/dalvikvm(1072): VM aborting
09-05 04:41:05.356: A/libc(1072): Fatal signal 6 (SIGABRT) at 0x00000430 (code=-6), thread 1144 (.test.bufferapp)

マニフェスト ファイル

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.bufferapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="io.vov.vitamio.activity.InitActivity"
            android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
            android:launchMode="singleTop"
            android:theme="@android:style/Theme.NoTitleBar"
            android:windowSoftInputMode="stateAlwaysHidden" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
4

1 に答える 1

4

次のエラーが表示されます。

java.lang.SecurityException: ConnectivityService: Neither user 10056 nor current process has android.permission.ACCESS_NETWORK_STATE.

追加

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

マニフェスト ファイルで確認します。

それが役に立てば幸い。

于 2014-09-05T09:21:38.313 に答える