System.err: java.io.FileNotFoundException: WAOSA_URL: open failed: ENOENT (No such file or directory) - 视频文件

时间:2021-06-21 17:54:10

标签: java android android-studio

本质上,这是一个由开发团队创建的应用程序,我只是想让该应用程序在最新的 Android SDK 上运行(目标 30)。在这一点上,我对 Android Studio 和移动开发仍然很陌生,所以我只是试图让应用程序恢复使用所有功能,即使 API 已被弃用并且需要尽快升级。一旦它启动并运行,我就可以处理已弃用的方面。我也可以将目标 SDK 暂时降低到 28 或 29 之类的值。

当我在应用上播放视频时会抛出错误。视频在那里,缩略图显示没有问题,但无法播放。应用程序在尝试播放时会在播放器上显示 "something error"。该应用程序不会崩溃或离开屏幕。它只是不断地尝试播放视频,直到用户退出页面。

非常感谢任何帮助或建议。如果我遗漏了应该添加到帖子中的任何代码,请告诉我。

错误如下:

W/System.err: java.io.FileNotFoundException: WAOSA_URL: open failed: ENOENT (No such file or directory)
W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:496)
        at java.io.FileInputStream.<init>(FileInputStream.java:159)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1182)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1160)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1076)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1097)
        at tv.danmaku.ijk.media.player.AndroidMediaPlayer.setDataSource(AndroidMediaPlayer.java:94)
        at tcking.github.com.giraffeplayer2.GiraffePlayer.init(GiraffePlayer.java:421)
        at tcking.github.com.giraffeplayer2.GiraffePlayer.access$600(GiraffePlayer.java:54)
        at tcking.github.com.giraffeplayer2.GiraffePlayer$1.handleMessage(GiraffePlayer.java:222)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:214)
W/MediaPlayer: Couldn't open WAOSA_URL
    java.io.FileNotFoundException: No content provider: WAOSA_URL
        at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1673)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1503)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1420)
        at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1101)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1073)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1097)
        at tv.danmaku.ijk.media.player.AndroidMediaPlayer.setDataSource(AndroidMediaPlayer.java:94)
        at tcking.github.com.giraffeplayer2.GiraffePlayer.init(GiraffePlayer.java:421)
        at tcking.github.com.giraffeplayer2.GiraffePlayer.access$600(GiraffePlayer.java:54)
        at tcking.github.com.giraffeplayer2.GiraffePlayer$1.handleMessage(GiraffePlayer.java:222)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)
    V/MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
    cleanDrmObj: mDrmObj=null mDrmSessionId=null
W/MediaPlayer: Use of stream types is deprecated for operations other than volume control
W/MediaPlayer: See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case
    Use of stream types is deprecated for operations other than volume control
    See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case    

Build.gradle(应用):

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

buildscript {
    repositories {
        google()
        mavenCentral() 
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.google.gms:google-services:4.3.8'
        classpath 'com.android.tools.build:gradle:3.5.4'
    }
}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.'
    }
    compileSdkVersion 30
    defaultConfig {
        applicationId "//removed for privacy"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 3
        versionName '3.1'
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    useLibrary 'org.apache.http.legacy'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    ndkVersion '20.0.5594570'
}

repositories {
    flatDir {
        dirs 'libs'
    }
    mavenCentral()
    maven {
        url 'https://maven.google.com'
    }
    jcenter()
    google()
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.viewpager:viewpager:1.0.0'
    implementation 'androidx.navigation:navigation-runtime:2.4.0-alpha02'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:compose-theme-adapter:1.0.0-beta08'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'com.google.android.material:material:1.4.0-rc01'

    implementation 'commons-io:commons-io:20030203.000550'
    implementation group: 'com.bikomobile', name: 'multipart', version: '1.3.4'

    // The GoCoder SDK library dependency declaration
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'me.relex:circleindicator:2.1.6@aar'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.reginald:editspinner:1.0.0'

    implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
    implementation 'com.github.tcking:viewquery:1.6'
    implementation group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'

    implementation 'com.android.volley:volley:1.2.0'
    implementation 'com.google.code.gson:gson:2.8.7'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'
    implementation 'com.google.firebase:firebase-config:21.0.0'
    implementation 'com.google.firebase:firebase-dynamic-links:20.1.0'

    implementation 'joda-time:joda-time:2.10.10'
    implementation 'com.github.dynckathline:danmaku:1.0'

    implementation files('libs/apache-mime4j-0.6.jar')
    implementation files('libs/httpmime-4.0.1.jar')

    implementation 'com.github.tcking:giraffeplayer2:0.1.25'

    implementation 'com.mikhaellopez:circularimageview:4.3.0'

    implementation group: 'com.github.tcking', name: 'ijkplayer-x86_64', version: '0.8.8'

    api 'com.github.tcking:giraffeplayer2:0.1.25'
    api 'com.github.tcking:giraffeplayer2:0.1.25-lazyLoad'
    api 'com.github.tcking:giraffeplayer2:0.1.25-full'

    api 'com.github.tcking:ijkplayer-arm64:0.8.8-full' //support arm64
    api 'com.github.tcking:ijkplayer-armv5:0.8.8-full' //support armv5
    api 'com.github.tcking:ijkplayer-x86:0.8.8-full' //support x86
    api 'com.github.tcking:ijkplayer-x86_64:0.8.8-full' //support x86_64

}
apply plugin: 'com.google.gms.google-services'

课堂活动流视频:

package com.ccgo.utility;

/*
This class is used to stream online video
 */
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.util.Log;
import android.widget.MediaController;
import android.widget.VideoView;
import com.ccgo.R;
import com.ccgo.utility.AppConstant;
import com.ccgo.utility.Utility;

public class ActivityStreamVideo extends Activity {

    // Declare variables
    ProgressDialog pDialog;
    VideoView videoview;
    private String VIDEO_ID="";
    // Insert your Video URL
    String VideoURL = "";
    private PreferenceManager pref;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Get the layout from video_main.xml

        pref                        =           new PreferenceManager(this);
        if(pref.getThemeId()== AppConstant.THEME_GREEN)
        {
            setContentView(R.layout.activity_stream_video);
        }
        else
        {
            setContentView(R.layout.activity_stream_video_red);
        }

        // Find your VideoView in your video_main.xml layout
        videoview = findViewById(R.id.VideoView);
        // Execute StreamVideo AsyncTask

        //Getting Intent Data
        getIntentData();

        // Create a progressbar
        pDialog = new ProgressDialog(ActivityStreamVideo.this);
        // Set progressbar title
        pDialog.setTitle("Please wait");
        // Set progressbar message
        pDialog.setMessage("Buffering...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        // Show progressbar
        pDialog.show();

        try
        {
            // Start the MediaController
            MediaController mediacontroller = new MediaController(
                    ActivityStreamVideo.this);
            mediacontroller.setAnchorView(videoview);
            // Get the URL from String VideoURL
            Uri video = Uri.parse("//removed for privacy");

            Log.d("UPLOAD",video.toString());
            if(!video.toString().equals("") || video!=null) {
                videoview.setMediaController(mediacontroller);
                videoview.setVideoURI(video);
            }
            else
            {
                Utility.displayToast(ActivityStreamVideo.this,getString(R.string.video_not_found));
            }

        }
        catch (Exception e)
        {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }

        videoview.requestFocus();
        videoview.setOnPreparedListener(new OnPreparedListener()
        {
            // Close the progress bar and play the video
            public void onPrepared(MediaPlayer mp) {
                pDialog.dismiss();
                videoview.start();
            }
        });
    
    }

    //Method to get intent data
    private void getIntentData()
    {
        try
        {
            VIDEO_ID        =       getIntent().getStringExtra("VIDEO_ID");
        }
        catch(NullPointerException e)
        {
                e.printStackTrace();
        }
    }

}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.ccgo">

    <!--<uses-feature android:name="android.hardware.camera" />-->

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACTION_MANAGE_STORAGE" />
    <uses-permission android:name="android.permission.DEFAULT_SCOPED_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!--<uses-feature android:name="android.hardware.camera.autofocus" />-->
    <!--<permission android:name="android.permission.FLASHLIGHT" />-->
    <!--<uses-feature android:name="android.hardware.camera2.full" />-->

    <!--<uses-feature-->
    <!--android:name="android.hardware.camera.front"-->
    <!--android:required="false" />-->

    <application

        android:name=".utility.AppController"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <!--tools:replace="android:appComponentFactory">-->

        <activity
            android:name=".login.activity.SplashActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.StatusBar.Light"
            android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".login.activity.ActivityForgotPassword"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.StatusBar.Light"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".coach.activity.ActivityRecordVideo"
            android:label="@string/title_activity_add_challenge"
            android:theme="@style/AppTheme.NoActionBar" />

        <activity
            android:name=".company_admin.activity.ActivityViewLicenseInformation"
            android:label="@string/title_activity_add_challenge"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />

        <activity
            android:name=".company_admin.activity.ActivityManageNotification"
            android:label="@string/title_activity_add_challenge"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />

        <activity
            android:name=".ActivityManageTheme"
            android:label="@string/manage_theme"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />

        <activity
            android:name=".coach.activity.ActivityCreateChallengeSubmission"
            android:label="@string/title_activity_add_challenge"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".company_admin.activity.ActivityAddVote"
            android:label="@string/title_activity_add_challenge"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".coach.activity.ActivityCreateChallenge"
            android:label="@string/title_activity_add_challenge"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".coach.activity.ActivityPreviewVideo"
            android:label="@string/title_activity_add_challenge"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".coach.activity.ActivityPreviewDescription"
            android:label="@string/title_activity_add_challenge"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".login.activity.ActivityLogin"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.StatusBar.Light"
            android:windowSoftInputMode="stateHidden">
            <!--dynamicLink intent filter starts-->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="//removed for privacy"
                    android:scheme="http" />
                <data
                    android:host="//removed for privacy"
                    android:scheme="https" />
                <!--dynamicLink intent filter ends-->
            </intent-filter>
        </activity>
        <activity
            android:name=".HomeActivity"
            android:label="@string/title_activity_main"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".company_admin.activity.ActivityOngoingChallengesDetail"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:launchMode="singleTask"
            android:screenOrientation="sensor"
            android:theme="@style/AppTheme.StatusBar.Light"
            android:windowSoftInputMode="stateHidden" />

        <activity
            android:name=".company_admin.activity.ActivityEditChallenge"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="sensor"
            android:theme="@style/AppTheme.StatusBar.Light"
            android:windowSoftInputMode="stateHidden" />

        <activity
            android:name=".company_admin.activity.ActivityResponseDetail"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:launchMode="singleTask"
            android:screenOrientation="sensor"
            android:theme="@style/AppTheme.StatusBar.Light"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".company_admin.activity.ActivityViewLeaderBoard"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".coach.activity.ActivityViewTeamLeaderBoardCaoch"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />

        <activity
            android:name=".company_admin.activity.ActivityManageLibraryDetail"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="sensor"
            android:theme="@style/AppTheme.NoActionBar" />

        <receiver
            android:name=".utility.ConnectivityReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".SampleActivity"
            android:label="@string/title_activity_sample"
            android:theme="@style/AppTheme.NoActionBar" />
        <!-- Firebase Notifications -->

        <!--  <service android:name=".notification.MyFireBaseIntanceIDService">
             <intent-filter>
                 <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
             </intent-filter>
         </service> -->

         <service android:name=".notification.MyFireBaseMessagingService">
             <intent-filter>
                 <action android:name="com.google.firebase.MESSAGING_EVENT" />
             </intent-filter>
         </service>

         <activity
             android:name=".company_admin.activity.ViewTeamActivity"
             android:label="Select Team"
             android:screenOrientation="portrait"
             android:theme="@style/AppTheme.StatusBar.Light" />

         <provider
             android:name="androidx.core.content.FileProvider"
             android:authorities="com.ccgo.provider"
             android:exported="false"
             android:grantUriPermissions="true">
             <meta-data
                 android:name="android.support.FILE_PROVIDER_PATHS"
                 android:resource="@xml/external_files" />
         </provider>

         <activity android:name=".company_admin.activity.ActivityManageLibraryResponse" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
     </application>

 </manifest>

如果我尝试在应用的不同区域播放视频,则会出现以下错误:

W/MediaPlayer: Couldn't open WAOSA_URL
    java.io.FileNotFoundException: No content provider: WAOSA_URL
        at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1673)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1503)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1420)
        at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1101)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1073)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1097)
        at android.widget.VideoView.openVideo(VideoView.java:412)
        at android.widget.VideoView.access$2200(VideoView.java:83)
        at android.widget.VideoView$7.surfaceCreated(VideoView.java:694)
        at android.view.SurfaceView.updateSurface(SurfaceView.java:758)
        at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:155)
        at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1088)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2745)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
        at android.view.Choreographer.doCallbacks(Choreographer.java:790)
        at android.view.Choreographer.doFrame(Choreographer.java:725)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

1 个答案:

答案 0 :(得分:0)

您面临的问题可能是因为在您将 gradle 文件升级到 targetSdkVersion(共 30 个)后,您的应用必须遵守新的文件访问限制。

虽然 Google 的文档不是很好,但这是我能找到的最好的信息来了解更多信息:

https://support.google.com/googleplay/android-developer/answer/10467955(确保展开此页面底部的部分)

https://www.reddit.com/r/androiddev/comments/mwaqn1/scoped_storage_recap/(这个更侧重于范围存储,但仍然有帮助)