How to embed and play a YouTube video in android
The Answer is Simple "YES".
Please look at to following link,
How to play YouTube video in my Android application?
Streaming Youtube Videos
How to embed a Youtube video into my app?
Xcode 8.2 • Swift 3.0.2
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var wv: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
loadYoutube(videoID: "oCm_lnoVf08")
}
func loadYoutube(videoID:String) {
guard
let youtubeURL = URL(string: "https://www.youtube.com/embed/\(videoID)")
else { return }
wv.loadRequest( URLRequest(url: youtubeURL) )
}
}
Xcode 7.3.1 • Swift 2.x
import UIKit
class ViewController: UIViewController {
// create an outlet for your webview
@IBOutlet weak var wv: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// load your you tube video ID
loadYoutube(videoID: "oCm_lnoVf08")
}
func loadYoutube(videoID videoID:String) {
// create a custom youtubeURL with the video ID
guard
let youtubeURL = NSURL(string: "https://www.youtube.com/embed/\(videoID)")
else { return }
// load your web request
wv.loadRequest( NSURLRequest(URL: youtubeURL) )
}
}
Iframes and React.js - How to embed a youtube video into my app
You can just use an iframe
element to achieve this. There is no need to depend on yet another npm
package.
<iframe src='https://www.youtube.com/embed/E7wJTI-1dvQ'
frameborder='0'
allow='autoplay; encrypted-media'
allowfullscreen
title='video'
/>
By the way, if you are wondering why the embed URL
looks like it looks, you can just go to an arbitrary Youtube video
, click on Share
and then you immediately see that we just need to append /embed/:videoId
Youtube's
base URL
.
Embed YouTube live stream in android app
First video id out-of-date so you need to replace another one and check agein
Also i think your code should be like below
onCreate
YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player);
youTubePlayerView.initialize(getString(R.string.google_developer_api_key), this);
OnInitializedListener
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.loadVideo(""); // your video id
youTubePlayer.play();
}
embedding youtube video in iphone app
No need to use the embed code. The standard UIWebView aimed at the youtube web address should work fine...
// URL from safari address bar.
NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=fDXWW5vX-64"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
How to embed a YouTube clip in a WebView on Android
I am not sure if this is what you need. Anyway I hope the following be useful.
You can use the iframe method that youtube provides to play its videos. If the browser supports html5 will show the video with it, otherwise with flash.
You can use the following code as an example <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/bIPcobKMB94" frameborder="0">
in the above example the video id is bIPcobKMB94. You can change this id and show your video.
You can access a live example of it here
More infromation for youtube iframe
YouTube HTML5 Video Player
Related Topics
Open Uitableview Edit Action Buttons Programmatically
Hide Keyboard for Text Field in Swift Programming Language
Create a Copy of a Uiview in Swift
iOS 7 Uitextview Vertical Alignment
Type 'Any' Has No Subscript Members (Firebase)
How to Disable/Remove Firebaseanalytics
How to Use Core Location/Gps Without Any Internet Connection/Disabled Cellular Network
iOS - How to Play a Video with Transparency
iOS Open Youtube App with Query (Url Schemes)
How to Present a Uiviewcontroller from Skscene
How to Debug "Terminated Due to Memory Error"
Swift - Get Local Date and Time
Xcode 10.2 with Swift 5.0 Compiler - Protocol Inheritance Issue