App Name

RecallCMS

Greeting Prefix

Auto

Learner Name

Aspirant

Home Subtitle

Spaced Repetition (SM-2) Master PYQ Decks

AdSense Publisher ID

ca-pub-0000000000000000

AdSense Auto Ads (ON or OFF)

OFF

Rest Stop Ad Slot ID

1234567890

Home and Game Page Ad Slot ID

0987654321

Default Batch Size

20

Thursday, March 12, 2020

YouTube Videos List in Sketchware

Improved app on this topic
https://www.sketchwarehelp.com/2020/03/create-list-of-youtube-videos-with.html?m=1

To display a list of YouTube Videos on a page, we can create multiple WebViews programmatically and add them to a Linear vertical in a ScrollView. Follow the steps given below.

1. In VIEW area of main.xml add a ScrollView with padding 0. Inside ScrollView add a LinearV linear1.

2. Add a Map List urlList, and a Number variable n.

3. Add a RequestNetwork component rn.
This will add INTERNET permissions in AndroidManifest.xml.

4. In onCreate event:
a. Add items to the list with key 'url'.

Here add the videos in html iframe codes.
<html>
<iframe width=100% height=100% src="https://www.youtube.com/embed/abIuko6FM3M" frameborder="0" allowfullscreen>
</iframe>
</html>

Note that video URL should be as shown above:
https://www.youtube.com/embed/( VIDEO ID)

b. Then use a repeat block. Repeat for length of List urlList.

c. Inside repeat block, use an add source directly block and put following codes.
// Create a WebView programmatically.
WebView webView = new WebView(MainActivity.this);
// Create new LayoutParams, set it's margins and set it as LayoutParams of WebView.
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int)getDip(200));
lp.setMargins(0, 16, 0, 16);
webView.setLayoutParams(lp);

// For WebView enable JavaScript and add WebViewClient and WebChromeClient.
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webView.setWebViewClient(new WebViewClient());

webView.setWebChromeClient(new CustomWebClient());
// In WebView load url by getting data from urlList, and add WebView to linear1.
webView.loadUrl("data:text/html, " + urlList.get((int)n).get("url").toString());

linear1.addView(webView);

d. After this, inside repeat block, use Number variable n increase 1.

5. Create a more block extra.

6. In the more block extra, use an add source directly blocks and put codes to define a new WebChromeClient class with name CustomWebClient. This will enable fullscreen mode for the YouTube videos.
}

public class CustomWebClient extends WebChromeClient {
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout frame;

// Initially mOriginalOrientation is set to Landscape
private int mOriginalOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
private int mOriginalSystemUiVisibility;

// Constructor for CustomWebClient
public CustomWebClient() {}

public Bitmap getDefaultVideoPoster() {
if (MainActivity.this == null) {
return null; }
return BitmapFactory.decodeResource(MainActivity.this.getApplicationContext().getResources(), 2130837573); }

public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback viewCallback) {
if (this.mCustomView != null) {
onHideCustomView();
return; }
this.mCustomView = paramView;
this.mOriginalSystemUiVisibility = MainActivity.this.getWindow().getDecorView().getSystemUiVisibility();
// When CustomView is shown screen orientation changes to mOriginalOrientation (Landscape).
MainActivity.this.setRequestedOrientation(this.mOriginalOrientation);
// After that mOriginalOrientation is set to portrait.
this.mOriginalOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
this.mCustomViewCallback = viewCallback; ((FrameLayout)MainActivity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1)); MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
}

public void onHideCustomView() {
((FrameLayout)MainActivity.this.getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
// When CustomView is hidden, screen orientation is set to mOriginalOrientation (portrait).
MainActivity.this.setRequestedOrientation(this.mOriginalOrientation);
// After that mOriginalOrientation is set to landscape.
this.mOriginalOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;
}
}

{

7. Save and run the project.

No comments:

Home
⚡ 0d
Good Morning
Aspirant

Spaced Repetition (SM-2) Master PYQ Decks

Loading Master PYQ Decks...

Free Active Recall & Spaced Repetition for Competitive Exams

Practice verified Previous Year Questions (PYQs) and speed calculation drills for SSC CGL, CHSL, MTS, UPSSSC PET, RRB NTPC, Group D, CTET, and State PSC exams. Our SuperMemo-2 (SM-2) engine schedules each flashcard right before you forget it and saves progress offline on your device.

30s
MASTER DECK
Question reference graphic
Answer & Explanation
Tap anywhere to reveal answer
Practice Games

Select a practice game page to start playing

Batch Complete!

Great work finishing this batch.

0
Reviewed
0
Memorized
0
Remaining
Stats & Backup

Memory Telemetry

0
Tracked Cards
0
Due Today
2.50
Avg Ease
0
Starred PYQs

Offline Progress Backup

Export or restore your IndexedDB spaced-repetition intervals as a portable JSON file.

Page

Loading Page...