itsnubix / react-native-video-controls

A React Native video component with controls
MIT License
637 stars 526 forks source link

Audio is not working on iPhone but works on emulator #20

Closed j3rin closed 7 years ago

j3rin commented 7 years ago

Please help, audio is not working on iPhone but works on emulator.

kylemilloy commented 7 years ago

You don't have the device muted or hooked to any Bluetooth setup eh?

Sent from my iPhone

On Mar 20, 2017, at 6:33 PM, j3rin notifications@github.com<mailto:notifications@github.com> wrote:

Please help, audio is not working on iPhone but works on emulator.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/itsnubix/react-native-video-controls/issues/20, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APBvPTNseblZ2HhW3kooXRudJXAMXadkks5rnxrkgaJpZM4MjMF6.

j3rin commented 7 years ago

Nope, tried on two different iPhones same issue.

kylemilloy commented 7 years ago

Can you send me the code on how you're using the package? What version of RN are you on?

Sent from my iPhone

On Mar 20, 2017, at 6:35 PM, j3rin notifications@github.com<mailto:notifications@github.com> wrote:

Nope, tried on two different iPhones same issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/itsnubix/react-native-video-controls/issues/20#issuecomment-287940938, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APBvPaTYNJ09hbgc1MJCUUJY1cJNf7Ieks5rnxtZgaJpZM4MjMF6.

kylemilloy commented 7 years ago

Also, what kind of devices are you running? Which version of iOS?

Sent from my iPhone

On Mar 20, 2017, at 6:35 PM, j3rin notifications@github.com<mailto:notifications@github.com> wrote:

Nope, tried on two different iPhones same issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/itsnubix/react-native-video-controls/issues/20#issuecomment-287940938, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APBvPaTYNJ09hbgc1MJCUUJY1cJNf7Ieks5rnxtZgaJpZM4MjMF6.

j3rin commented 7 years ago

Running react-native-cli: 0.1.10 react-native: 0.42.0

Emulator iPhone 6

Device iPhone 7 Plus 10.2.1 iPhone 6

Package JSON File "dependencies": { "axios": "^0.15.3", "native-base": "^2.0.13", "react": "15.4.2", "react-native": "^0.42.0", "react-native-elements": "^0.10.0", "react-native-image-slider": "^1.1.5", "react-native-material-buttons": "^0.2.0", "react-native-md-textinput": "^2.0.4", "react-native-video": "^1.0.0", "react-native-video-controls": "^1.1.1" },

Code Below import React, { Component} from 'react'; import { AppRegistry, StyleSheet, Text, View, StatusBar, KeyboardAvoidingView, TabBarIOS, Image } from 'react-native'; import { Container, Content, Card, CardItem, Tabs, Tab, Left, Body,Thumbnail,Footer, FooterTab, Button, Icon } from 'native-base';

import VideoPlayer from 'react-native-video-controls'; export default class Test extends Component {

render() {
    return (
      <View style={styles.ViewContainer}>
      <VideoPlayer
        source={{ uri: 'https://vjs.zencdn.net/v/oceans.mp4' }}
        navigator={ this.props.navigator }
        />
      </View>
    );
}

} const styles = StyleSheet.create({ ViewContainer: { flex: 1, flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'stretch', backgroundColor: '#fff', }, loginView: { alignItems:'center', flexGrow:1, justifyContent: 'center', }, header:{ height: 70, backgroundColor: '#e74c3c', paddingTop:30, shadowColor: '#aaa', shadowOpacity: 1, }, headerTitle:{ color:'#fff', fontSize: 20, alignItems:'center', justifyContent: 'center', }, image:{ flex:1, height:200 }, slider:{ flex:1, flexDirection: 'row', height:200 }, card:{ padding:0, margin:0 }, info:{ padding:20 }, title:{ fontWeight:"bold" } });

j3rin commented 7 years ago

Thank you for your help

kylemilloy commented 7 years ago

No problem....gimme a bit to play around with this and build out a few tests.

j3rin commented 7 years ago

Figured it out, my ringer was on mute on the iPhone. how can overide this because instagram and other applications audio worked.

kylemilloy commented 7 years ago

D'oh.

For playing while muted: https://github.com/react-native-community/react-native-video/issues/531

When I built this a few months back there were a few things that didn't quite work well with RN Video 0.9...example: +/- buttons on the side also don't fully respond to the volume either. I'm a little busy these days but am planning on doing an overhaul to this package...need to update the RN version it uses as well as a couple more features that'd be nice to have (such as your play audio while muted bit).

j3rin commented 7 years ago

Thank you so much, really appreciate it!

j3rin commented 7 years ago

Sorry, but where do i add this. Im new to mobile development. forgive my ignorance.

do { try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with:AVAudioSessionCategoryOptions.mixWithOthers) print("AppDelegate: [AVPlayer] setCategory to Playback") do { try AVAudioSession.sharedInstance().setActive(true) print("AppDelegate: [AVPlayer] activate ") } catch let error as NSError { print("AppDelegate: Warning [AVPlayer] setCategory failed with error (error)") } } catch let error as NSError { print("AppDelegate: Warning [AVPlayer] failed to change category: (error)") }

kylemilloy commented 7 years ago

No problem. You add it in your AppDelegate.m file.

In your app file go into the ios folder and open the .xcodeproj file

In the tree view you'll see your project...open that and then the folder with your project name and you'll see AppDelegate.m.

That said, that code is Swift so you'll need to change it to Obj-C if you're going to place it directly into your delegate file.

http://stackoverflow.com/questions/31309249/how-to-convert-objective-c-appdelegate-to-swift

https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

j3rin commented 7 years ago

Last question lol, How do I convert swift code to Obj-C. Thanks a million!

j3rin commented 7 years ago

Wait Got it. This works!

NSError setCategoryErr = nil; NSError activationErr = nil; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&setCategoryErr]; [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];

kylemilloy commented 7 years ago

Excellent. Good luck out there.