1

I can not seem to get video playing on my device (Nexus 7). I decided to just start fresh with a new project for this problem.

The video is stored in res/raw.
It is this video: http://www.howtodance.org/media/Lesson_2__9_lindy_demo_2__shoulder_pop_with_scoop_around.mp4

I have tried many of the ways suggested here at stackoverflow. Here is the latest of what I have tried:

    <!-- main.xml -->


    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="vertical"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
            >
        <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="New Button"
                android:id="@+id/button"
                android:layout_gravity="center"
                android:onClick="onButtonClick"
                />

    </LinearLayout>

//MyActivity.java

package com.example.VideoTests;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.io.File;

public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }



    public void onButtonClick(View v){
        Log.d("working", "PlayVideo();");
        //  both of these urls don't seem to work
        //String uriString = "android.resource://com.example.VideoTests/raw/lesson_2__9_lindy_demo_2__shoulder_pop_with_scoop_around.mp4";
        String uriString = "android.resource://" + getPackageName() + "/" + R.raw.lesson_2__9_lindy_demo_2__shoulder_pop_with_scoop_around;

        //Uri video = Uri.parse(uriString);
        File file = new File(uriString); // video player selection dialog doesn't seem to load at all unless I send it through a file first.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file), "video/mp4");
        startActivity(intent); // this is where it seems to crash
    }

}

After adding the File object a dialog finally comes up, but then I get a message saying "Can't play this video" and the following error:

ERROR/(128): Failed to open file '/android.resource:/com.example.VideoTests/2130968576'. (No such file or directory)

If I use the other uriString, it still gives me this error:

ERROR/(128): Failed to open file '/android.resource:/com.example.VideoTests/raw/lesson_2__9_lindy_demo_2__shoulder_pop_with_scoop_around.mp4'. (No such file or directory)

I have also tried changing the video file name to something short like 'asdf.mp4', but the same errors occur

Thank you in advance for any help everyone.

A--C
  • 36,351
  • 10
  • 106
  • 92
Herbal7ea
  • 306
  • 3
  • 8

1 Answers1

0

The issue ended up being that I was trying to let them choose which Video player they want to use to play a video file that is internal and not accessible on the local storage. I ended up using a local VideoView in a sub activity.

Herbal7ea
  • 306
  • 3
  • 8