2013-11-09 5 views
1

Я пытаюсь воспроизвести видео в своем приложении для Android, но когда я нажимаю на активность через свой список меню, приложение остается в списке и не воспроизводит видео. Код нижеandroid: не могу воспроизвести видео

мое меню

package com.example.taekwondobuddy.util; 

import android.app.ListActivity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 

public class Kicks extends ListActivity { 

String classes[] = {"FrontKick","RoundhouseKick","AxeKick"} ; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setListAdapter(new ArrayAdapter<String>(Kicks.this, android.R.layout.simple_list_item_1, classes)); 
} 


@Override 
protected void onListItemClick(ListView l, View v, int position, long id) { 
    // TODO Auto-generated method stub 
    super.onListItemClick(l, v, position, id); 
    String cheese = classes[position]; 
    try{ 
    Class ourclass = Class.forName("com.example.taekwondobuddy.util" + cheese); 
    Intent ourIntent = new Intent(Kicks.this, ourclass); 
    startActivity(ourIntent); 
    } catch(ClassNotFoundException e){ 
     e.printStackTrace(); 

    } 
    } 

} 

видео я пытаюсь играть

package com.example.taekwondobuddy.util; 

import android.app.Activity; 
import android.net.Uri; 
import android.os.Bundle; 
import android.widget.MediaController; 
import android.widget.VideoView; 

public class RoundhouseKick extends Activity { 
private VideoView mVideoView; 

@Override 
public void onCreate(Bundle icicle) { 
    super.onCreate(icicle); 
setContentView(R.layout.roundhousekick); 
mVideoView = (VideoView) findViewById(R.id.roundhousekick); 
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.roundhousekick)); 
mVideoView.setMediaController(new MediaController(this)); 
mVideoView.requestFocus(); 
} 

}

расположение XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<VideoView 
    android:id="@+id/roundhousekick" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

</LinearLayout> 

и манифест

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

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

    <application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
    android:name="com.example.taekwondobuddy.util.Menu" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.Tools" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

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

</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.Techniques" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

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

</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.Kicks" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 

</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.Counter" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 


</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.Time" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 


</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.Accelermeter" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 


</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.FrontKick" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 


</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.RoundhouseKick" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 


</activity> 
<activity 
    android:name="com.example.taekwondobuddy.util.AxeKick" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:label="@string/app_name" 
    android:theme="@style/FullscreenTheme" > 


</activity> 

</application> 

</manifest> 

Я думаю, что что-то не так с манифестом, но я не могу понять, что не так, любые идеи? Плюс видео в mp4, так что они находятся в нужном формате для андроид

ответ

1

Я думаю, вы просто пропустили одну маленькую вещь: точку

(.)

Смотрите на свой код здесь:

Class ourclass = Class.forName("com.example.taekwondobuddy.util" + cheese); 

вы не думаете, это должно быть так:

Class ourclass = Class.forName("com.example.taekwondobuddy.util." + cheese); 
+0

спасибо, что исправил его прямо вверх – user2809321

0

Try использовать:

mVideoView.start(); 
+0

попробовал, не работал – user2809321

Смежные вопросы