بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]
پرسش و پاسخ

سورس کد گذاشتن ویدئو در برنامه و یه سوال داشتم

مدیریت گفتگو
jafar 12 سال پیش
آخرین تغییر: 12 سال پیش

سلام

یکی جواب بده چی کار کنم  چرخش گوشی باعث نشه فیلم از اول پخش بشه

اینم سورس کدش

 public class VideoTestActivity extends Activity {

    VideoView vv;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        vv = (VideoView) findViewById(R.id.videoView1);

        ///تنظیم آدرس ویدیو 
        vv.setVideoPath("android.resource://com.example.videotest/" + R.raw.beakhkh);
        /// افزودن یک کنترلر (در تصویر آخر کارش رو نشون دادم ) 
        vv.setMediaController(new MediaController(this));
        ///شروع فیلم و درخواست فکوس 

        vv.start();

    }

}

نظرات

مجتبی یگانه 12 سال پیش
شما این یه موضوع رو 4 نوع سوال مختلف ازش طرح کردید ، بهتر اینه که وقتی جوابی نمی گیرید ، لینک سوال رو به استاد ایمیل کنید ، تا یه وقت بهش اختصاص بده ، هرچند که اگر اینکار رو هم نکنید ، باز هم جواب میدن پس صبور باشید ، ضمنا شما دنبال دستوری باش که زمان فعلی اجرا شده از فیلم رو بر گردونه
jafar 12 سال پیش
باشه برادر
uncocoder 12 سال پیش
باید یکبار کد رو بنویسم، تست کنم، تا بتونم جواب قطعی بدم. یک علامت برای سئوالتون می زنم اما قول نمی دم زود جوابی ارسال کنم. چون هنوز بخش ویدئو و صدا تدوین نشده، من هم دو سال پیش از این کارا کردم، چیزی یادم نیست.
jafar 12 سال پیش
ممنون از لطفتون استاد

پاسخ‌ها 2

مجتبی یگانه 12 سال پیش

پاسخی سوال مشابه در لینک زیر درج شد موفق باشید

لینک سوال

نظرات

Borhani 12 سال پیش

این سورس تست کن عالیه

 /*
* Copyright (c) 2013, Intel Corporation
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

package com.example.videoviewsample;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.database.Cursor;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.Menu;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoViewSample extends Activity
{

private VideoView mVideoView;

private MediaController mController;

MediaMetadataRetriever mMetadataRetriever;



@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mVideoView = (VideoView) findViewById(R.id.myplaysurface);

mMetadataRetriever = new MediaMetadataRetriever();

Intent intent = new Intent();

intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent, "Video File to Play"), 0);
}



@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
}



public void startPlayback(String videoPath)
{
mMetadataRetriever.setDataSource(videoPath);

Uri uri = Uri.parse(videoPath);
mVideoView.setVideoURI(uri);

mController = new MediaController(this, false);
mVideoView.setMediaController(mController);
mVideoView.requestFocus();
mVideoView.start();
}



@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.video_view_sample, menu);

return true;
}



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == 0)
{
if (resultCode == RESULT_OK)
{
Uri sourceUri = data.getData();
String source = getPath(sourceUri);

startPlayback(source);
}
}
}



public String getPath(Uri uri)
{
Cursor cursor = getContentResolver().query(uri, null, null, null, null);

if (cursor == null)
{
return uri.getPath();
} else
{
cursor.moveToFirst();

int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);

return cursor.getString(idx);
}
}
}

نظرات


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .