How can I simulate a touch in a UIWebView? - javascript

I want to automatically play a YouTube video but because of how YouTube's view counter is set up, autoplay views will not count as views.
How can I simulate a user interaction tap in a UIWebView so YouTube thinks that the user pressed/tapped play?
Or do you "think" that a very near version of iOS will support this?
Trying to phrase that in NDA accordance. Do you think it would work if I changed the user agent of the UIWebView to a desktop user agent and displayed a standard YouTube page?
On the desktop YouTube videos autoplay on Youtube.com but this does not work on mobile.
I have set mediaPlaybackRequiresUserAction to no.

Related

Youtube playing a video with sound in PWA is not working

My app used to be able to play videos with sound inside a PWA environment using the YouTube Iframe API, but in the last few days this is only achieved if there has been a user gesture before. Playing the video muted is allowed, also no errors are produced in the above process.
This is not allowed anymore in Chrome:
Chrome's autoplay policies are simple:
Muted autoplay is always allowed. Autoplay with sound is allowed if:
The user has interacted with the domain (click, tap, etc.). On
desktop, the user's Media Engagement Index threshold has been crossed,
meaning the user has previously played video with sound. The user has
added the site to their home screen on mobile or installed the PWA on
desktop. Top frames can delegate autoplay permission to their iframes
to allow autoplay with sound.
Source: https://developer.chrome.com/blog/autoplay/

How to autoplay HTML5 videos with sound (unmuted) in Safari

Safari and Chrome is not allowing video to autoplay if sound is on by default (unmuted). If you mute the video, it will autoplay, and the user is forced to enable sound. Fine and well, I can live with this.
However, in researching this, I found that YouTube (Safari 11, MacOS High Sierra), is allowing subsequent videos to be played with sound ON if the user turns sound on for a given video. Likewise, if user mutes the video, clicks onto a different video, this video will autoplay muted until user toggles the sound on. I would love to replicate this on a site in which I have created a video gallery of sorts. Each video does live on it's own page, and navigating the gallery will take user to a new page in the browser. This needs to stay the same, for multiple reasons (as opposed to creating a single media element and dynamically changing video source).
Alternatively, is there a way to convince Safari that a user has intentionally clicked a button in order to watch a video, thus allowing autoplay with sound on, when the user is simply clicking a link (in the form of a "Play Video Now" button) to a page with the video embedded?

HTML, JS: Does loading audio need user interaction on mobile browsers?

Playing audio definitely needs user interaction on mobiles but, my question is does loading audio also need user interaction?
If yes, what I want to do is preload the audio so when the user taps the play button, the audio can start playing faster, as it has already started loading.
User interaction need to load and play the audio or video in mobile device, Mobile device avoiding auto play on audio and video for bandwidth limitation. Sorry i cant comment that's why i post in answer.

How to play an inline video in Phonegap on Android without user interaction?

I'm creating a Phonegap application with embedded video using the HTML5 tag.
The video loads and plays fine. The only problem is that it requires user interaction. The play script runs fine when I trigger it by clicking a link, but will not work when run using setTimeOut. Is there a way to bypass this limitation?
It only needs to work on one device, and the devices is rooted. So hacks are also welcome ;-)
I don't want to play the video fullscreen, so I cannot use the video plugin.
Android 4.2.2, Phonegap 3.2

How mobile YouTube page autoplay videos on iOS?

I'm trying to get it understand but after 2 days of digging the code I thought that I will post my issue here...
According to Apple's documentation, autoplaying videos on iOS devices cannot be done without user interaction first (e.g. tap on video). Despite that, mobile YouTube (m.youtube.com) is able to autoplay its videos just after loading a page with video.
Does anyone know how they are doing it?
PS. I've checked all available JS/HTML techniques of autoplaying videos on website on iOS (e.g. iframe, fake click, triggering touch event on video, fetching video with XHR).
I believe that youtube.com is a single page app. So when the user clicks on the video from the list view the page is not loading and their javascript uses that initial click, that leads to the video page, as the click that starts the video. It's not actually autoplaying, it's just a trick.

Categories

Resources