Toast.makeText(getBaseContext(), "Terimakasih....", Toast.LENGTH_LONG).show();
Create:
final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());//Login.this
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean("Registered", true);
editor.putString("kode_pegawai", kode_pegawai);
editor.apply();
Update:
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("kode_pemesanan", kode_pemesanan);
Get:
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());//customer.this
Boolean Registered = sharedPref.getBoolean("Registered", false);
if (!Registered){finish();}
else {
kode_customer = sharedPref.getString("kode_customer", "");
}
YOUTUBE:
How to get 3gp link of Youtube video: For example we have the link www.youtube.com/watch?v=Xprog0HC3aQ 1) open new tab in your browser and write: m.youtube.com/watch?v=VIDEO_ID&app=m 2) now change VIDEO_ID from above with your video id code (Xprog0HC3aQ) and the result should be: m.youtube.com/watch?v=Xprog0HC3aQ&app=m and press enter. 3) right click on your video and Copy Link Location. 4) the result: rtsp://r7—sn-4g57kue6.googlevideo.com/Ck0LENy73wIaRAmk3cJBg-iaXhMYDSANFC0k8JRWMOCoAUIJbXYtZ29vZ2xlSARSBXdhdGNoYKK205Ti2LaNVooBC2lZYlRtN201YTlRDA==/9EFB79E36D6A4191F3BF60D01A0AE429B5C9AA32.B774C6D2C0948C3A49A088F9F5CCCFBE34864B29/yt6/1/video.3gp This is what you use on Uri.parse. Watch the video tutorial how to play Youtube videos in Android with VideoView with Android Studio version 1.5:
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/begroun"
tools:context=".VideoView"
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:gravity="center">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
android:foreground="?selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="50dp">
<TextView
android:id="@+id/txtjudul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:textSize="28sp"
tools:ignore="MissingConstraints"
android:text="Presentasi"
android:layout_gravity="center"
android:textAlignment="center"/>
<RelativeLayout
android:id="@+id/layoutVid"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@id/txtjudul"
android:gravity="center"
tools:ignore="MissingConstraints"
android:background="@android:color/background_dark">
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<Button
android:id="@+id/btnback"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="-30dp"
android:background="@drawable/logo_home_biru"
android:layout_gravity="center"
android:onClick="back"/>
</LinearLayout>
</LinearLayout>
JAVA
package com.iak.belajar.asambasa;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.MediaController;
public class VideoView extends AppCompatActivity {
android.widget.VideoView videoV;
MediaController mc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_view);
videoV = findViewById(R.id.videoView);
mc = new MediaController(this);
Intent intent = getIntent();
String title = intent.getStringExtra("video");
switch (title){
case "vpresentasi":
String path1="android.resource://"+getPackageName()+"/"+R.raw.presentasi_video_instrumen;
//path1="rtsp://r4---sn-npoeene6.googlevideo.com/Cj0LENy73wIaNAmPXH9pbuVaCBMYESARFC3hOHlfMOCoAUIASARgy5n9j9WNzJ5eigELdjBsRkRYLVJ1ZWsM/54C228E664CACEE02A38601EF853CCEF0C154385.807944B86439375E612BD42999C527F5EDACDC27/yt8/1/video.3gp";
videoV.setVideoURI(Uri.parse(path1));
break;
default:
break;
}
videoV.setMediaController(mc);
mc.setAnchorView(videoV);
videoV.start();
videoV.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
Intent intent = new Intent(VideoView.this, MainActivity.class);
startActivity(intent);
}
});
}
public void back(View view){
MediaPlayer klik = new MediaPlayer().create(this, R.raw.clik);
klik.start();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
startService(new Intent(getApplicationContext(), MyService.class));
}
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
startService(new Intent(getApplicationContext(), MyService.class));
}
}
ATAU:
android.widget.VideoView videoView = findViewById(R.id.videoplay);
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri=Uri.parse("rtsp://r7---sn-4g57kue6.googlevideo.com/Ck0LENy73wIaRAmk3cJBg-iaXhMYDSANFC3u0pRWMOCoAUIJbXYtZ29vZ2xlSARSBXdhdGNoYIaluaTkzciOVooBCzVxRjNraG5XcXdnDA==/D693A8E7577C3A29E60C292B42C9C87D7C25A565.762A63DC4CA0A028DA83256C6A79E5F160CBEDA3/yt6/1/video.3gp");
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
Video = https://youtu.be/BYJcMZtHDag
Mobile =https://m.youtube.com/watch?v=BYJcMZtHDag&app=m
RTSP =
rtsp://r3---sn-npoe7ne6.googlevideo.com/Cj0LENy73wIaNAmoDUebMVyCBRMYESARFC1SNnlfMOCoAUIASARgy5n9j9WNzJ5eigELdjBsRkRYLVJ1ZWsM/3106EFC698A86E21C8DDEAECBBF2FF66A382AC42.5547FD412BD275DD9ED11A1D179863D04012CBC5/yt8/1/video.3gp
Tidak ada komentar:
Posting Komentar