Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
Research-Project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jayakody J.A.D.K.A - IT19114040
Research-Project
Commits
4251af72
Commit
4251af72
authored
Apr 25, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introductory Videos for games - Code Fix
parent
de7c1b0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
133 deletions
+79
-133
app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoLandscapeActivity.java
...assessment/videos/IntroductoryVideoLandscapeActivity.java
+44
-28
app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoPortraitActivity.java
...nassessment/videos/IntroductoryVideoPortraitActivity.java
+34
-105
build.gradle
build.gradle
+1
-0
No files found.
app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoLandscapeActivity.java
View file @
4251af72
...
...
@@ -4,7 +4,13 @@ import android.content.Intent;
import
android.media.MediaPlayer
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.widget.MediaController
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.VideoView
;
...
...
@@ -17,19 +23,25 @@ import com.anuththara18.attentionassessment.focused.AnimalChoosingActivity;
import
com.anuththara18.attentionassessment.focused.FocusedAttentionGame1
;
import
com.anuththara18.attentionassessment.focused.FocusedAttentionGame2
;
import
com.anuththara18.attentionassessment.home.MainFragment
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
import
com.anuththara18.attentionassessment.map.Map1Activity
;
import
com.anuththara18.attentionassessment.map.Map2Activity
;
import
com.anuththara18.attentionassessment.selective.SelectiveAttentionGame1
;
import
com.anuththara18.attentionassessment.sustained.BirdChoosingActivity
;
public
class
IntroductoryVideoLandscapeActivity
extends
AppCompatActivity
{
String
video
Url
=
"https://media.geeksforgeeks.org/wp-content/uploads/20201217192146/Screenrecorder-2020-12-17-19-17-36-828.mp4?_=1"
;
String
video
Str
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_introductory_video
);
TextView
skip
=
findViewById
(
R
.
id
.
skip
);
skip
.
setText
(
LanguageSetter
.
getresources
().
getString
(
R
.
string
.
skip
));
/*
// finding videoview by its id
VideoView videoView = findViewById(R.id.videoView);
...
...
@@ -40,35 +52,11 @@ public class IntroductoryVideoLandscapeActivity extends AppCompatActivity {
videoUrl = "";
}
// Uri object to refer the
// resource from the videoUrl
Uri
uri
=
Uri
.
parse
(
videoUrl
);
// sets the resource from the
// videoUrl to the videoView
videoView
.
setVideoURI
(
uri
);
// creating object of
// media controller class
MediaController
mediaController
=
new
MediaController
(
this
);
// sets the anchor view
// anchor view for the videoView
mediaController
.
setAnchorView
(
videoView
);
// sets the media player to the videoView
mediaController
.
setMediaPlayer
(
videoView
);
// sets the media controller to the videoView
videoView
.
setMediaController
(
mediaController
);
*/
// starts the video
videoView
.
start
();
videoView
.
setOnCompletionListener
(
new
MediaPlayer
.
OnCompletionListener
()
{
skip
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onCompletion
(
MediaPlayer
mp
)
{
//Toast.makeText(getApplicationContext(), "Video completed", Toast.LENGTH_LONG).show();
public
void
onClick
(
View
view
)
{
if
(
MainFragment
.
game
.
equals
(
"focused"
))
{
if
(
Map1Activity
.
level
==
1
){
startActivity
(
new
Intent
(
getApplicationContext
(),
FocusedAttentionGame2
.
class
));
...
...
@@ -86,6 +74,34 @@ public class IntroductoryVideoLandscapeActivity extends AppCompatActivity {
}
});
if
(
MainFragment
.
game
.
equals
(
"focused"
))
{
if
(
Map1Activity
.
level
==
1
||
Map1Activity
.
level
==
2
)
{
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
else
if
(
Map1Activity
.
level
==
5
){
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
}
else
if
(
MainFragment
.
game
.
equals
(
"alternating"
))
{
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
Log
.
i
(
"*********************************************************Video"
,
"Video Playing...."
);
WebView
mWebView
=(
WebView
)
findViewById
(
R
.
id
.
videoView
);
int
height
=
2
;
mWebView
.
setWebViewClient
(
new
WebViewClient
()
{
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
return
false
;
}
});
WebSettings
ws
=
mWebView
.
getSettings
();
ws
.
setJavaScriptEnabled
(
true
);
mWebView
.
loadData
(
videoStr
,
"text/html"
,
"utf-8"
);
}
}
\ No newline at end of file
app/src/main/java/com/anuththara18/attentionassessment/videos/IntroductoryVideoPortraitActivity.java
View file @
4251af72
...
...
@@ -10,11 +10,14 @@ import android.graphics.Bitmap;
import
android.media.MediaPlayer
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.webkit.DownloadListener
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.widget.MediaController
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.VideoView
;
...
...
@@ -23,84 +26,30 @@ import com.anuththara18.attentionassessment.dividedattention.DividedAttentionGam
import
com.anuththara18.attentionassessment.focused.AnimalChoosingActivity
;
import
com.anuththara18.attentionassessment.focused.FocusedAttentionGame1
;
import
com.anuththara18.attentionassessment.home.MainFragment
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
import
com.anuththara18.attentionassessment.map.Map1Activity
;
import
com.anuththara18.attentionassessment.map.Map2Activity
;
import
com.anuththara18.attentionassessment.selective.SelectiveAttentionGame1
;
import
com.anuththara18.attentionassessment.sustained.BirdChoosingActivity
;
import
com.google.android.youtube.player.YouTubeInitializationResult
;
import
com.google.android.youtube.player.YouTubePlayer
;
import
com.google.android.youtube.player.YouTubePlayerView
;
public
class
IntroductoryVideoPortraitActivity
extends
AppCompatActivity
{
//String videoUrl;
String
videoUrl
=
"https://1drv.ms/v/s!AvtsEIqJweWzmFqPURb36VGZZJpp"
;
//String videoUrl = "https://drive.google.com/file/d/1Qt8C8Ucf0icgnLYdBSfhThm1nQbatGDa/view?usp=sharing";
String
videoStr
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_introductory_video
);
/*
if (MainFragment.game.equals("focused")) {
videoUrl = "https://media.geeksforgeeks.org/wp-content/uploads/20201217192146/Screenrecorder-2020-12-17-19-17-36-828.mp4?_=1";
}
else if (MainFragment.game.equals("divided")) {
videoUrl = "https://1drv.ms/v/s!AvtsEIqJweWzmFqPURb36VGZZJpp";
}
else if (MainFragment.game.equals("selective")) {
videoUrl = "";
}
else if (MainFragment.game.equals("sustained")) {
videoUrl = "";
}
*/
// initialising the web view
WebView
wv
=
(
WebView
)
findViewById
(
R
.
id
.
videoView
);
// add your link here
wv
.
loadUrl
(
"https://drive.google.com/file/d/1Qt8C8Ucf0icgnLYdBSfhThm1nQbatGDa/view?usp=sharing"
);
//wv.loadUrl("https://1drv.ms/v/s!AvtsEIqJweWzmFqPURb36VGZZJpp");
wv
.
setWebViewClient
(
new
Client
());
WebSettings
ws
=
wv
.
getSettings
();
// Enabling javascript
ws
.
setJavaScriptEnabled
(
true
);
wv
.
getSettings
().
setJavaScriptCanOpenWindowsAutomatically
(
true
);
wv
.
clearCache
(
true
);
wv
.
clearHistory
();
// download manager is a service that can be used to handle downloads
wv
.
setDownloadListener
(
new
DownloadListener
()
{
@Override
public
void
onDownloadStart
(
String
url
,
String
s1
,
String
s2
,
String
s3
,
long
l
)
{
DownloadManager
.
Request
req
=
new
DownloadManager
.
Request
(
Uri
.
parse
(
url
));
req
.
setNotificationVisibility
(
DownloadManager
.
Request
.
VISIBILITY_VISIBLE_NOTIFY_COMPLETED
);
DownloadManager
dm
=
(
DownloadManager
)
getSystemService
(
DOWNLOAD_SERVICE
);
dm
.
enqueue
(
req
);
Toast
.
makeText
(
IntroductoryVideoPortraitActivity
.
this
,
"Downloading...."
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
/*
TextView
skip
=
findViewById
(
R
.
id
.
skip
);
skip
.
setText
(
LanguageSetter
.
getresources
().
getString
(
R
.
string
.
skip
));
VideoView videoView = findViewById(R.id.videoView);
Uri uri = Uri.parse(videoUrl);
videoView.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
mediaController.setMediaPlayer(videoView);
videoView.setMediaController(mediaController);
videoView.start();
*/
/*
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
skip
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public void onCompletion(MediaPlayer mp) {
//Toast.makeText(getApplicationContext(), "Video completed", Toast.LENGTH_LONG).show();
public
void
onClick
(
View
view
)
{
if
(
MainFragment
.
game
.
equals
(
"focused"
))
{
if
(
Map1Activity
.
level
==
3
){
startActivity
(
new
Intent
(
getApplicationContext
(),
AnimalChoosingActivity
.
class
));
...
...
@@ -120,57 +69,37 @@ public class IntroductoryVideoPortraitActivity extends AppCompatActivity {
}
}
});
*/
}
private
class
Client
extends
WebViewClient
{
// on page started load start loading the url
@Override
public
void
onPageStarted
(
WebView
view
,
String
url
,
Bitmap
favicon
)
{
super
.
onPageStarted
(
view
,
url
,
favicon
);
if
(
MainFragment
.
game
.
equals
(
"focused"
))
{
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
// load the url of our drive
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
view
.
loadUrl
(
url
);
return
true
;
else
if
(
MainFragment
.
game
.
equals
(
"divided"
))
{
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
@Override
public
void
onPageFinished
(
WebView
view
,
String
url
)
{
super
.
onPageFinished
(
view
,
url
);
else
if
(
MainFragment
.
game
.
equals
(
"selective"
))
{
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
else
if
(
MainFragment
.
game
.
equals
(
"sustained"
))
{
videoStr
=
"<html><body><iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/9n7kxFr-nBA\" frameborder=\"0\" allowfullscreen></iframe></body></html>"
;
}
public
void
onReceivedError
(
WebView
webView
,
int
errorCode
,
String
description
,
String
failingUrl
)
{
// if stop loading
try
{
webView
.
stopLoading
();
}
catch
(
Exception
e
)
{
}
Log
.
i
(
"*********************************************************Video"
,
"Video Playing...."
);
WebView
mWebView
=(
WebView
)
findViewById
(
R
.
id
.
videoView
);
if
(
webView
.
canGoBack
())
{
webView
.
goBack
();
int
height
=
2
;
mWebView
.
setWebViewClient
(
new
WebViewClient
()
{
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
return
false
;
}
});
WebSettings
ws
=
mWebView
.
getSettings
();
ws
.
setJavaScriptEnabled
(
true
);
mWebView
.
loadData
(
videoStr
,
"text/html"
,
"utf-8"
);
// if loaded blank then show error
// to check internet connection using
// alert dialog
webView
.
loadUrl
(
"about:blank"
);
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
IntroductoryVideoPortraitActivity
.
this
).
create
();
alertDialog
.
setTitle
(
"Error"
);
alertDialog
.
setMessage
(
"Check your internet connection and Try again."
);
alertDialog
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
"Try Again"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
finish
();
startActivity
(
getIntent
());
}
});
alertDialog
.
show
();
super
.
onReceivedError
(
webView
,
errorCode
,
description
,
failingUrl
);
}
}
}
\ No newline at end of file
build.gradle
View file @
4251af72
...
...
@@ -6,6 +6,7 @@ buildscript {
}
dependencies
{
classpath
"com.android.tools.build:gradle:4.1.3"
classpath
'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment