I have an android project where I integrate the JWplayer sdk, the player is playing video well
The problem is when the player arrive to play the ads it show me this exeption :
"Mixed Content: The page at 'https://intercept.jw//data/user/0/user/files/jwplayer/jw_core/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://myXmlAdsFile'. This request has been blocked;
I tried those solution without a result:
turn my link to https:
did not work, it shows me an insecure link exeption
allow mixed content:
I dont have a web view in the player so can not use this method
this is my code to initialize my jwplayer:
List<AdBreak> adSchedule = new ArrayList<>();
AdBreak adBreak = new AdBreak.Builder()
.tag(My Xml Link)
.offset(time when the ads show up)
.build();
adSchedule.add(adBreak);
Advertising advertising = new Advertising(AdSource.VAST, adSchedule);
PlaylistItem playlistItem = new PlaylistItem.Builder()
.file(videoUrl)
.build();
List<PlaylistItem> playlist = new ArrayList<>();
playlist.add(playlistItem);
config = new PlayerConfig.Builder()
.playlist(playlist)
.advertising(advertising)
.build();
jwPlayerView.setup(config);
Related
I'm trying to play Vimeo video using ExoPlayer and here is the code:
val dataSourceFactory = DefaultDataSourceFactory(requireContext(),
getUserAgent(requireContext(), requireContext().getString(R.string.app_name)))
val videoSource = ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(videoLink))
player.prepare(videoSource)
This throw the following exception:
com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:300)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:177)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:961)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Also I tried to extract the Vimeo url using AndroidVimeoExtractor and it fails with the following exception:
java.io.IOException: Video has restricted playback
Here is the code:
VimeoExtractor.getInstance().fetchVideoWithIdentifier(
"videoIdentifier",
null,
object : OnVimeoExtractionListener {
override fun onSuccess(video: VimeoVideo) {
Logger.i("video: ${video.streams.size}")
}
override fun onFailure(throwable: Throwable) {
Logger.e(throwable)
}
})
And here is a sample of Vimeo video link: http://player.vimeo.com/external/videoIdentifier.sd.mp4?s=value&profile_id=value&oauth2_token_id=value
Note: I'm not the person who uploaded the video. Also, when I put the link in Google Chrome Browser it redirects to another link and plays video normally. So I need something like that to get the final link to pass it to ExoPlayer.
There is 2 ways to handle this issue
First solution
Using Vimeo networking API to get video URI and to use it
create app on vimeo developer
using your app access token and video Id you can get Video Url then pass it to Exo player
Second Solution (it's a work around and fast solution)
using web view to redirect to .mp4 url, then use the redirected url ends with.mp4 to open it with Exo player
webView = WebView(context).apply {
settings.javaScriptEnabled = false
webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val requestUrl = request?.url.toString()
val uri = requestUrl.toUri()
if (isVideoLink(requestUrl)) {
preparePlayer(uri)
webView?.release()
webView = null
return true
}
return false
}
}
loadUrl(url)
}
fun isVideoLink(url: String): Boolean {
return getMimeType(url)?.contains("video", true) ?: false
}
Are you trying to play all Vimeo Videos, or just Vimeo videos you've uploaded?
I think the issue is the mp4 file you're pulling isn't actually valid or you don't have permissions to stream it given your oauth token (if you don't own it).
You can check out the vimeo-networking library README here.
The basic requirements for native playback are:
User must be logged in.
User must be the owner of the video.
User must be PRO or higher (or the app must have the "can access owner's video files" capability).
Token must have the video_files scope.
User must be the owner of the API app making the request.
If you satisfy all of those requirements, then you can make an API request to Vimeo and they'll give you back a valid MP4 file you can pass as the videoLink.
// Obtain a video you own my making a GET request
Video video = ...;
Play play = video.getPlay();
// This will be a list of "progressive" video files (basically just MP4s of different resolutions that you can pass to ExoPlayer
ArrayList<VideoFile> progressiveFiles = play.getProgressiveVideoFiles();
String linkToMp4File = progressiveFiles.get(0).getLink();
val videoSource = ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(linkToMp4File))
If you weren't the person who uploaded the video, I think there's a way to get a valid video link, but I've never done it personally. Since all users are allowed to embed any video (if the video is public and embeddable), then you could get the embed link from the API here and then extract the MP4 file link from the embed code maybe? Just an idea.
I am trying to play youtube video using android cardboard sdk provided by google but I am not able to play it.
Here is my code
Options options = new Options();
options.inputFormat = Options.FORMAT_HLS;
options.inputType = Options.TYPE_MONO; // for 360 video
videoWidgetView.loadVideo(Uri.parse("https://www.youtube.com/watch?v=xyzzyz"), options);
Error Log :
E/VrVideoPlayer: 205251285AdaptiveMediaSourceEventListener.onLoadError com.google.a.a.g.v: Input does not start with the #EXTM3U header.
I got a example from github you can go through this link:https://github.com/googlevr/gvr-android-sdk
I use setIconUri set a online Image URL at MediaDescriptionCompat Builder like this
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder();
builder.setMediaId(item.getlistId());
builder.setTitle(item.getlistName());
builder.setIconUri(Uri.parse(item.getlistIconM()));
Bundle bundle = new Bundle();
bundle.putInt(BUNDLE_KEY_MEDIA, R.string.title_theme);
then the Image of MediaItem display perfect at Android Auto, but not at Android Wear, why ?
and what should I do fixed this issue ?
Android Wear only loads remote URLs from https - if you are using http URLs, you should switch to https.
I'm developing a cardboard app. In my app I want to play a 360 youtube video, I want it to go straight to VR mode so the user doesn't have to remove their headset.
I don't mind whether this video is embedded in my app or opens the youtube app, but I need it go directly into VR mode with no non-VR interaction.
I've looked into doing the following:
streaming the video onto a surfaceTexture and using this to render stereoscoptically: not Possible
Launching the youtube app in cardboard mode: Not Possible
Using the YoutubePlayerView/Fragment/standalonePlayer : None expose functions to enable cardboard mode.
Is this possible?
I ended up using DASH with exoplayer.
I grabbed the direct url like so:
String GET_VIDEO_INFO_URL = "http://www.youtube.com/get_video_info";
Bundle params = new Bundle();
params.putString("video_id", info.getId());
UrlUtils.HttpURLRequest request = new UrlUtils.HttpURLRequest(GET_VIDEO_INFO_URL, "GET", params);
String response = request.execute();
if(response != null) {
Bundle urlParams = UrlUtils.decodeUrl(response);
String manifest_url = urlParams.getString("dashmpd", null);
info.setPath(manifest_url);
}
Then I use exoplayer to render the dash stream to a texture as explained here.
I am developing vimeo video app in native android. But it is not supported in VideoView. May I know any samples or related query for Android. I want final output to be in .mp3/.mp4 format.
I have tried iframe in Android WebView, It works well in Android WebView but I am not able to get seek bar. And OnPause() not able to Pause the video.
Here I am able to get Pause and Play button Only
Example: player.vimeo.com/video/49462103
I want play this video in android native
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/videoView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
Update link in :
Vimeo site Thread-1
Vimeo site Thread-2
I am getting above error
I made a native player for vimeo, base by WebView. Support public and private video.
Try it : https://github.com/ct7ct7ct7/Android-VimeoPlayer
<com.ct7ct7ct7.androidvimeoplayer.view.VimeoPlayerView
android:id="#+id/vimeoPlayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
VimeoPlayerView vimeoPlayer = findViewById(R.id.vimeoPlayer);
getLifecycle().addObserver(vimeoPlayer);
//public video
vimeoPlayer.initialize(59777392);
//If video is open. but limit playing at embedded.
vimeoPlayer.initialize({YourPrivateVideoId}, "SettingsEmbeddedUrl")
//If video is pirvate.
vimeoPlayer.initialize({YourPrivateVideoId},"VideoHashKey", "SettingsEmbeddedUrl")
Vimeo's embed codes should work inside an Android WebView.
Vimeo only offers .mp4 links to PRO users on those users own videos.
Another option is to use the official Deep Link library for the android application. This will let you open any vimeo video in the Android app.
You can use Exoplayer to play vimeo Videos. Exoplayer is more customizable. All you need is to extract the url link from the video config link. You may use retrofit to extract the video url.
BASE_URL = "https://player.vimeo.com/video/"
You will need to use a get method like below:
#GET("{id}/{config}")
Call<JsonObject>getVideoLink(#Path("id") String id, #Path("config") String config);
You will get the id from video link. Example: "https://vimeo.com/123456789/" Here the id is: 123456789 .
JsonObject jsonObject = response.body();
JsonObject req = jsonObject.getAsJsonObject("request");
JsonObject file = req.getAsJsonObject("files");
JsonArray arr = file.getAsJsonArray("progressive");
String url = arr.get(0).getAsJsonObject().get("url").getAsString();
// Build the media item.
MediaItem mediaItem = MediaItem.fromUri(url);
// Set the media item to be played.
player.setMediaItem(mediaItem);
// Prepare the player.
player.prepare();
// Start the playback.
player.play();
Don't forget to initiate Exoplayer first.