Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > Android ขอคำแนะนำการใช้ VideoView เวลากดปุ่มไปหน้าถัดไปแล้ว อยากให้แสดงวีดีโอในส่วนของหน้าถัดไปเลย



 

Android ขอคำแนะนำการใช้ VideoView เวลากดปุ่มไปหน้าถัดไปแล้ว อยากให้แสดงวีดีโอในส่วนของหน้าถัดไปเลย

 



Topic : 122376



โพสกระทู้ ( 9 )
บทความ ( 0 )



สถานะออฟไลน์




ขอคำแนะนำการใช้ VideoView ครับ คือ เวลากดปุ่มไปหน้าถัดไปแล้ว อยากให้แสดงวีดีโอในส่วนของหน้าถัดไปเลย แต่ตอนนี้วีดีโอของหน้าแรกมาแสดงซ้อน

Code (Android-Java)
Button btn1 = (Button)findViewById(R.id.button);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final VideoView myVideoV = (VideoView)findViewById(R.id.videoView);
                myVideoV.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.a1));
                myVideoV.setMediaController(new android.widget.MediaController(Main2Activity.this));
                myVideoV.requestFocus();
                myVideoV.start();
            }
        });

        Button btn2 = (Button)findViewById(R.id.button4);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final VideoView myVideoV = (VideoView) findViewById(R.id.videoView1);
                myVideoV.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.f1));
                myVideoV.setMediaController(new android.widget.MediaController(Main2Activity.this));
                myVideoV.requestFocus();
                myVideoV.start();
            }
        });


แสดงวีดีโอ



Tag : Mobile, Android, Mobile









ประวัติการแก้ไข
2016-04-08 23:23:17
2016-04-08 23:29:31
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-04-08 23:19:13 By : NongNong View : 980 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (Android-Java)
final VideoView myVideoV = (VideoView)findViewById(R.id.videoView);


ประกาศตัวนี้ไว้บนสุด แล้วใช้ myVideoV ตัวเดียวกันครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-04-11 11:16:00 By : mr.win
 


 

No. 2



โพสกระทู้ ( 9 )
บทความ ( 0 )



สถานะออฟไลน์


ใช้ VideoView วางใน ViewAnimator ครับ หรือมีวิธีอื่นแนะนำไหมครับ ที่จะสร้างปุ่ม Next เพื่อจะคลิกไปที่วีดีโอถัดไป (ทำกับรูปภาพแล้วใช้งานได้ เลยลองเอามาใช้กับวีดีโอ ครับ) สามารถทำแบบนี้ได้ไหม

Code (Android-Java)
public class Main2Activity extends AppCompatActivity {
    ViewAnimator va;
  //  MediaPlayer myVideoV;
    final VideoView myVideoV = (VideoView)findViewById(R.id.videoView);

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

        va = (ViewAnimator) findViewById(R.id.viewAnimator);

        final Animation in = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in);
        final Animation out = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in);


        final Button btn1 = (Button) findViewById(R.id.button2);
        btn1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                va.setInAnimation(in);
                va.showPrevious();

            }
        });

        Button btn2 = (Button) findViewById(R.id.button3);
        btn2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                va.setInAnimation(out);
                va.showNext();

            }
        });

button();

    }   //end onCreate


            public void button() {


        Button btn1 = (Button)findViewById(R.id.button);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //final VideoView myVideoV = (VideoView)findViewById(R.id.videoView);
                myVideoV.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.a1));
                myVideoV.setMediaController(new android.widget.MediaController(Main2Activity.this));
                myVideoV.requestFocus();
                myVideoV.start();


            }
        });

        Button btn2 = (Button)findViewById(R.id.button4);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              //  final VideoView myVideoV = (VideoView) findViewById(R.id.videoView1);
                myVideoV.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.f1));
                myVideoV.setMediaController(new android.widget.MediaController(Main2Activity.this));
                myVideoV.requestFocus();
                myVideoV.start();

            }
        });

            }
}



#Activity
Code (Android-Java)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.nipon.app.testvdio.Main2Activity">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:weightSum="1">

        <ViewAnimator
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/viewAnimator"
            android:layout_gravity="center_horizontal"
            android:layout_weight="0.94" >


            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:weightSum="1">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal">

                    <VideoView
                        android:layout_width="match_parent"
                        android:layout_height="332dp"
                        android:id="@+id/videoView" />
                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Play"
                    android:id="@+id/button"
                    android:layout_gravity="center_horizontal" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="หน้า1"
                    android:id="@+id/textView"
                    android:textSize="30dp"
                    android:layout_gravity="center_horizontal" />
            </LinearLayout>
            //-------------------------------
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:weightSum="1">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal">

                    <VideoView
                        android:layout_width="match_parent"
                        android:layout_height="332dp"
                        android:id="@+id/videoView1" />
                </LinearLayout>

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Play"
                    android:id="@+id/button4"
                    android:layout_gravity="center_horizontal" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="หน้า2"
                    android:id="@+id/textView1"
                    android:textSize="30dp"
                    android:layout_gravity="center_horizontal" />
            </LinearLayout>
            //-------------------------------

        </ViewAnimator>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal">

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="&lt;&lt;"
                android:id="@+id/button2" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=">>"
                android:id="@+id/button3" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>



ประวัติการแก้ไข
2016-04-12 21:16:02
2016-04-19 10:17:17
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-04-12 21:10:20 By : NongNong
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android ขอคำแนะนำการใช้ VideoView เวลากดปุ่มไปหน้าถัดไปแล้ว อยากให้แสดงวีดีโอในส่วนของหน้าถัดไปเลย
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่