{"id":13607350,"url":"https://github.com/TalbotGooday/Android-Oembed-Video","last_synced_at":"2025-04-12T11:32:23.780Z","repository":{"id":152787370,"uuid":"225641422","full_name":"TalbotGooday/Android-Oembed-Video","owner":"TalbotGooday","description":"A simple library for parsing and playing links from YouTube, YouTube Music, Vimeo and Rutube in the WebView without the need to connect API data services","archived":false,"fork":false,"pushed_at":"2024-03-25T20:47:42.000Z","size":4892,"stargazers_count":39,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-01T19:44:51.099Z","etag":null,"topics":["android","android-ui","custom","oembed","video","video-hosting","view"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TalbotGooday.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-12-03T14:35:18.000Z","updated_at":"2024-05-07T11:18:47.000Z","dependencies_parsed_at":"2023-06-26T20:52:39.409Z","dependency_job_id":null,"html_url":"https://github.com/TalbotGooday/Android-Oembed-Video","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TalbotGooday%2FAndroid-Oembed-Video","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TalbotGooday%2FAndroid-Oembed-Video/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TalbotGooday%2FAndroid-Oembed-Video/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TalbotGooday%2FAndroid-Oembed-Video/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TalbotGooday","download_url":"https://codeload.github.com/TalbotGooday/Android-Oembed-Video/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223514204,"owners_count":17158143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-ui","custom","oembed","video","video-hosting","view"],"created_at":"2024-08-01T19:01:17.875Z","updated_at":"2024-11-07T12:32:07.585Z","avatar_url":"https://github.com/TalbotGooday.png","language":"Kotlin","readme":"\n# Android Oembed Video\nA 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.\n\n[![Release](https://jitpack.io/v/TalbotGooday/Android-Oembed-Video.svg)](https://jitpack.io/#TalbotGooday/Android-Oembed-Video) [![Platform](https://img.shields.io/badge/platforms-Android-green.svg)]() [![Languages](https://img.shields.io/badge/languages-Kotlin-F18E33.svg)]()\n\n## Supported Video Hostings\n\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/youtube.png\" width=18px/\u003e    YouTube\n\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/youtube_music.png\" width=18px/\u003e YouTube Music\n\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/vimeo.png\" width=18px/\u003e Vimeo\n\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/rutube.png\" width=18px/\u003e Rutube\n\n* \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Facebook_icon_2013.svg/1024px-Facebook_icon_2013.svg.png\" width=18px/\u003e Facebook (is no longer available due to API restrictions)\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/dailymotion.png\" width=18px/\u003e Dailymotion\n* \u003cimg src=\"https://www.saashub.com/images/app/service_logos/25/1a1b2c9e8acc/large.png?1547934029\" width=18px/\u003e Wistia\n* \u003cimg src=\"https://static.crozdesk.com/web_app_library/providers/logos/000/003/720/original/vzaar-1559230945-logo.png?1559230945\" width=18px/\u003e ~~Vzaar~~ (it's Dacast now) \n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/hulu.png\" width=18px/\u003e Hulu\n* \u003cimg src=\"https://blog.video.ibm.com/wp-content/uploads/2014/10/U_logo_blue-2.png\" width=18px/\u003e Ustream\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/ted_talks.png\" width=18px/\u003e Ted Talks\n* \u003cimg src=\"https://cdn.iconscout.com/icon/free/png-512/coub-1693601-1442642.png\" width=18px/\u003e Coub\n* \u003cimg src=\"https://cdn.embed.ly/providers/logos/streamable.png\" width=18px/\u003e Streamable\n* \u003cimg src=\"https://github.com/TalbotGooday/Android-Oembed-Video/blob/master/app/src/main/res/drawable-xxhdpi/loom.png\" width=18px/\u003e Loom\n\n## Screenshots\n\n\u003cimg src=\"/screenshots/device-2020-02-06-232720.png\" width=32%/\u003e \u003cimg src=\"/screenshots/device-2020-02-06-232746.png\" width=32%/\u003e \u003cimg src=\"/screenshots/device-2020-02-06-232924.png\" width=32%/\u003e\n\nAdd it in your root build.gradle at the end of repositories:\n```java\nallprojects {\n        repositories {\n                ...\n                maven { url 'https://jitpack.io' }\n        }\n}\n```\nAdd the dependency\n\n```java\ndependencies {\n        implementation 'com.github.TalbotGooday:Android-Oembed-Video:Tag'\n}\n\n```\n\n## Work Flow\n1. Create your OkHttpClient and add it to the VideoService.Builder\n```kotlin\nval okHttpClient = OkHttpClient.Builder()\n\t.connectTimeout(15, TimeUnit.SECONDS)\n\t.readTimeout(15, TimeUnit.SECONDS)\n\t.build()\n\nval videoService = VideoService.build{\n\twith(this@MainActivity)\n\thttpClient(okHttpClient)\n\tenableCache(true)\n\tenableLog(true)\n}\n```\n2. Get VideoPreviewModel\n```kotlin\nvideoService.loadVideoPreview(\n\turl,\n\tonSuccess = { video -\u003e\n\t\t//handle a video model\n\t},\n\tonError = { url, error -\u003e\n\t\t//handle an error\n\t})\n```\n3. Enable/disable caching\n```kotlin\nval videoService = VideoService.build {\n\tenableCache(true)\n}\n```\n4. Enable/disable logging\n```kotlin\nval videoService = VideoService.build {\n\tenableLog(BuildConfig.DEBUG)\n}\n```\n## Play Video from VideoPreviewModel\nThe BottomVideoController allows to run any oembed video in WebView.\n```kotlin\nval host = model.videoHosting\nval linkToPlay = model.linkToPlay\nval title = model.videoTitle\nval initUrl = model.url\n\nBottomVideoController.build(this) {\n\tsetListener(object : BottomVideoController.Listener() {\n\t\toverride fun openLinkIn(link: String) {\n\t\t\topenLink(link)\n\t\t}\n\t\toverride fun copyLink(link: String) {\n\t\t\tcopyLinkToClipboard(link)\n\t\t}\n\t})\n\tsetHostText(host)\n\tsetPlayLink(linkToPlay)\n\tsetSize(model.width, model.height)\n\tsetTitle(title)\n\tsetVideoUrl(initUrl)\n\tsetProgressView(TextView(this@MainActivity).apply { text = \"Loading\" })\n\tshow()\n}\n```\n## How to add some other video hosting\n1. Add the `Gson` library to your project\n2. 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:\n```kotlin\n override fun toPreview(url: String?, linkToPlay: String, hostingName: String, videoId: String): VideoPreviewModel {\n        return VideoPreviewModel(url, linkToPlay, hostingName, videoId).apply {\n            this.thumbnailUrl = this@UltimediaResponse.thumbnailUrl\n            this.videoTitle = this@UltimediaResponse.authorName\n            this.width = this@UltimediaResponse.width.toInt()\n            this.height = this@UltimediaResponse.height.toInt()\n        }\n    }\n```\n3. Create a subclass of `VideoInfoModel`, implement members and override them:\n```kotlin\nclass UltimediaVideoInfoModel: VideoInfoModel\u003cUltimediaResponse\u003e() {\n\toverride val baseUrl: String\n\t\tget() = \"https://www.ultimedia.com\"\n\t//https://regex101.com/r/2AsrOc/1\n\toverride val pattern: String\n\t\tget() = \"(?:http[s]?:\\\\/\\\\/)?(?:www)?\\\\.?ultimedia\\\\.com\\\\/(?:deliver|default|api)\\\\/.*\\\\/([_a-zA-Z0-9]+)\\\\S*\"\n\toverride val idPattern: String\n\t\tget() = pattern //or some another video id search pattern\n\toverride val type: Class\u003cUltimediaResponse\u003e\n\t\tget() = UltimediaResponse::class.java\n\toverride val hostingName: String\n\t\tget() = \"Ultimedia\"\n\n\toverride fun getInfoUrl(incomingUrl: String?): String? {\n\t\treturn \"$baseUrl/api/search/oembed?$FORMAT=$FORMAT_JSON\u0026$URL=$incomingUrl\"\n\t}\n\n\toverride fun getPlayLink(videoId: String): String {\n\t\treturn \"https://www.ultimedia.com/deliver/generic/iframe/src/$videoId/\"\n\t}\n}\n``` \n**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:\n```kotlin\noverride fun parseVideoId(url: String?): String? {\n\turl ?: return null\n\treturn idPattern.toRegex().find(url)?.groups?.get(**someIndex**)?.value\n}\n```\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details\n\n","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTalbotGooday%2FAndroid-Oembed-Video","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTalbotGooday%2FAndroid-Oembed-Video","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTalbotGooday%2FAndroid-Oembed-Video/lists"}