brandly / angular-youtube-embed

:tv: Embed a YouTube player with a simple directive
http://brandly.github.io/angular-youtube-embed/
MIT License
509 stars 147 forks source link

Playing in Background and Closes App #102

Open felipeap92 opened 8 years ago

felipeap92 commented 8 years ago

Hi, i'm having 2 problems using this plugin in mobile (ionic + cordova):

1- When i play the video and minimize the app, the video keep playing in background... I tryied using $scope.player and "state change" to controll this but the player does not exist and "state changer" dosent know when the app was minimized.

2- When i click in the video do open in full screen and hit the device back button, it closes the app. Wha i expected was that the video closes the full screen.

There is a way to fix those 2 issues?

Thanks. =]

AtomSub commented 8 years ago

I'm also interested in pausing the player when the phone sleeps. I use ionic and plan on trying this solution: http://stackoverflow.com/a/32245134

UniSoundEcho commented 8 years ago

I am using ionic as well to create a mobile app and I am also using this youtube iframe api. I am wondering about two things:

  1. How to play audio in the background when app is closed.
  2. How to remove play back restriction such as Vevo? !important.

Thank you!

brandly commented 8 years ago

How to play audio in the background when app is closed.

i'm not certain, but i think that might be a violation of youtube's terms. if you're doing something for yourself, you might be able to pull it off, but i doubt you'd make it into the app store.

How to remove play back restriction such as Vevo? !important.

if you mean the thing where you can't play certain videos on mobile, i don't think there's any way around that. sorry!

felipeap92 commented 8 years ago

And about the things i asked? There is a way around? Thanks

brandly commented 8 years ago

sorry @felipeap92!

When i play the video and minimize the app, the video keep playing in background

check out this issue: https://github.com/brandly/angular-youtube-embed/issues/98#issue-126876752

When i click in the video do open in full screen and hit the device back button, it closes the app.

i'm not sure about this! maybe there's a way to listen for some event at the browser level, to find out the back button was pressed. i'm guessing you're on android, and i don't know much about android.

good luck! :star2:

UniSoundEcho commented 8 years ago

@brandly I am positive that it is legal to use youtube api to play audio in the background. This app does exactly this, https://itunes.apple.com/us/app/musi-unlimited-free-music/id591560124?mt=8 This app can play any music with youtube iframe api with no restriction and can play in background.

If I am doing this for myself, could you please suggest a way to allow background music play?

UniSoundEcho commented 8 years ago

@brandly I have a possible solution for playing videos that are restricted. I think the url has to start with https instead of http. I am not familiar with how your plugin works. Is it currently requesting from youtube using httpsecure?

UniSoundEcho commented 8 years ago

@felipeap92 How did you get your app to play audio in background? Please help me.

felipeap92 commented 8 years ago

@UniSoundEcho i simple used ionic + cordova + this plugin... When i play the video and put the app in background or change de view, the video keep playing...

If i use youtube frame wihtout the plugin i get the same behaviour...

UniSoundEcho commented 8 years ago

@felipeap92 I used ionic and this plugin as well, but the music stops when I put the app in background or change the view, the audio stops. How did you get it to play in the background? What do you mean by you used cordova plugin?

Also, have you encountered problems with restricted playback due to copyright? How to bypass that?

Thank you!