I saw many posts about the issue that it is not possible to attach 2 or more Youtube players in one activity.
Its look like youtube api allows only 1 player per activity even if its on fragment.
There is a solution for it?
Related
I'd like to implement bookmarks app allowing to save a bookmark for a particular moment in a youtube video so that it would be possible to jump back to the given second of the video.
I'd like it to be seamlessly integrated with the native youtube app. Is it possible to create a transparent layer on top of youtube app so that I could add this kind of functionality? I mean kind of button in the corner of the screen allowing to save the exact moment of the video. To do that I need to know what youtube video is being watched and what is the moment? Is it doable?
I have no experience with android development, but I'm a skilled Java programmer.
This is a link to a youtube video which takes you directly to a certain moment in the video: https://theyoutubevideolink?t=36m42s (Note everything after ?)
This also works on the current Android YouTube App you can click on the link and it will directly take you to the moment. So it is possible to simply save that link to an external overlay/database.
But before thinking about that you understand Root permission is needed to be able to do this as an overlay. If you are fine with this, it is doable there are many open source YouTube apps with changes made to them on XDA Developers for example, and a simple database addition can the trick for this.
[EDIT]
Well I just went on the YouTube app and you cant hold a time-link like for example on LinusTechTips new video on mobile if you scroll down to the comments you will see many comment showing 0:55 which if you click on can take you directly to that moment in the video. Because we cant hold or anything else than just click, You will need to re-write so you can highlight etc.. which is why i mentioned before about having root access since you cant install third party YouTube apps it has to be re-written and just made into another app. To start you off check this re-written YouTube app called SkyTube: https://github.com/ram-on/SkyTube
I'm trying to make a kid-safe youtube player (users can't easily watch unapproved content). Using the CHROMELESS style almost gets there, but users can still click the lower banners or 'Watch Next' button that pops on the video. This takes them to the Youtube app where they could browse to any video.
Similar questions that I've found without resolutions:
how to remove bottom overlay ads from custom youtube player Android
Is there any way to disable "Watch Next" block at the end of video using YouTube Android Player API?
Someone in the second thread suggested using "a ViewTreeObserver and hiding that particular view", but I am having trouble getting that to work.
-Hello! Please correct me if i am wrong but this line of code may be helpful to you i think player.setPlayerStyle(PlayerStyle.MINIMAL);
-Try this line this may will sure solve your problem :-
player.setPlayerStyle(PlayerStyle.CHROMELESS);
In case anyone is still stuck with this, here is what worked for me. If you are only playing a single video then cue the video when playing is finished but don't call player.play() unless you want to repeat the video.
if(player.getCurrentTimeMillis()>=player.getDurationMillis())
{
player.cueVideo(CurrentVideoUrl);
}
If you are providing a long list of videos that play one after the other then use an array list
if(player.getCurrentTimeMillis()>=player.getDurationMillis())
{
CurrentVideoIndex++;
CurrentVideoUrl =videosListArray.get(CurrentVideoIndex).getVideoUrl();
player.cueVideo(CurrentVideoUrl);
}
I want to develop a scenario:
when i click on listview item youtube video should start playing.
Listview content is fetched from JSON. JSON object has title, description and youtube url. This youtube url should initiate the youtube player.
I tried few tutorials from the internet but the problem is: when youtube video is playing in portrait mode, blank white screen is displayed below the video view. I want to display the next videos thumbnails as listview there. Can any one suggest me how to do this?...
Create an explicit intent and set the url as an extra for the intent.
You can find more information about intents here: https://developer.android.com/guide/components/intents-filters.html
You can also checkout this link for intents specific to the Youtube app https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeIntents
In the future, do a google search before posting questions on stackoverflow. You need to show that you have done your own research before asking such vague questions on here.
Possible duplicate (please don't vote my answer):
Embed Youtube video inside an Android app
and
How to play YouTube video in my Android application?
Some other resources you can use: https://developers.google.com/youtube/android/player/sample-applications
Because I do not fully understand the context of your app, you will have to decide which type of player is best for you.
In my android tablet app I have one base activity and that activity has 3fragments
all the fragments has a video playing option and all of them are interlinked, means I can switch from one fragment to the other two fragments
when user clicks the video play option it will open a new activity and play the youtube video.
I'm using youtube api and the video is playing well except for sometime
the video id is generated from the url every time in that youtube activity from the url,I have printed the log and I'm checking whether id is created, and it is created
I've used
youtubeplayerview.initialize(API_KEY, VideoPlayActivity.this);
to initialize the youtubeplayview, and
player.cueVideo(VIDEO_ID);
inside onInitializationSuccess method to add the view to the youtube view
the problem I'm facing is:
if suppose I play the video from fragment A, it played well and good,
now if i go to fragment B from A and again play the video, it will go on loading but will never go inside the onInitializationSuccess method, but if I debug the code, its going well and good.
does the youtube api needs some delay before starting the video?
I don't have any idea why this is happening and what am i missing
Question 2:
Will the youtube api behaviour differ from system to system???
My app has been integrated with facebook and its been done from another pc, and I'm doing youtube from my pc, the final build has to be from the system which integrated facebook,(I know youtube api key doesn't depend on sha1 key which differs from system to system still want to clear my doubt) will it be a problem with youtube at that time?
any help is favourable
Thanks
I'm working on an app for a band, which consists of several different activities such as an agenda, news section, album section et cetera.
Since it's for a band, I would like to play the band's songs in the background.
This isn't such a problem, but I would like to show a small music player on the bottom of all activities so users can always stop, skip, or replay a song if they want to. An example of this can be found in the apps of Mobile Roadie, for instance.
However I have no idea how to do this. My best guess is creating a music player class with its own layout, and including this at the bottom of each activity/layout. But since every activity starts in its own thread, I'm guessing this would reset the player for each activity.
So, how would I go about adding a common music player to all of my activities, where the state of the music player would be maintained?
For an example, download any of the music based apps of Mobile Roadie and you'll know what I mean.
I decided on using Fragments, but I'm not sure if I can use those in already existing activities. All the examples I found focus on completely new projects, and not already existing ones.
So in short, can you create fragments and use them in already existing activities? (such as showing the music player on top of the existing agenda activity)
I suggest you doing it the following way. Since music playing state must be retained in all the activities, you have to use a service to achieve this. Also you need a control panel, which must exist separately from activities. The best method to do it is by using fragments. Create a fragment which connects to the service and provides an UI to control it, then add this fragment to all the activities where you need it.