A simple library for parsing and playing links from YouTube, YouTube Music, Vimeo and Rutube is WebView without the need to connect api data services. Request caching is available now

Overview

Android Oembed Video

A simple library for parsing and playing links from YouTube, YouTube Music, Vimeo and Rutube and others in the WebView without the need to connect data API services.

Release Platform Languages

Supported Video Hostings

  • YouTube

  • YouTube Music

  • Vimeo

  • Rutube

  • Facebook (the thumbnail is not available due to api restrictions)

  • Dailymotion

  • Wistia

  • Vzaar

  • Hulu

  • Ustream

  • Ted Talks

  • Coub

  • Streamable

  • Loom

Screenshots

Add it in your root build.gradle at the end of repositories:

allprojects {
        repositories {
                ...
                maven { url 'https://jitpack.io' }
        }
}

Add the dependency

dependencies {
        implementation 'com.github.TalbotGooday:Android-Oembed-Video:Tag'
}

Work Flow

  1. Create your OkHttpClient and add it to the VideoService.Builder
val okHttpClient = OkHttpClient.Builder()
	.connectTimeout(15, TimeUnit.SECONDS)
	.readTimeout(15, TimeUnit.SECONDS)
	.build()

val videoService = VideoService.build{
	with(this@MainActivity)
	httpClient(okHttpClient)
	enableCache(true)
	enableLog(true)
}
  1. Get VideoPreviewModel
videoService.loadVideoPreview(
	url,
	onSuccess = { video ->
		//handle a video model
	},
	onError = { url, error ->
		//handle an error
	})
  1. Enable/disable caching
val videoService = VideoService.build {
	enableCache(true)
}
  1. Enable/disable logging
val videoService = VideoService.build {
	enableLog(BuildConfig.DEBUG)
}

Play Video from VideoPreviewModel

The BottomVideoController allows to run any oembed video in WebView.

val host = model.videoHosting
val linkToPlay = model.linkToPlay
val title = model.videoTitle
val initUrl = model.url

BottomVideoController.build(this) {
	setListener(object : BottomVideoController.Listener() {
		override fun openLinkIn(link: String) {
			openLink(link)
		}
		override fun copyLink(link: String) {
			copyLinkToClipboard(link)
		}
	})
	setHostText(host)
	setPlayLink(linkToPlay)
	setSize(model.width, model.height)
	setTitle(title)
	setVideoUrl(initUrl)
	setProgressView(TextView(this@MainActivity).apply { text = "Loading" })
	show()
}

How to add some other video hosting

  1. Add the Gson library to your project
  2. Create the Gson data class from the embed response of the video service. Make this class a subclass of VideoInfoModel, implement the toPreview function, and override it:
 override fun toPreview(url: String?, linkToPlay: String, hostingName: String, videoId: String): VideoPreviewModel {
        return VideoPreviewModel(url, linkToPlay, hostingName, videoId).apply {
            this.thumbnailUrl = this@UltimediaResponse.thumbnailUrl
            this.videoTitle = this@UltimediaResponse.authorName
            this.width = this@UltimediaResponse.width.toInt()
            this.height = this@UltimediaResponse.height.toInt()
        }
    }
  1. Create a subclass of VideoInfoModel, implement members and override them:
class UltimediaVideoInfoModel: VideoInfoModel<UltimediaResponse>() {
	override val baseUrl: String
		get() = "https://www.ultimedia.com"
	//https://regex101.com/r/2AsrOc/1
	override val pattern: String
		get() = "(?:http[s]?:\\/\\/)?(?:www)?\\.?ultimedia\\.com\\/(?:deliver|default|api)\\/.*\\/([_a-zA-Z0-9]+)\\S*"
	override val idPattern: String
		get() = pattern //or some another video id search pattern
	override val type: Class<UltimediaResponse>
		get() = UltimediaResponse::class.java
	override val hostingName: String
		get() = "Ultimedia"

	override fun getInfoUrl(incomingUrl: String?): String? {
		return "$baseUrl/api/search/oembed?$FORMAT=$FORMAT_JSON&$URL=$incomingUrl"
	}

	override fun getPlayLink(videoId: String): String {
		return "https://www.ultimedia.com/deliver/generic/iframe/src/$videoId/"
	}
}

Note: By default, the index of the Regex group should be 1. If your idPattern does not fulfill this condition, then override the parseVideoId method:

override fun parseVideoId(url: String?): String? {
	url ?: return null
	return idPattern.toRegex().find(url)?.groups?.get(**someIndex**)?.value
}

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

You might also like...
Odeon Music Player is a lightweight music player for Android.
Odeon Music Player is a lightweight music player for Android.

Odeon 🎵 Odeon Music Player is a lightweight music player for Android. Get it on Google Play. We value your privacy, your battery life and your device

This is a local music player, imitates the UI of Netease Music client.
This is a local music player, imitates the UI of Netease Music client.

Introduce This is a local music player, imitates the UI of Netease Music client. The UI was built on Jetbrains Compose. Screenshot Features Parse and

This is a local music player, imitates the UI of Netease Music client.
This is a local music player, imitates the UI of Netease Music client.

Introduce This is a local music player, imitates the UI of Netease Music client. The UI was built on Jetbrains Compose. Screenshots Features Parse and

Android app that uses Spotify API to recommend new music based on your listening history

Android app that uses Spotify API to recommend new music based on your listening history. Written in Kotlin and uses Spotify Web API and Android SDK. New music is presented in swipe cards where a left swipe plays the next song and a right swipe can add the app to your liked songs in Spotify.

A simple app showing how to make a YouTube Shorts/TikTok style video pager

It's pretty straightforward to get started using ExoPlayer by following the library's Hello world! documentation. Once you throw Android's lifecycles

Auxio - A simple, rational music player for android.
Auxio - A simple, rational music player for android.

Auxio is a local music player with a fast, reliable UI/UX without the many useless features present in other music players. Built off of Exoplayer, Auxio has a much better listening experience compared to other apps that use the native MediaPlayer API. In short, It plays music.

A simple music player for Android
A simple music player for Android

RSShool2021-Android-task6-Music-App Цель - реализовать простой музыкальный плеер на Android 🎵 Требования: Данные о треках считываются с JSON-файла. П

Listen to your favourite songs from Spotify with your friends in Discord (via Spotify Connect)

Adieux Listen to your favourite songs from Spotify with your friends in Discord (via Spotify Connect) Requires Spotify Premium. This project is self-h

Echo is a lightweight and minimal music player for Android, built with Android Studio and written in Kotlin
Echo is a lightweight and minimal music player for Android, built with Android Studio and written in Kotlin

Echo - Echo, A light-weight, minimal music player for Android, with shuffle, favorites and audio visualization

Comments
  • Streamable Added

    Streamable Added

    I added support for streamable for a project. I think it is a popular site so here is PR if you want to include it.

    Btw I have added an example in the demo app but the thumbnail doesn't load there because of Picasso. I have tested it with Glide and there are no issues.

    opened by geption 0
Releases(0.2.2)
Owner
Alexey Mostovoy
Alexey Mostovoy
Auxio is a local music player with a fast, reliable UI/UX without the many useless features present in other music players

Auxio A simple, rational music player for android. FAQ | Licenses | Contributing | Architecture About Auxio is a local music player with a fast, relia

null 3 Mar 21, 2022
Convert your YouTube channel into a native Android app using YouTube Data API v3.

Convert your YouTube channel into an app. Screenshots • Description • Features • Configuration • Documentation Screenshots Description Channelify is a

Aculix Technologies LLP 123 Nov 12, 2022
Another local music player for Android built with Compose. Way too "local" so you likely won't need it.

AnotherAndroidLocalMusicPlayer Another local music player for Android built with Compose and media3 (ExoPlayer). Warning The app behaves strangly as i

oO0oO0oO0o0o00 0 Mar 13, 2022
Android Application that plays music through a Spotify API based on a user's current location found through Google Maps API and also checking Google Weather API.

GeoStereo Android Application that plays music through a Spotify API based on a user's current location found through Google Maps API and also checkin

Jonah Douglas 1 Jun 16, 2022
Youtube-dl UI - Youtube-dl ui built with kotlin and jetpack compose

youtube-dl_UI youtube-dl ui built with kotlin and jetpack compose.

null 0 Feb 11, 2022
Youtube Android Clone 🚀an Android Youtube Clone made out of XML and Kotlin

Youtube Android Clone ?? This app consumes The Youtube Api to fetch and display a list of popular videos, The app uses MVVM design pattern to allow se

Breens Robert 36 Nov 27, 2022
SpotiFlyer - Kotlin Multiplatform Music Downloader ,supports Spotify, Youtube, Gaana, Jio-Saavn and SoundCloud

SpotiFlyer Kotlin Multiplatform Music Downloader ,supports Spotify, Youtube, Gaa

Gas Com IT 1 Feb 8, 2022
Music Player - This is a basic music player built with Android Studio and Kotlin

Music Player Made by Jenny Cárdenas This is a basic music player built with Android Studio and Kotlin, it shows two views in the UI, the user can play

Jenny C 3 Oct 28, 2021
TunePlayer is a basic music player app aimed at showing how MusicServiceCompat and MusicBrowerCompat can be used to build a music playback service

TunePlayer TunePlayer is a basic music player app aimed at showing how MusicServiceCompat and MusicBrowerCompat can be used to build a music playback

Abdulmalik 6 Nov 18, 2022
SocyMusic is an open-source Android music player written in Java with the aim of creating an easy-to-use app for exchanging and listening to top-quality music. Help us create it!

SocyMusic SocyMusic is an open-source Android music player written entirely in Java. It's objectives are to provide top-quality music to everyone for

Benji 24 Nov 17, 2022