2016-06-26 255 views
1

因此,當我的視頻加載並開始播放時,設備(ipod,spotify)的音頻停止播放。如果我強制播放音頻(通過切換到iPod並按下播放鍵並回到我的應用程序),視頻會被凍結。我還在應用程序中直接測試了一個音頻文件,並且在播放視頻時效果很好。音頻全部通過應用程序,我把它放在與視頻相同的UIView中。該應用中的所有視頻都沒有任何音頻文件。我已經嘗試過在視頻標籤中沒有運氣的「靜音」偏好。這是該應用程序的重要組成部分,任何幫助將非常感激。設備音頻播放時視頻不播放,反之亦然

HTML:

<div style="height:85%;width:100%;border:0px solid purple;border-radius:100px;margin-left:auto;margin-right:auto;margin-top:0%;" ng-click="showIt();" on-swipe-right="prev()" on-swipe-left="next()"> 

    <video webkit-playsinline muted autoplay loop ng-src="{{keeper}}" style="width:100%;height:100%;border:0px solid white;border-radius:100px;z-index:1;"> 
    </video> 

</div> 

我願意嘗試任何事情,所以請隨時扔掉你的任何想法。

+0

請參閱http://stackoverflow.com/questions/15728424/html5-video-is-not-working-with-angularjs-ng-src-tag您必須爲您的音頻創建過濾器 –

+0

這是列出的問題(現在封閉)的角度。有一個SO問題的答案和一個正式的解決方法從角度列表這裏https://github.com/angular/angular.js/issues/1352 –

+0

@RachelGallen視頻文件是.mp4文件沒有音頻(我編輯它們在premiere pro)。他們是運動視頻(每個3-4秒)循環遍歷,以演示不同的鍛鍊動作..我會嘗試過濾器,讓你知道...謝謝:) – MehdiN

回答

0

下面的代碼是從ThePolyGlotDeveloper.com

ionic start IonicProject blank 
cd IonicProject 
ionic platform add android 
ionic platform add ios 

安裝Apache科爾多瓦媒體PluginShell

cordova plugin add org.apache.cordova.media 

的index.html

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
     <title></title> 
     <link href="lib/ionic/css/ionic.css" rel="stylesheet"> 
     <link href="css/style.css" rel="stylesheet"> 
     <script src="lib/ionic/js/ionic.bundle.js"></script> 
     <script src="js/ng-cordova.min.js"></script> 
     <script src="cordova.js"></script> 
     <script src="js/app.js"></script> 
    </head> 
    <body ng-app="starter"> 
    //important to note that ng-cordova.min.js must come before cordova.js in your script includes. Your project will not work correctly if it comes after. 


    app.js 

    angular.module('starter', ['ionic', 'ngCordova']) 

創建一個新的控制器,就像這樣:

app.js

example.controller("ExampleController", function($scope, $cordovaMedia, $ionicLoading) { 

    $scope.play = function(src) { 
     var media = new Media(src, null, null, mediaStatusCallback); 
     $cordovaMedia.play(media); 
    } 

    var mediaStatusCallback = function(status) { 
     if(status == 1) { 
      $ionicLoading.show({template: 'Loading...'}); 
     } else { 
      $ionicLoading.hide(); 
     } 
    } 

}); 

播放從URL(index.html的)

<ion-content ng-controller="ExampleController"> 
    <button class="button" ng-click="play('http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2013.mp3')">Play from internet</button> 
</ion-content> 

或本地文件(index.html文件):

<ion-content ng-controller="ExampleController"> 
    <button class="button" ng-click="play('www/mp3/song.mp3')">Play from file system</button> 
</ion-content> 

觀看tutorial video

Code Source