Trending February 2024 # Display Youtube, Vimeo, And Dailymotion Videos In Your Android Apps # Suggested March 2024 # Top 7 Popular

You are reading the article Display Youtube, Vimeo, And Dailymotion Videos In Your Android Apps updated in February 2024 on the website Hatcungthantuong.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Display Youtube, Vimeo, And Dailymotion Videos In Your Android Apps

Including one or more video files in your project’s “resources” directory.

Embedding content from a video-sharing website.

YouTube, using the YouTube Android Player API.

Dailymotion, using the Dailymotion Player SDK for Android.

Vimeo, using Android’s built-in WebView component.

Although we’ll be sticking to YouTube, Dailymotion and Vimeo, you should be able to embed content from any video-sharing platform, using the platform’s own API or SDK, or Android’s WebView component. Just because your favorite video-sharing website isn’t included in this list, doesn’t mean you can’t use the techniques discussed in this article!

Playing a video with VideoView

Displaying local videos, with VideoView

In this section, we’ll create an application that displays a video clip, which is stored locally in our application’s “res” directory.

We’ll display this video using Android’s VideoView class, and provide the user with a set of media controls, via Android’s MediaController class. The MediaController class includes play, pause, rewind and fast-forward controls, plus a progress slider that’ll allow the user to skip to a specific point within the video.

Getting started: Creating a “raw” directory

You’ll need to add the video file to your application’s “res/raw” directory. Android projects don’t contain this directory by default, so let’s create it now:

In the subsequent window, open the “Resource type” dropdown and select “raw.”

The “Directory name” should update to “raw” automatically, but if it doesn’t then you’ll need to rename it manually.

Android supports a range of video formats; you can either use one of your own videos or download a compatible video from a website that offers free stock footage, such as Sample Videos.

Once you have a video file, add it to your application by dragging and dropping it into the “raw” directory.

Add a VideoView to your UI

Next, we need to add a VideoView to our application’s user interface. This VideoView widget implements much of the basic behavior required to play a video.

In our VideoView widget, I’m setting both “layout_width” and “layout_height” to 0dp, as this allows the size of the VideoView to be calculated dynamically, based on the dimensions of the video we want it to display.

Code

<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" <VideoView android:id="@+id/videoView" android:layout_width="0dp" android:layout_height="0dp" android:layout_margin="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="4:3" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"

Now, we need to retrieve the path to our local video; play the clip automatically at startup, and give the user a way to interact with the video.

1. Retrieve the video file

Open your project’s MainActivity class, and add a constant to represent the video file:

Code

private static final String VIDEO = "samplevideo";

Next, define the URI that our VideoView widget should play, using the getMedia() and setVideoUri() methods:

Code

private void initializePlayer() { Uri videoUri = getMedia(VIDEO); videoView.setVideoURI(videoUri); }

We then need to create a getMedia() method that takes the name of the video file, in the form of a string, and then converts it into a URI object representing the path to this file:

Code

private Uri getMedia(String mediaName) { if (URLUtil.isValidUrl(mediaName)) { return Uri.parse(mediaName);

Note that the string and returned URI don’t include the video’s extension.

2. Play the video

Next, we load the video each time onStart() is called, and set the video playing automatically, using the start() method:

Code

@Override protected void onStart() { super.onStart(); initializePlayer(); videoView.start(); } 3. Cleaning up

Playing a video puts significant strain on the system, so it’s important to release all the resources held by VideoView, as soon as they’re no longer required.

Since our app is fairly straightforward, we just need to stop the video and release all of its resources, but in more complicated applications this step might involve unregistering multiple listeners.

I’m going to create a releasePlayer() method, and call the stopPlayback() method on the VideoView:

Code

private void releasePlayer() { videoView.stopPlayback(); }

We can then override the onStop() method and call releasePlayer():

Code

@Override protected void onStop() { super.onStop(); releasePlayer();

Code

@Override protected void onPause() { super.onPause(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { videoView.pause(); } } 4. Add playback controls

Currently, there’s no way for the user to pause, rewind or otherwise interact with the video, so we need to add some media controls, using Android’s MediaController class.

In the following snippet, we’re instantiating a MediaController programmatically, and then attaching it to our VideoView using setMediaPlayer(). Finally, we’re informing the VideoView about the new MediaController, using the setMediaController() method:

Code

MediaController controller = new MediaController(this); controller.setMediaPlayer(videoView); videoView.setMediaController(controller); } ViewView and MediaController: Completed code

After adding all the above to our MainActivity, your code should look something like this:

Code

import android.support.v7.app.AppCompatActivity; import android.os.Build; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; import android.net.Uri; import android.webkit.URLUtil; public class MainActivity extends AppCompatActivity { private static final String VIDEO = "samplevideo"; private VideoView videoView; private int currentPosition = 0; private static final String PLAYBACK = "playback"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); videoView = findViewById(R.id.videoView); if (savedInstanceState != null) { currentPosition = savedInstanceState.getInt(PLAYBACK); } MediaController controller = new MediaController(this); controller.setMediaPlayer(videoView); videoView.setMediaController(controller); } @Override protected void onStart() { super.onStart(); initializePlayer(); videoView.start(); } @Override protected void onPause() { super.onPause(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { videoView.pause(); } } @Override protected void onStop() { super.onStop(); releasePlayer(); } private void initializePlayer() { Uri videoUri = getMedia(VIDEO); videoView.setVideoURI(videoUri); } private void releasePlayer() { videoView.stopPlayback(); } private Uri getMedia(String mediaName) { if (URLUtil.isValidUrl(mediaName)) { return Uri.parse(mediaName); } else { return Uri.parse("android.resource://" + getPackageName() + "/raw/" + mediaName); } } } Testing your VideoView project

How to embed YouTube videos in your Android app

Embedding a video file within your application is a great way to ensure that video is always available, regardless of the device’s Internet connection. However, embedding multiple large, high-resolution videos in your app is also a great way to increase the size of your APK!

If you’re concerned about APK size, or your application includes videos that are nice-to-have added extras, then you may want to publish those videos to an online platform and then stream them through your application at runtime.

When it comes to publishing videos online, there’s one website that instantly springs to mind, so in this section I’ll show you how to embed any YouTube video in your app, using the YouTube Android Player API client library.

Retrieving a YouTube video’s ID Get your project’s SHA-1 fingerprint

In order to access the YouTube Android Player API, you’ll need to generate an API key with Android restrictions. This involves linking the API key to your project’s unique package name and certificate fingerprint (SHA-1).

You can retrieve your project’s SHA-1 fingerprint, via the Gradle Console:

Select the Gradle tab along the right-hand side of the Android Studio window.

Open the Gradle Console tab that appears towards the bottom-right of the screen.

The Gradle Console will open automatically. Find the SHA-1 value in this window, and make a note of it.

We’re using a debug certificate fingerprint, which is only suitable for testing an application. Before publishing an app, you should always generate a new API key based on that application’s release certificate.

Register with the Google API Console

Before you can use the YouTube Android Player API, you need to register your application in the Google API Console:

In the header, select the name of your current project (where the cursor is positioned in the following screenshot).

In the subsequent window, select “New project.”

In the left-hand menu, select “Credentials.”

Your API key will now appear in a popup, which includes a prompt to restrict this API key. Restricted keys are more secure, so unless you specifically require an unrestricted API key, opt to “Restrict key.”

On the subsequent screen, give your API key a distinctive name.

Select the “Android apps” radio button.

Copy/paste your project’s SHA-1 fingerprint into the subsequent section, and then enter your project’s package name (which appears at the top of every Java class file and in your project’s Manifest).

Download the YouTube Android Player API

Next, you’ll need to download the YouTube Android Player API client library. When using this library, it’s recommended that you enable ProGuard, to help keep your APK as lightweight as possible.

To add the YouTube library to your project:

Head over to the YouTube Android Player website, and download the latest version.

Unzip the subsequent zip file.

Open the newly-unzipped folder and navigate to its “libs” subfolder – it should contain a “YouTubeAndroidPlayerApi.jar” file.

In Android Studio, switch to the “Project” view.

Open your build.gradle file and add the YouTube library as a project dependency:

Code

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' implementation files('libs/YouTubeAndroidPlayerApi.jar') }

When prompted, sync your Gradle files.

Update your Manifest

If your application is going to display any online video content, then it’ll need access to the Internet.

Open your project’s Manifest and add the Internet permission:

Code

<activity android:name=".MainActivity"

You can display a YouTube video, using either:

YouTubePlayerView. If you want to use YouTubePlayerView in your layout, then you’ll need to extend YouTubeBaseActivity in that layout’s corresponding Activity class.

YouTubePlayerFragment. This is a fragment that contains a YouTubePlayerView. If you choose to implement a YouTubePlayerFragment, then you won’t have to extend from YouTubeBaseActivity.

I’ll be using YouTubePlayerView, so open your project’s “activity_main.xml” file, and add a YouTubePlayerView widget:

<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/YouTubePlayer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent"

Next, open your MainActivity and complete the following tasks:

1. Extend YouTubeBaseActivity

Since we’re using a YouTubePlayerView in our layout, we need to extend YouTubeBaseActivity:

Code

public class MainActivity extends YouTubeBaseActivity { 2. Initialize YouTube Player

We initialize the YouTube Player by calling initialize() and passing the API key we created earlier:

Code

YouTubePlayerView youTubePlayerView = (YouTubePlayerView) findViewById(R.id.YouTubePlayer); youTubePlayerView.initialize(YOUR_API_KEY, new YouTubePlayer.OnInitializedListener() { 3. Implement onInitializationSuccess and onInitializationFailure

Finally, we need to specify how our application should react, depending on whether the initialization is a success, or a failure. If the YouTube Player is initialized successfully, then we can load our video, by passing the unique video ID:

Code

public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) { youTubePlayer.loadVideo("hJLBcViaX8Q");

Next, we need to tell our application how it should handle failed initializations. I’m going to display a Toast:

Code

public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { Toast.makeText(MainActivity.this, "An error occurred", Toast.LENGTH_SHORT).show(); } Playing a YouTube video: Completed code

Add all the above to your MainActivity, and you should end up with something like this:

Code

import android.os.Bundle; import android.widget.Toast; import com.google.android.youtube.player.YouTubeBaseActivity; import com.google.android.youtube.player.YouTubeInitializationResult; import com.google.android.youtube.player.YouTubePlayer; import com.google.android.youtube.player.YouTubePlayerView; public class MainActivity extends YouTubeBaseActivity { public static final String YOUR_API_KEY = "YOUR_API_KEY_HERE"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); YouTubePlayerView youTubePlayerView = (YouTubePlayerView) findViewById(R.id.YouTubePlayer); youTubePlayerView.initialize(YOUR_API_KEY, new YouTubePlayer.OnInitializedListener() { @Override public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) { youTubePlayer.loadVideo("hJLBcViaX8Q"); } @Override public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { Toast.makeText(MainActivity.this, "An error occurred", Toast.LENGTH_SHORT).show(); } }); } } Testing the YouTube Android Player API Display Dailymotion content in a WebView

Get the Dailymotion video ID Adding the Dailymotion SDK

Since we’re using the Dailymotion SDK, we need to declare it as a project dependency. Open your project’s build.gradle file, and add the following:

Code

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.dailymotion.dailymotion-sdk-android:sdk:0.1.29' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' Requesting Internet access

Once again, we’re streaming content from the World Wide Web, so our project requires the Internet permission:

Code

<activity android:name=".MainActivity"

Code

<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" <com.dailymotion.android.player.sdk.PlayerWebView android:id="@+id/dailymotionPlayer" android:layout_width="match_parent"

Now we’ve implemented the PlayerWebView widget, we need to configure the player in our corresponding Activity class.

Open your MainActivity, and start by getting a reference to the PlayerWebView:

Code

dailyMotionPlayer= (PlayerWebView) findViewById(R.id.dailymotionPlayer);

Then, call “dailyMotionPlayer.load” and pass it the video ID we retrieved earlier:

Code

dailyMotionPlayer.load("x71jlg3");

This gives us the following:

Code

import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.dailymotion.android.player.sdk.PlayerWebView; import java.util.HashMap; import java.util.Map; public class MainActivity extends AppCompatActivity { private PlayerWebView dailyMotionPlayer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dailyMotionPlayer= (PlayerWebView) findViewById(R.id.dailymotionPlayer); playerParams.put("key", "value"); dailyMotionPlayer.load("x71jlg3"); } Updating the Manifest

Since we’re streaming a video from the Internet, we need to add the Internet permission to our Manifest:

Code

<activity android:name=".MainActivity"

Next, let’s add a WebView to our app. We can either add the WebView to our Activity’s layout, or turn the entire Activity into a WebView, by implementing it in our application’s onCreate() method.

I’m going to add a WebView to our application’s layout:

<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" <WebView android:id="@+id/myWebView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent"

Once again, we need a video to display, but this time we’re not using a video ID:

Head over to Vimeo and choose a video that you want to use; I’ve opted for this winter time lapse.

Select the “Embed” icon; this will provide you with an embed code that should look something like this:

iframe. Specifies that we’re embedding another HTML page inside the current context.

src. The video’s path, so your app knows where to find this video.

width / height. The video’s dimensions.

frameborder. Whether to display a border around the video’s frame. The possible values are border (1) and no border (0).

allowfullscreen. This enables the video to be displayed in fullscreen mode.

I’m going to add this embed code to my project as a string, so you need to copy/paste this information into the following template:

In production, you’d typically experiment with various dimensions to see what delivers the best results, across as many different screen configurations as possible. However, to help keep this article from getting out of control, I’m just going to use the following, which should provide good results on your “typical” Android smartphone screen:

Now we’ve created our layout and have our HTML all ready to go, open your MainActivity and lets implement our WebView.

Start by adding the HTML string:

Code

webView.loadUrl(request.getUrl().toString());

JavaScript is disabled by default, so we’ll need to enable it in our WebView.

Every time you create a WebView, it’s automatically assigned a set of default WebSettings. We’ll retrieve this WebSettings object, using the getSettings() method, and then enable JavaScript, using setJavaScriptEnabled().

Code

WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true);

After adding all this to your MainActivity, your code should look something like this:

Code

import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); WebView webView = (WebView) findViewById(R.id.myWebView); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) { webView.loadUrl(request.getUrl().toString()); return true; } }); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webView.loadData(vimeoVideo, "text/html", "utf-8"); } } Testing your Vimeo app

You know the drill by now: install this project on a physical Android device or AVD. The WebView isn’t set to play automatically, so you’ll need to give the video a tap, to reveal Vimeo’s media controls. You can then play, pause, rewind and fast-forward the video, to make sure it’s functioning correctly.

Wrapping up

You're reading Display Youtube, Vimeo, And Dailymotion Videos In Your Android Apps

Vimeo Videos Won’t Play; Video Not Playing In Chrome!

YouTube and Vimeo are the two most popular video hosting platforms. While YouTube does not require you to log in to view the videos hosted on the site, Vimeo requires you to register to view HD content on their platform. It is still very popular among users, and many creators host their videos on the platform.

Some Windows 10 users have reported that Vimeo videos won’t play on their device when they open the site from Google Chrome. Here, I shall discuss how you can solve if videos won’t play on Chrome.

This can be annoying as you may be missing out on some important content on your device. Here are some of the simple methods that you can try to resolve the Chrome videos not playing error.

Many times users face this error due to an unstable network. If your network connection disconnected midway, the video may fail to load, and you will see videos not playing on your device.

First, try opening the webpage in another browser. If the webpage fails to load on other browsers as well, there is a possibility that there may be some error with your internet connectivity.

On nearly every kind of network, there is a timeout period, after which the connectivity throttles upon continued usage. Restarting your router and putting your device on Airplane mode and back, will reset the network, and the throttle should be over. This will clear the network errors, and you should be able to resolve the Google Chrome error.

On Windows, you can try clearing the DNS cache as well. To do that:

Open an elevated Command Prompt. To do this, open a Run window by pressing Win + R. Type cmd and press Ctrl + Shift + Enter to launch Command Prompt with administrative privileges.

ipconfig /flushdns

Wait for the confirmation message and then try loading your web pages again.

On your computer, open Google Chrome.

Visit the Vimeo page of the video that you want to play.

Locate Flash from the list of site settings available.

Choose Always allow on this site.

If your Vimeo videos won’t play error was being caused by improper permissions for flash, it should now be resolved.

If you have confirmed that only the Chrome browser is unable to play videos from Vimeo, it is possible that some broken extensions may be causing the error on your device.

The extensions by default are disabled in this mode, and you can confirm that the error was caused by some broken extension if you do not face this error anymore in Incognito mode.

Start by enabling the extensions one by one and check if the error persists.

If enabled, the hardware acceleration uses computer hardware specially made to perform some functions more efficiently than possible in software running on a general-purpose CPU.

If the hardware is used to smoothen the performance, the resources tangled in doing so can create compatibility problems and hence cause the video not playing in Chrome error.

Note: Post turning off hardware acceleration, you may see a bump in the CPU and other system resources usage. This is natural and shouldn’t bother much. If you see a drastic change, you can turn it back on.

Follow these steps to disable hardware acceleration in Chrome:

Open Google Chrome.

Select Settings.

Under the System subsection, locate Hardware Acceleration.

Turn the toggle towards off next to “Use hardware acceleration when available”.

Restart your browser.

After you restart your browser, you will see that the issue does not occur anymore.

The cache is the data stored on your device by various websites, to load data from them faster the next time you load the website. However, sometimes a mismatched cache data can cause all sorts of errors, and this error is one of them. To solve your Chrome won’t load pages error; clear all your Google Chrome data like cookies and cached images and files.

To clear Google Chrome data, press the Ctrl + Shift + Delete in a new tab to open the Clear browsing data dialog box. Here select All time from the Time range drop-down menu. Then select Clear data.

If all other solutions fail, you can try reinstalling Chrome as a last resort. A fresh install will reset all the broken files and settings, and form the data libraries again.

Uninstall the Chrome application from the Control panel. Then remove the residual files as well. To remove the residual files, you can use a third-party junk file cleaner like CCleaner.

Then download a fresh copy of the installer from the Google website (link) and run the installer.

Wait for the installer to finish.

Now check if the issue still persists.

So there you have it. Now you know how to resolve the Vimeo videos won’t play error using the one or a combination of the solutions provided above. Comment below if you found this useful, and tell us how you solved the ‘Chrome videos not playing’ error on your device.

5 Android Apps To Test Phone Display, Quality, Sensitivity

So Today I have brought you 5 Android Apps for checking your Smartphone’s Display quality and its sensitivity.

Screen Test

Screen Test is an app which looks simple yet is effective. You can use this app for finding the broken pixel on your Smartphone’s Display. For the app to work you can touch the screen at different places to change between modes.

Pros

This app can be directly installed on your Smartphone’s SD Card which allows you to save space on the Internal Storage of your Smartphone.

This app is completely Ads free.

Works great until your smartphone has ON-Screen buttons so in that case it doesn’t works on that particular area.

Screen Touch Test

Screen Touch Test is the next app which helps to check the Touch Sensitivity of your Smartphone. This is yet another simplistic app. In this app, it turns your whole display to dark black and then when to touch it with your fingers then a single pixel turns white which lets you know that the screen is registering your touch at that portion.

Pros

This app lets you check the touch sensitivity of your Smartphone’s Display.

It lets you discover the actual portion of your Touch Screen which isn’t registering the touch responses effectively.

The new users might get confused while thinking about how to exit this app.

Users could also find this app a bit boring.

Test Your Android

Finally an interesting app – Test Your Android. If the previous two apps seemed boring to you then this one might sound interesting due to its user friendly user interface. This is an all is one app which lets you perform an all round test of your smartphone, including tests like – Touch Screen test, Wi-Fi Test, Multi-Touch Test, GPS Test and much more.

Pros

This app has a really interesting User-Friendly User-Interface.

This app is capable to perform an all round test of your smartphone by testing its performance on all grounds.

In Some of the Tests like the Sound and Vibration tests, a few bugs are noticed.

Screen Resolution & Density

Our next app Screen Resolution & Density does exactly what is stated by its name. If you are searching for an app using which you could check your Smartphone’s Screen Resolution and calculated Pixels Per Inch then this is the app for you.

Pros

This app is very perfect in calculating your Smartphone’s Screen Resolution and Pixels Per Inch (i.e. Pixel Density).

The app does not tell you anything about touch sensitivity for a particular area on screen.

Display Tester

Display Tester is the last app in our list. If you are looking into an in-depth testing of your Smartphone’s Display screen then this app could do a lot for you. It could perform several tests like – Dead Pixel Test, Color Test, Gamma Calibration, Screen Viewing Angle Test and much more.

Pros

If you are looking for a Free app which could perform a series of in-depth test on your Smartphone’s Display Screen then you couldn’t get a better app than this one.

This app supports testing on all types of screen be it LCD, OLED or any other type of Screen.

The app is found to crash on certain Smartphones.

Conclusion

How To Track Youtube Videos In Google Analytics 4

So you want to learn how to track YouTube Videos? 

This post shows how to track YouTube videos that you embed on your site or that you share as links elsewhere. 

We will cover how to quantify the consumption of YouTube video content on your website and measure the performance of YouTube as a traffic source.

The topics we’ll focus on:

Let’s dive in!

How to Track YouTube Videos in Google Analytics

There are 2 ways to track embedded YouTube videos in Google Analytics. We’ll cover them both with a focus on GA4. 

You can simply enable the Video engagement option within Enhanced Measurement (which automatically tracks video interactions without any code).

You can configure your tracking in Google Tag Manager (recommended).

However, for this to work, all your embedded videos must have the JS API support enabled which requires a modification of your YouTube embedded code. 

Also, this first option will limit you to default thresholds (such as the video progress for any user viewing passed 10%, 25%, 50, and 75% of the video), which can get in the way of setting your thresholds. 

Consequently, Google Tag Manager is the option of choice for many marketers. Using GTM is best practice, as you have more control over your data. 

🚨 Note: We recommend using GTM. However, whichever option you choose, make sure not to use both at the same time. If you decide to use GTM, disable Video engagement in Enhanced Measurement to prevent duplicate data in your reports.

How do you track videos on GA4? (Enhanced Measurement)

This approach is suited for YouTube videos that are embedded on your website. 

GA4 Enhanced Measurement allows tracking common events without the need for any code implementation. Unfortunately, it isn’t a magic wand for YouTube video tracking. 

That is because you’ll need to add the enablejsapi parameter to the source URL of the video and set it to 1. This is how it looks exactly: enablejsapi=1.

Then select Embed. 

Start by typing the question mark (?) and then add the parameter to the code enablejsapi=1

How Do I Track a YouTube Video With Google Tag Manager

Let’s start by building a trigger in Google Tag Manager. 

For the Trigger configuration, select the YouTube Video trigger type. 

Follow our next setup. 

There are occasions where video tracking may not work and one solution is to select Add JavaScript API support to all YouTube videos. So, we’ll keep it checked just in case.

This is a common setup that works for most people. But, it can be modified. At this moment, you’ll have to ask yourself or your team what you want to achieve with this trigger and what you want to measure. 

Are there specific pages or videos that you want to track? 

If yes, then you can achieve it by selecting Some Videos for when the trigger should fire. 

Do you need to track the video progress in percentages or in time?

Is capturing Pause, Seeking, and Buffering important to you?

Given the way we watch videos online, these events are likely to multiply very quickly and populate your GA4 unnecessarily. Therefore, If these events aren’t critical for your measurement, you can leave this option unchecked.

Now that you have a trigger, make sure that you’ve enabled the GTM’s built-in video variables. These will provide additional information about tracked videos.

Follow these steps: Variables → Configure

In Configure Built-In Variables, scroll down to Videos and select all the variables.

You can test your trigger quickly by enabling the preview mode in Google Tag Manager. We will use the welcome video embedded on our demo shop website.

Let’s preview the page by enabling the preview mode in your GTM Workspace.

In Tag Assistant, add your page URL.

Play the video and skip to the end of the video, so we can see what data our trigger collects. 

In the debug interface, you should see 2 events in the left panel entitled YouTube Video. The first one fired when the video started playing, and the second was when the video was completed. 

Scroll down to Video Status and observe the value.

Let’s create a new Tag to send this information to Google Analytics. 

Select Google Analytics: GA4 Event and use your GA4 settings variable for the Configuration Tag. 

🚨 Note: If you’re not familiar with the process of creating GA4 events, check out our Google Analytics 4 tutorial for beginners. It’ll take you through setting up an account, how to use Google Tag Manager, and create events for GA4.

Let’s now name our tag.

Naming Convention for YouTube Video Tracking

You can name your event however you wish. 

It is, however, best practice to first consider using existing event names either recommended by Google (called Recommended Events) or those listed in Enhanced Measurements before coming up with your own.

Let’s take a look at Enhanced measurement because there you’ll find more details on Video Engagement and Google’s event naming structure. 

Google Analytics can natively track 3 different types of engagement:

video_start

video_progress

video_complete

The good news is that Google Tag Manager has a variable known as Video Status, which you saw earlier. This variable shows these statuses depending on whether a user started, progressed, or completed a video. 

So, instead of sending 3 events for each, your event will streamline all of them into one event with the current status of users. 

This is how you do it. In your tag, in the Event name, type the word video followed by an underscore: video_

Google names all its events in lowercase and uses underscores to separate words. You should follow this convention.

In Choose a variable, select the Video Status dataLayer variable.

Now your Event name will be the following: video_{{Video Status}}

You could consider the job done here. 

However, we’d like to add more details to the event we’re sending to GA4. These details are called parameters. 

What relevant details could you send to GA after users viewed a video? Again, we can get some inspiration from Google Analytics by looking at what parameters it tracks automatically with videos.

In the previous section, we looked at the Video Engagement section on the Enhanced measurement page. There you will not only see your option of video events but also the useful parameters that GA4 sends with it. 

These are:

video_current_time

video_duration

video_percent

video_provider

video_title

video_url

visible

We will use these to name our parameters. Choose those that will serve your measurement objectives. For our example, we will use all of them except for visible.

Copy and paste each into a separate row under Parameters.

Now we need to add their corresponding dynamic values. 

Luckily for us, these values also exist as variables in Google Tag Manager. They’re the same video variables we enabled when creating our trigger. 

Then select the Video Current Time dataLayer variable.

Repeat the process for each. You should end up with the following:

Name and save your tag. 

Testing YouTube Video Tracking in Google Tag Manager

This is what you can expect if your tag is fired properly.

To make sure everything works well on GA4’s side, head over to the DebugView in GA4. Here are the coming events. 

🚨 Note: All our parameters appear in the DebugView. However, to use them in your reports, you need to register them as custom dimensions. 

Let’s look at an example of how to register our tag’s parameters as custom dimensions. 

Copy a parameter. We will highlight and copy the Video title. 

In the Dimension name placeholder, write a relevant title. There is no naming convention here, so feel free to write your title any way you wish. 

Select Event for Scope. The Description box is optional. The most important step is what you add in the Event parameter. Paste the parameter you copied earlier. 

Here’s what everything should look like: 

These parameters will be ready within the next 24 hours in your GA4 reports. By then, you’ll be able to use them in your reports and your Explorations. 

UTM tracking consists of tagging your links by adding code to the end of your URL.

We designed a tool to help you tag your links fast with the support of our guide full of examples on how to use UTM tracking in the real world.

Lastly, you can evaluate your marketing efforts by determining how your YouTube channel compares to other traffic sources.

Google Analytics vs YouTube Analytics

We have often discussed the analytics features of Google Analytics for a good reason. It is the most popular analytics platform in the world. 

However, YouTube is owned by Google, and it comes as no surprise that its analytics capabilities are powerful and quite similar to those of Google Analytics.

YouTube offers robust and detailed reports about the views, engagement, traffic sources, and demographics of visitors to your channel. You can view these reports within YouTube Analytics. 

If you’re using YouTube as your main marketing channel, then its analytics are what you need to measure your success.

Now the question is – what’s the point of using Google Analytics to track YouTube videos?

There are a few reasons why you might want to use Google Analytics over YouTube’s native analytics. First, they are mostly all tied to understanding and measuring online behaviors outside of your YouTube channel.

Second, in today’s multi-touch marketing world, these reasons explain the need to have a global view of all your marketing efforts across different channels in one place for a global analysis. 

This is not limited to Google Analytics, but also other platforms like BigQuery for example. 

Google Analytics is a great option if you conduct a lot of your business through an online website because you likely don’t rely on YouTube as a primary marketing channel. 

You might want to track and uncover insights unavailable in YouTube’s analytics dashboard, such as tracking visits to a blog post or another piece of content that lives on your site but isn’t a video.

If the goal is to understand how visitors coming from YouTube interact with your site, how engaged they are once there, and how they convert, then you want to look at Google Analytics via YouTube video tracking. 

Google Analytics will help you also determine how YouTube as a channel holds up against other channels using attribution modeling. 

FAQ Can I use both Enhanced Measurement and Google Tag Manager for tracking YouTube videos simultaneously?

No, it is recommended to use either Enhanced Measurement or Google Tag Manager for tracking YouTube videos. Using both at the same time may result in duplicate data in your reports.

What is the recommended naming convention for YouTube video tracking events in Google Analytics?

It is recommended to use existing event names recommended by Google or those listed in Enhanced Measurement. Event names should be lowercase with words separated by underscores.

Summary

The next time you have a YouTube video you want to track, you’ll know exactly what to do. You can always come back and refer to this post. 

In the future, we’ll continue to post more ways to track other video-sharing platforms on your sites, so keep checking back.

Continue your learning journey and check out our handy guide on how to track site search in GA4.

How To Create Your Own Music Videos With Triller On Android And Iphone

Everyone loves music stars and we would be lying if we say that we have never thought of becoming a rockstar. However, most of us don’t have that musical talent to make it but what if we tell you that there’s a way to create your very own music video. Yes, that’s right, the cool Triller app lets you do exactly that. The app lets you create your very own music videos and we are pretty sure you are going to love it. First, let us introduce you to Triller:

What is Triller?

Triller is a popular music video creating app, that you might feel is similar to Dubsmash but there’s a lot more to it. The app has been developed by David Leiberman in collaboration with music director, Colin Tilley, who has directed various popular videos of Justin Bieber, Kendrick Lamar and Nicki Minaj, to name a few. The app lets you choose your favorite songs and then take various takes of you, dubbing that song. Then, Triller uses a cool algorithm (which is said to match a professional editor) to automatically edit the various takes into one.

The results are pretty amazing and if you don’t believe us, check out Triller’s Instagram page. Looks very impressive, right? So, without further ado, here’s how you can create your very own music videos using Triller:

How to create your very own music video:

2. Then, choose the music you want in your video. The app features a ton of songs, with the latest ones shown up front. It even lists regional songs, which is highly appreciable. Moreover, you can search for a song or choose a song from your device too.

3. Once you have selected the music track, you will have to select the portion of the song you want in the music video. To get a preview of a song in the app, hit the play button in the center. After you have chosen the portion of the track to feature in the music video, tap the tick button.

Note: The songs available in the app are limited to 29-seconds but your own music isn’t, so if you want a full length proper music video to show off your rockstar skills, you can choose a song from your device.

4. You will then be presented with the camera viewfinder, where you can select the front or the rear camera. Choose different filters and record in normal, fast or slow motion. Hit the capture button and the video should start capturing. When capturing, you can use the bar below to zoom in and out.

5. Don’t worry if the first take isn’t that great, as the app’s skill lies in using multiple takes and then editing them together for best results. After a take is done, hit the plus button to capture another take.

Once you have various video projects, you can swipe left on a project in the homepage to get the “delete” option and swipe right to get the “play” and “share” option. You can also check out Triller’s Settings by swiping down from the top in app’s homepage.

Triller Notable Features

The ability to choose from tons of songs available in the app along with your own music catalog.

The option to take as many takes as you want, for the best results.

Automatic editing of videos, which works like a charm.

Tons of cool filters and video modes like fast and slow motion.

Sharing options to almost all social networks and email or SMS etc.

Video resolution up to 720p.

Processing options and ability to synchronize audio.

SEE ALSO: Tribe: A Walkie-Talkie App to Send Disappearing Messages

Ready to star in your own music video created by Triller?

After using the Triller app for quite a while, we can confidently say that we are huge fans of the app. The app works like a charm and the video editing & rendering is a breeze. Also, brownie points to the developers for the intuitive interface. To sum things up, if you want to create a fun music video of yourself without having to go through the fuss of editing, Triller is the app to install. So, try out and the app and you can thank us later!

How To Watch Youtube Playlist In Android

For Android Smartphone

On your Android smartphone, launch the YouTube app (if you have not installed it, here’s the link).

Tap the “Menu” button and select the “My Channel” option.

Go to the Playlists tab and select your playlist.

Tap on any video to start playing. Once it has ended, the next video will continue automatically.

For Android tablet

While the YouTube app is the same, the interface is different.

At the top of the YouTube app, select “Your Channel”.

On the left sidebar, select “Playlist”. On the right pane, select the playlist that you want to play.

When you tap on a video to play, it will only play that video and won’t continue to the next video. To play all the videos in the playlist, you have to select the “Play all” option at the top right corner.

That’s it.

Note: From the YouTube app, you can also create new playlist and add/delete videos to/from your playlist. However, You will need to have at least one playlist in your YouTube account before the YouTube app allows you to create playlist. If not, it will show a “No Playlist found” error message.

Damien

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

Update the detailed information about Display Youtube, Vimeo, And Dailymotion Videos In Your Android Apps on the Hatcungthantuong.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!